Skip to content

Commit 750b10e

Browse files
authored
Merge pull request #501 from fluxcd/static-pickups
2 parents baae990 + 6cadb04 commit 750b10e

8 files changed

+16
-11
lines changed

controllers/bucket_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
170170
r.recordReadiness(ctx, reconciledBucket)
171171

172172
log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
173-
time.Now().Sub(start).String(),
173+
time.Since(start).String(),
174174
bucket.GetInterval().Duration.String(),
175175
))
176176

controllers/gitrepository_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
192192
r.recordReadiness(ctx, reconciledRepository)
193193

194194
log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
195-
time.Now().Sub(start).String(),
195+
time.Since(start).String(),
196196
repository.GetInterval().Duration.String(),
197197
))
198198

controllers/helmchart_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
247247
r.recordReadiness(ctx, reconciledChart)
248248

249249
log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
250-
time.Now().Sub(start).String(),
250+
time.Since(start).String(),
251251
chart.GetInterval().Duration.String(),
252252
))
253253
return ctrl.Result{RequeueAfter: chart.GetInterval().Duration}, nil
@@ -307,6 +307,7 @@ func (r *HelmChartReconciler) fromHelmRepository(ctx context.Context, repo sourc
307307
authDir := filepath.Join(workDir, "creds")
308308
if err := os.Mkdir(authDir, 0700); err != nil {
309309
err = fmt.Errorf("failed to create temporary directory for repository credentials: %w", err)
310+
return sourcev1.HelmChartNotReady(c, sourcev1.StorageOperationFailedReason, err.Error()), err
310311
}
311312
opts, err := getter.ClientOptionsFromSecret(authDir, *secret)
312313
if err != nil {

controllers/helmrepository_controller.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
8989
return ctrl.Result{}, client.IgnoreNotFound(err)
9090
}
9191

92+
// Record suspended status metric
93+
defer r.recordSuspension(ctx, repository)
94+
9295
// Add our finalizer if it does not exist
9396
if !controllerutil.ContainsFinalizer(&repository, sourcev1.SourceFinalizer) {
9497
controllerutil.AddFinalizer(&repository, sourcev1.SourceFinalizer)
@@ -163,7 +166,7 @@ func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque
163166
r.recordReadiness(ctx, reconciledRepository)
164167

165168
log.Info(fmt.Sprintf("Reconciliation finished in %s, next run in %s",
166-
time.Now().Sub(start).String(),
169+
time.Since(start).String(),
167170
repository.GetInterval().Duration.String(),
168171
))
169172

internal/helm/chart/builder_remote_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ func Test_validatePackageAndWriteToPath(t *testing.T) {
357357
g.Expect(chartPath).To(BeARegularFile())
358358

359359
emptyF, err := os.Open("./../testdata/charts/empty.tgz")
360-
defer emptyF.Close()
361360
g.Expect(err).ToNot(HaveOccurred())
361+
defer emptyF.Close()
362362
err = validatePackageAndWriteToPath(emptyF, filepath.Join(tmpDir, "out.tgz"))
363363
g.Expect(err).To(HaveOccurred())
364364
}

main.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,10 @@ func main() {
125125

126126
var eventRecorder *events.Recorder
127127
if eventsAddr != "" {
128-
if er, err := events.NewRecorder(eventsAddr, controllerName); err != nil {
128+
var err error
129+
if eventRecorder, err = events.NewRecorder(eventsAddr, controllerName); err != nil {
129130
setupLog.Error(err, "unable to create event recorder")
130131
os.Exit(1)
131-
} else {
132-
eventRecorder = er
133132
}
134133
}
135134

pkg/git/libgit2/transport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func (k knownKey) matches(host string, hostkey git2go.HostkeyCertificate) bool {
266266
return false
267267
}
268268
hasher.Write(k.key.Marshal())
269-
return bytes.Compare(hasher.Sum(nil), fingerprint) == 0
269+
return bytes.Equal(hasher.Sum(nil), fingerprint)
270270
}
271271

272272
func containsHost(hosts []string, host string) bool {

pkg/sourceignore/sourceignore.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func ReadIgnoreFile(path string, domain []string) ([]gitignore.Pattern, error) {
100100
return ps, nil
101101
}
102102

103-
// LoadIgnorePatterns recursively loads the the IgnoreFile patterns found
103+
// LoadIgnorePatterns recursively loads the IgnoreFile patterns found
104104
// in the directory.
105105
func LoadIgnorePatterns(dir string, domain []string) ([]gitignore.Pattern, error) {
106106
ps, err := ReadIgnoreFile(filepath.Join(dir, IgnoreFile), domain)
@@ -114,7 +114,9 @@ func LoadIgnorePatterns(dir string, domain []string) ([]gitignore.Pattern, error
114114
for _, fi := range fis {
115115
if fi.IsDir() && fi.Name() != ".git" {
116116
var subps []gitignore.Pattern
117-
subps, err = LoadIgnorePatterns(filepath.Join(dir, fi.Name()), append(domain, fi.Name()))
117+
if subps, err = LoadIgnorePatterns(filepath.Join(dir, fi.Name()), append(domain, fi.Name())); err != nil {
118+
return nil, err
119+
}
118120
if len(subps) > 0 {
119121
ps = append(ps, subps...)
120122
}

0 commit comments

Comments
 (0)