@@ -59,7 +59,7 @@ func AddFileCmd(ctx context.Context, o *flags.AddFileOpts, s *store.Layout, refe
5959 cfg := v1.File {
6060 Path : reference ,
6161 CaFile : o .CaFile ,
62- InsecureSkipTLSVerify : & o .InsecureSkipTLSVerify ,
62+ InsecureSkipTLSVerify : o .InsecureSkipTLSVerify ,
6363 }
6464 if len (o .Name ) > 0 {
6565 cfg .Name = o .Name
@@ -83,7 +83,7 @@ func storeFile(ctx context.Context, s *store.Layout, fi v1.File, ro *flags.CliRo
8383
8484 copts := getter.ClientOptions {
8585 NameOverride : fi .Name ,
86- InsecureSkipTLSVerify : derefInsecure ( fi .InsecureSkipTLSVerify ) ,
86+ InsecureSkipTLSVerify : fi .InsecureSkipTLSVerify ,
8787 CAFile : fi .CaFile ,
8888 }
8989
@@ -248,15 +248,15 @@ func AddImageCmd(ctx context.Context, o *flags.AddImageOpts, s *store.Layout, re
248248func addImageVerifyConfig (o * flags.AddImageOpts ) cosign.Config {
249249 switch {
250250 case o .Key != "" :
251- return cosign.Config {Key : o .Key , Tlog : o .Tlog , InsecureSkipTLSVerify : derefInsecure ( o .InsecureSkipTLSVerify ) , CaFile : o .CaFile }
251+ return cosign.Config {Key : o .Key , Tlog : o .Tlog , InsecureSkipTLSVerify : o .InsecureSkipTLSVerify , CaFile : o .CaFile }
252252 case o .CertIdentityRegexp != "" || o .CertIdentity != "" :
253253 return cosign.Config {
254254 CertIdentity : o .CertIdentity ,
255255 CertIdentityRegexp : o .CertIdentityRegexp ,
256256 CertOidcIssuer : o .CertOidcIssuer ,
257257 CertOidcIssuerRegexp : o .CertOidcIssuerRegexp ,
258258 CertGithubWorkflowRepository : o .CertGithubWorkflowRepository ,
259- InsecureSkipTLSVerify : derefInsecure ( o .InsecureSkipTLSVerify ) ,
259+ InsecureSkipTLSVerify : o .InsecureSkipTLSVerify ,
260260 CaFile : o .CaFile ,
261261 }
262262 default :
@@ -480,7 +480,7 @@ func storeImage(ctx context.Context, s *store.Layout, i v1.Image, platform strin
480480 return err
481481 }
482482
483- insecureSkipTLSVerify := derefInsecure ( i .InsecureSkipTLSVerify )
483+ insecureSkipTLSVerify := i .InsecureSkipTLSVerify
484484 caFile := i .CaFile
485485
486486 log .BaseFromContext (ctx ).Debugf ("resolving image [%s] (verified=%t, platform=%q, excludeExtras=%t, insecureSkipTLSVerify=%t, caFile=%q, rewrite=%q, digest=%q)" , i .Name , verified , platform , excludeExtras , insecureSkipTLSVerify , caFile , rewrite , pinnedDigest )
@@ -619,7 +619,13 @@ func rewriteReference(ctx context.Context, s *store.Layout, oldRef name.Referenc
619619 // index.docker.io. Preserve the original registry when the source is non-docker.
620620 if newRegistry == "index.docker.io" && ! strings .HasPrefix (rawRewrite , "docker.io" ) && ! strings .HasPrefix (rawRewrite , "index.docker.io" ) {
621621 newRegistry = oldRegistry
622- newRepo = strings .TrimPrefix (newRepo , "library/" ) //if rewrite has library/ prefix in path it is stripped off unless registry specified in rewrite
622+ rewriteRepo := strings .TrimPrefix (rawRewrite , "/" )
623+ if i := strings .LastIndex (rewriteRepo , ":" ); i != - 1 {
624+ rewriteRepo = rewriteRepo [:i ]
625+ }
626+ if ! strings .HasPrefix (rewriteRepo , "library/" ) {
627+ newRepo = strings .TrimPrefix (newRepo , "library/" )
628+ }
623629 }
624630 oldTotal := oldRepo + ":" + oldTag
625631 newTotal := newRepo + ":" + newTag
@@ -777,11 +783,11 @@ type chartJob struct {
777783//
778784// The three precedence rules are not uniform. registry is CLI > annotation.
779785// excludeExtras is a one-way switch that any of the three sources can flip on
780- // and none can flip off. platform is per-chart > CLI > annotation: an explicit
781- // --platform is run-time intent and outranks manifest metadata . That last rule
782- // must stay identical to resolveImageJobs's, or a single `hauler store sync`
783- // run would pull a chart's discovered images for a different platform than the
784- // manifest's own Images section.
786+ // and none can flip off, since a plain bool has no unset state. platform is
787+ // CLI > per-chart > annotation . That last rule must stay identical to
788+ // resolveImageJobs's, or a single `hauler store sync` run would pull a
789+ // chart's discovered images for a different platform than the manifest's own
790+ // Images section.
785791//
786792// Every job allocates its own *action.ChartPathOptions. flags.AddChartOpts
787793// holds that as a pointer, so copying the struct alone would leave sibling
@@ -795,20 +801,15 @@ func resolveChartJobs(o *flags.SyncOpts, annotations map[string]string, manifest
795801
796802 jobs := make ([]chartJob , 0 , len (charts ))
797803 for _ , ch := range charts {
798- excludeExtras := o .ExcludeExtras
799- if ! o .ExcludeExtras && annotations [consts .ImageAnnotationExcludeExtras ] == "true" {
800- excludeExtras = true
801- }
802- if ch .ExcludeExtras {
803- excludeExtras = ch .ExcludeExtras
804- }
804+ excludeExtras := resolveBoolFlag (ch .ExcludeExtras , annotations [consts .ImageAnnotationExcludeExtras ] == "true" , o .ExcludeExtras , o .ExcludeExtrasChanged )
805805
806806 platform := o .Platform
807- if o .Platform == "" && annotations [consts .ImageAnnotationPlatform ] != "" {
808- platform = annotations [consts .ImageAnnotationPlatform ]
809- }
810- if ch .Platform != "" {
811- platform = ch .Platform
807+ if o .Platform == "" {
808+ if ch .Platform != "" {
809+ platform = ch .Platform
810+ } else if annotations [consts .ImageAnnotationPlatform ] != "" {
811+ platform = annotations [consts .ImageAnnotationPlatform ]
812+ }
812813 }
813814
814815 var valuesFiles []string
@@ -826,16 +827,13 @@ func resolveChartJobs(o *flags.SyncOpts, annotations map[string]string, manifest
826827 if caFile == "" {
827828 if ch .CaFile != "" {
828829 caFile = ch .CaFile
829- } else if annotations [consts .ImageAnnotationCaFile ] == "true " {
830+ } else if annotations [consts .ImageAnnotationCaFile ] != " " {
830831 caFile = annotations [consts .ImageAnnotationCaFile ]
831832 }
832833 }
833834
834- insecureSkipTLSVerify := false
835- if o .CaFile == "" {
836- insecureSkipTLSVerify = resolveInsecure (ch .InsecureSkipTLSVerify , annotations , o .InsecureSkipTLSVerify )
837- } else {
838- }
835+ // a CA file and skipping TLS verification are mutually exclusive: providing one forces verification on
836+ insecureSkipTLSVerify := o .CaFile == "" && resolveBoolFlag (ch .InsecureSkipTLSVerify , annotations [consts .ImageAnnotationInsecureSkipTLSVerify ] == "true" , o .InsecureSkipTLSVerify , o .InsecureChanged )
839837
840838 jobs = append (jobs , chartJob {
841839 cfg : ch ,
@@ -1381,12 +1379,11 @@ func fetchChart(ctx context.Context, s *store.Layout, j chartJob, tempRoot strin
13811379 // there is no separate per-discovered-image TLS knob in a chart
13821380 // manifest, so the registry a chart's images live in is assumed
13831381 // to share the chart repo's trust configuration.
1384- chartInsecure := j .opts .ChartOpts .InsecureSkipTLSVerify
13851382 imageJobs = append (imageJobs , imageJob {
13861383 img : v1.Image {
13871384 Name : relocated ,
13881385 CaFile : j .opts .ChartOpts .CaFile ,
1389- InsecureSkipTLSVerify : & chartInsecure ,
1386+ InsecureSkipTLSVerify : j . opts . ChartOpts . InsecureSkipTLSVerify ,
13901387 },
13911388 platform : j .opts .Platform ,
13921389 excludeExtras : j .opts .ExcludeExtras ,
@@ -1461,6 +1458,7 @@ func fetchChart(ctx context.Context, s *store.Layout, j chartJob, tempRoot strin
14611458// rewrite. A rewrite that omits a tag inherits ref's.
14621459func rewriteChartReference (ctx context.Context , s * store.Layout , ref name.Reference , rewrite string ) error {
14631460 rewrite = strings .TrimPrefix (rewrite , "/" )
1461+ rawRewrite := rewrite
14641462 newRef , err := name .ParseReference (rewrite )
14651463 if err != nil {
14661464 // error... don't continue with a bad reference
@@ -1483,6 +1481,13 @@ func rewriteChartReference(ctx context.Context, s *store.Layout, ref name.Refere
14831481 // rename chart name in store
14841482 oldRepo := ref .Context ().RepositoryStr ()
14851483 newRepo := newRef .Context ().RepositoryStr ()
1484+ rewriteRepo := rawRewrite
1485+ if i := strings .LastIndex (rewriteRepo , ":" ); i != - 1 {
1486+ rewriteRepo = rewriteRepo [:i ]
1487+ }
1488+ if ! strings .HasPrefix (rewriteRepo , "library/" ) {
1489+ newRepo = strings .TrimPrefix (newRepo , "library/" )
1490+ }
14861491 newTag := newRef .Identifier ()
14871492 if tag , ok := newRef .(name.Tag ); ok {
14881493 newTag = tag .TagStr ()
0 commit comments