Merge pull request #501 from fluxcd/static-pickups

This commit is contained in:
Hidde Beydals 2021-11-23 10:07:06 +01:00 committed by GitHub
commit 750b10e57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 11 deletions

View File

@ -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(),
))

View File

@ -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(),
))

View File

@ -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
@ -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 {

View File

@ -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)
@ -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(),
))

View File

@ -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())
}

View File

@ -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
}
}

View File

@ -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 {

View File

@ -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)
@ -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...)
}