Skip to content

Commit

Permalink
Merge pull request fluxcd#501 from fluxcd/static-pickups
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddeco committed Nov 23, 2021
2 parents baae990 + 6cadb04 commit 750b10e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion controllers/bucket_controller.go
Expand Up @@ -170,7 +170,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
r.recordReadiness(ctx, reconciledBucket)

log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
time.Now().Sub(start).String(),
time.Since(start).String(),
bucket.GetInterval().Duration.String(),
))

Expand Down
2 changes: 1 addition & 1 deletion controllers/gitrepository_controller.go
Expand Up @@ -192,7 +192,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
r.recordReadiness(ctx, reconciledRepository)

log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
time.Now().Sub(start).String(),
time.Since(start).String(),
repository.GetInterval().Duration.String(),
))

Expand Down
3 changes: 2 additions & 1 deletion controllers/helmchart_controller.go
Expand Up @@ -247,7 +247,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
r.recordReadiness(ctx, reconciledChart)

log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
time.Now().Sub(start).String(),
time.Since(start).String(),
chart.GetInterval().Duration.String(),
))
return ctrl.Result{RequeueAfter: chart.GetInterval().Duration}, nil
Expand Down Expand Up @@ -307,6 +307,7 @@ func (r *HelmChartReconciler) fromHelmRepository(ctx context.Context, repo sourc
authDir := filepath.Join(workDir, "creds")
if err := os.Mkdir(authDir, 0700); err != nil {
err = fmt.Errorf("failed to create temporary directory for repository credentials: %w", err)
return sourcev1.HelmChartNotReady(c, sourcev1.StorageOperationFailedReason, err.Error()), err
}
opts, err := getter.ClientOptionsFromSecret(authDir, *secret)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion controllers/helmrepository_controller.go
Expand Up @@ -89,6 +89,9 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return ctrl.Result{}, client.IgnoreNotFound(err)
}

// Record suspended status metric
defer r.recordSuspension(ctx, repository)

// Add our finalizer if it does not exist
if !controllerutil.ContainsFinalizer(&repository, sourcev1.SourceFinalizer) {
controllerutil.AddFinalizer(&repository, sourcev1.SourceFinalizer)
Expand Down Expand Up @@ -163,7 +166,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
r.recordReadiness(ctx, reconciledRepository)

log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
time.Now().Sub(start).String(),
time.Since(start).String(),
repository.GetInterval().Duration.String(),
))

Expand Down
2 changes: 1 addition & 1 deletion internal/helm/chart/builder_remote_test.go
Expand Up @@ -357,8 +357,8 @@ func Test_validatePackageAndWriteToPath(t *testing.T) {
g.Expect(chartPath).To(BeARegularFile())

emptyF, err := os.Open("./../testdata/charts/empty.tgz")
defer emptyF.Close()
g.Expect(err).ToNot(HaveOccurred())
defer emptyF.Close()
err = validatePackageAndWriteToPath(emptyF, filepath.Join(tmpDir, "out.tgz"))
g.Expect(err).To(HaveOccurred())
}
Expand Down
5 changes: 2 additions & 3 deletions main.go
Expand Up @@ -125,11 +125,10 @@ func main() {

var eventRecorder *events.Recorder
if eventsAddr != "" {
if er, err := events.NewRecorder(eventsAddr, controllerName); err != nil {
var err error
if eventRecorder, err = events.NewRecorder(eventsAddr, controllerName); err != nil {
setupLog.Error(err, "unable to create event recorder")
os.Exit(1)
} else {
eventRecorder = er
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/git/libgit2/transport.go
Expand Up @@ -266,7 +266,7 @@ func (k knownKey) matches(host string, hostkey git2go.HostkeyCertificate) bool {
return false
}
hasher.Write(k.key.Marshal())
return bytes.Compare(hasher.Sum(nil), fingerprint) == 0
return bytes.Equal(hasher.Sum(nil), fingerprint)
}

func containsHost(hosts []string, host string) bool {
Expand Down
6 changes: 4 additions & 2 deletions pkg/sourceignore/sourceignore.go
Expand Up @@ -100,7 +100,7 @@ func ReadIgnoreFile(path string, domain []string) ([]gitignore.Pattern, error) {
return ps, nil
}

// LoadIgnorePatterns recursively loads the the IgnoreFile patterns found
// LoadIgnorePatterns recursively loads the IgnoreFile patterns found
// in the directory.
func LoadIgnorePatterns(dir string, domain []string) ([]gitignore.Pattern, error) {
ps, err := ReadIgnoreFile(filepath.Join(dir, IgnoreFile), domain)
Expand All @@ -114,7 +114,9 @@ func LoadIgnorePatterns(dir string, domain []string) ([]gitignore.Pattern, error
for _, fi := range fis {
if fi.IsDir() && fi.Name() != ".git" {
var subps []gitignore.Pattern
subps, err = LoadIgnorePatterns(filepath.Join(dir, fi.Name()), append(domain, fi.Name()))
if subps, err = LoadIgnorePatterns(filepath.Join(dir, fi.Name()), append(domain, fi.Name())); err != nil {
return nil, err
}
if len(subps) > 0 {
ps = append(ps, subps...)
}
Expand Down

0 comments on commit 750b10e

Please sign in to comment.