Skip to content

Commit 460ed45

Browse files
committed
Allow config using --artifact-digest-algo
Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent 3649d27 commit 460ed45

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

main.go

+16-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import (
4444
"github.com/fluxcd/pkg/runtime/logger"
4545
"github.com/fluxcd/pkg/runtime/pprof"
4646
"github.com/fluxcd/pkg/runtime/probes"
47+
48+
"github.com/fluxcd/source-controller/internal/digest"
4749
"github.com/fluxcd/source-controller/internal/features"
4850
"github.com/fluxcd/source-controller/internal/helm/registry"
4951

@@ -102,6 +104,7 @@ func main() {
102104
helmCachePurgeInterval string
103105
artifactRetentionTTL time.Duration
104106
artifactRetentionRecords int
107+
artifactDigestAlgo string
105108
)
106109

107110
flag.StringVar(&metricsAddr, "metrics-addr", envOrDefault("METRICS_ADDR", ":8080"),
@@ -137,9 +140,11 @@ func main() {
137140
flag.StringSliceVar(&git.HostKeyAlgos, "ssh-hostkey-algos", []string{},
138141
"The list of hostkey algorithms to use for ssh connections, arranged from most preferred to the least.")
139142
flag.DurationVar(&artifactRetentionTTL, "artifact-retention-ttl", 60*time.Second,
140-
"The duration of time that artifacts from previous reconcilations will be kept in storage before being garbage collected.")
143+
"The duration of time that artifacts from previous reconciliations will be kept in storage before being garbage collected.")
141144
flag.IntVar(&artifactRetentionRecords, "artifact-retention-records", 2,
142145
"The maximum number of artifacts to be kept in storage after a garbage collection.")
146+
flag.StringVar(&artifactDigestAlgo, "artifact-digest-algo", digest.Canonical.String(),
147+
"The algorithm to use to calculate the digest of artifacts.")
143148

144149
clientOptions.BindFlags(flag.CommandLine)
145150
logOptions.BindFlags(flag.CommandLine)
@@ -159,7 +164,15 @@ func main() {
159164
os.Exit(1)
160165
}
161166

162-
// Set upper bound file size limits Helm
167+
if artifactDigestAlgo != digest.Canonical.String() {
168+
algo, err := digest.AlgorithmForName(artifactDigestAlgo)
169+
if err != nil {
170+
setupLog.Error(err, "unable to configure canonical digest algorithm")
171+
os.Exit(1)
172+
}
173+
digest.Canonical = algo
174+
}
175+
163176
helm.MaxIndexSize = helmIndexLimit
164177
helm.MaxChartSize = helmChartLimit
165178
helm.MaxChartFileSize = helmChartFileLimit
@@ -169,7 +182,7 @@ func main() {
169182
watchNamespace = os.Getenv("RUNTIME_NAMESPACE")
170183
}
171184

172-
disableCacheFor := []ctrlclient.Object{}
185+
var disableCacheFor []ctrlclient.Object
173186
shouldCache, err := features.Enabled(features.CacheSecretsAndConfigMaps)
174187
if err != nil {
175188
setupLog.Error(err, "unable to check feature gate "+features.CacheSecretsAndConfigMaps)

0 commit comments

Comments
 (0)