Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start removing fixmes
Browse files Browse the repository at this point in the history
squaremo committed Feb 16, 2018
1 parent 973baab commit 55f6ae8
Showing 5 changed files with 11 additions and 46 deletions.
1 change: 0 additions & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ func (d *Daemon) ListServices(ctx context.Context, namespace string) ([]flux.Con
return nil, errors.Wrap(err, "getting services from cluster")
}

// FIXME(michael): consider a more efficient read-only way to do this
var services policy.ResourceMap
err = d.WithClone(ctx, func(checkout *git.Checkout) error {
var err error
19 changes: 8 additions & 11 deletions daemon/images.go
Original file line number Diff line number Diff line change
@@ -17,17 +17,9 @@ import (
func (d *Daemon) pollForNewImages(logger log.Logger) {
logger.Log("msg", "polling images")

// One day we may use this for operations other than the call at the end
ctx := context.Background()
// FIXME(michael): consider using Repo.Read(...) for this
working, err := d.Repo.Clone(ctx, d.GitConfig)
if err != nil {
logger.Log("err", err)
return
}
defer working.Clean()

candidateServices, err := d.unlockedAutomatedServices(working)
candidateServices, err := d.unlockedAutomatedServices(ctx)
if err != nil {
logger.Log("error", errors.Wrap(err, "getting unlocked automated services"))
return
@@ -86,8 +78,13 @@ func getTagPattern(services policy.ResourceMap, service flux.ResourceID, contain
}

// FIXME(michael) consider rewriting this stuff, it's a bit convulated.
func (d *Daemon) unlockedAutomatedServices(checkout *git.Checkout) (policy.ResourceMap, error) {
services, err := d.Manifests.ServicesWithPolicies(checkout.ManifestDir())
func (d *Daemon) unlockedAutomatedServices(ctx context.Context) (policy.ResourceMap, error) {
var services policy.ResourceMap
err := d.WithClone(ctx, func(checkout *git.Checkout) error {
var err error
services, err = d.Manifests.ServicesWithPolicies(checkout.ManifestDir())
return err
})
if err != nil {
return nil, err
}
5 changes: 3 additions & 2 deletions daemon/loop.go
Original file line number Diff line number Diff line change
@@ -89,8 +89,9 @@ func (d *Daemon) Loop(stop chan struct{}, wg *sync.WaitGroup, logger log.Logger)
case <-syncTimer.C:
d.AskForSync()
case <-d.Repo.C:
// FIXME(michael): context.TODO()
newSyncHead, err := d.Repo.Revision(context.TODO(), d.GitConfig.Branch)
ctx, cancel := context.WithTimeout(context.Background(), gitOpTimeout)
newSyncHead, err := d.Repo.Revision(ctx, d.GitConfig.Branch)
cancel()
if err != nil {
logger.Log("url", d.Repo.Origin().URL, "err", err)
continue
8 changes: 0 additions & 8 deletions git/operations.go
Original file line number Diff line number Diff line change
@@ -96,14 +96,6 @@ func push(ctx context.Context, workingDir, upstream string, refs []string) error
return nil
}

// // pull the specific ref from upstream
// func pull(ctx context.Context, workingDir, upstream, ref string) error {
// if err := execGitCmd(ctx, workingDir, nil, "pull", "--ff-only", upstream, ref); err != nil {
// return errors.Wrap(err, fmt.Sprintf("git pull --ff-only %s %s", upstream, ref))
// }
// return nil
// }

// fetch updates refs from the upstream.
func fetch(ctx context.Context, workingDir, upstream string, refspec ...string) error {
args := append([]string{"fetch", "--tags", upstream}, refspec...)
24 changes: 0 additions & 24 deletions git/repo.go
Original file line number Diff line number Diff line change
@@ -98,30 +98,6 @@ func (r *Repo) Notify() {
}
}

// // Read lets the caller examine a read-only clone of the repo.
// func (r *Repo) Read(ctx context.Context, readf func(dir string) error) error {
// r.mu.RLock()
// s := r.status
// r.mu.RUnlock()
// if s != flux.RepoReady {
// return ErrNotReady
// }

// dir, err := ioutil.TempDir(os.TempDir(), "flux-readclone")
// if err != nil {
// return err
// }
// defer os.RemoveAll(dir)

// r.mu.RLock()
// path, err := clone(ctx, dir, r.dir, r.config.Branch)
// r.mu.RUnlock()
// if err != nil {
// return err
// }
// return readf(filepath.Join(path, r.config.Path))
// }

// Revision returns the revision (SHA1) of the ref passed in
func (r *Repo) Revision(ctx context.Context, ref string) (string, error) {
r.mu.RLock()

0 comments on commit 55f6ae8

Please sign in to comment.