Skip to content

Commit

Permalink
fix: implement insecure option for cache repository
Browse files Browse the repository at this point in the history
I forgot to implement it while doing asset caching.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Oct 30, 2023
1 parent 3d99e0a commit 45b7886
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/image-factory/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type Options struct { //nolint:govet
// OCI registry to use to store cached boot assets.
// Only used internally by the image factory.
CacheRepository string
// Allow insecure connection to the cache repository.
InsecureCacheRepository bool
}

// DefaultOptions are the default options.
Expand Down
7 changes: 6 additions & 1 deletion cmd/image-factory/cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,14 @@ func buildAssetBuilder(logger *zap.Logger, artifactsManager *artifacts.Manager,

builderOptions.RemoteOptions = append(builderOptions.RemoteOptions, remoteOptions()...)

repoOpts := []name.Option{}
if opts.InsecureCacheRepository {
repoOpts = append(repoOpts, name.Insecure)
}

var err error

builderOptions.CacheRepository, err = name.NewRepository(opts.CacheRepository)
builderOptions.CacheRepository, err = name.NewRepository(opts.CacheRepository, repoOpts...)
if err != nil {
return nil, fmt.Errorf("failed to parse cache repository: %w", err)
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/image-factory/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func initFlags() cmd.Options {
flag.StringVar(&opts.CacheSigningKeyPath, "cache-signing-key-path", cmd.DefaultOptions.CacheSigningKeyPath, "path to the default cache signing key (PEM-encoded, ECDSA private key)")

flag.StringVar(&opts.CacheRepository, "cache-repository", cmd.DefaultOptions.CacheRepository, "cache repository for boot assets")
flag.BoolVar(
&opts.InsecureCacheRepository,
"insecure-cache-repository",
cmd.DefaultOptions.InsecureCacheRepository,
"allow an insecure connection to the cache repository",
)

flag.Parse()

Expand Down

0 comments on commit 45b7886

Please sign in to comment.