@@ -1798,12 +1798,13 @@ func TestResolveChartJobs_ExcludeExtras(t *testing.T) {
17981798 tests := []struct {
17991799 name string
18001800 cli bool
1801+ cliChanged bool
18011802 annotation string
18021803 perChart bool
18031804 want bool
18041805 }{
18051806 {name : "nothing set" , want : false },
1806- {name : "CLI flag alone" , cli : true , want : true },
1807+ {name : "CLI flag alone" , cli : true , cliChanged : true , want : true },
18071808 {name : "annotation alone" , annotation : "true" , want : true },
18081809 {name : "per-chart alone" , perChart : true , want : true },
18091810 {
@@ -1816,26 +1817,37 @@ func TestResolveChartJobs_ExcludeExtras(t *testing.T) {
18161817 // --exclude-extras back off; both are one-way switches.
18171818 name : "CLI flag survives an annotation that is not true" ,
18181819 cli : true ,
1820+ cliChanged : true ,
18191821 annotation : "false" ,
18201822 want : true ,
18211823 },
18221824 {
1823- name : "CLI flag survives a false per-chart field" ,
1824- cli : true ,
1825- perChart : false ,
1826- want : true ,
1825+ name : "CLI flag survives a false per-chart field" ,
1826+ cli : true ,
1827+ cliChanged : true ,
1828+ perChart : false ,
1829+ want : true ,
18271830 },
18281831 {
18291832 name : "annotation survives a false per-chart field" ,
18301833 annotation : "true" ,
18311834 perChart : false ,
18321835 want : true ,
18331836 },
1837+ {
1838+ // An explicit CLI --exclude-extras=false wins outright over an
1839+ // annotation/per-chart true.
1840+ name : "explicit CLI false overrides annotation and per-chart" ,
1841+ cliChanged : true ,
1842+ annotation : "true" ,
1843+ perChart : true ,
1844+ want : false ,
1845+ },
18341846 }
18351847
18361848 for _ , tc := range tests {
18371849 t .Run (tc .name , func (t * testing.T ) {
1838- o := & flags.SyncOpts {ExcludeExtras : tc .cli }
1850+ o := & flags.SyncOpts {ExcludeExtras : tc .cli , ExcludeExtrasChanged : tc . cliChanged }
18391851 a := map [string ]string {}
18401852 if tc .annotation != "" {
18411853 a [consts .ImageAnnotationExcludeExtras ] = tc .annotation
@@ -1877,10 +1889,16 @@ func TestResolveChartJobs_Platform(t *testing.T) {
18771889 want : "linux/amd64" ,
18781890 },
18791891 {
1880- name : "per-chart wins over both " ,
1892+ name : "CLI flag wins over annotation and per-chart " ,
18811893 cli : "linux/amd64" ,
18821894 annotation : "linux/arm64" ,
18831895 perChart : "linux/s390x" ,
1896+ want : "linux/amd64" ,
1897+ },
1898+ {
1899+ name : "per-chart wins over annotation when CLI flag unset" ,
1900+ annotation : "linux/arm64" ,
1901+ perChart : "linux/s390x" ,
18841902 want : "linux/s390x" ,
18851903 },
18861904 {
@@ -2155,7 +2173,6 @@ func TestResolveChartJobs_NoCharts(t *testing.T) {
21552173// TestResolveChartJobs_CredentialFields pins that every TLS/verification
21562174// field on v1.Chart reaches the job's ChartOpts unchanged.
21572175func TestResolveChartJobs_CredentialFields (t * testing.T ) {
2158- insecure := true
21592176 ch := v1.Chart {
21602177 Name : "rancher" ,
21612178 Verify : true ,
@@ -2164,7 +2181,7 @@ func TestResolveChartJobs_CredentialFields(t *testing.T) {
21642181 CertFile : "/certs/client.crt" ,
21652182 KeyFile : "/certs/client.key" ,
21662183 CaFile : "/certs/ca.crt" ,
2167- InsecureSkipTLSVerify : & insecure ,
2184+ InsecureSkipTLSVerify : true ,
21682185 PlainHTTP : true ,
21692186 }
21702187
@@ -2195,8 +2212,8 @@ func TestResolveChartJobs_CredentialFields(t *testing.T) {
21952212 if opts .CaFile != ch .CaFile {
21962213 t .Errorf ("CaFile = %q, want %q" , opts .CaFile , ch .CaFile )
21972214 }
2198- if opts .InsecureSkipTLSVerify != derefInsecure ( ch .InsecureSkipTLSVerify ) {
2199- t .Errorf ("InsecureSkipTLSVerify = %v, want %v" , opts .InsecureSkipTLSVerify , derefInsecure ( ch .InsecureSkipTLSVerify ) )
2215+ if opts .InsecureSkipTLSVerify != ch .InsecureSkipTLSVerify {
2216+ t .Errorf ("InsecureSkipTLSVerify = %v, want %v" , opts .InsecureSkipTLSVerify , ch .InsecureSkipTLSVerify )
22002217 }
22012218 if opts .PlainHTTP != ch .PlainHTTP {
22022219 t .Errorf ("PlainHTTP = %v, want %v" , opts .PlainHTTP , ch .PlainHTTP )
@@ -2999,7 +3016,7 @@ func TestStoreImage_CAFileAndInsecure(t *testing.T) {
29993016 t .Run ("bad caFile without insecure returns error and stores nothing" , func (t * testing.T ) {
30003017 s := newTestStore (t )
30013018 insecure := false
3002- img := v1.Image {Name : ref , CaFile : missingCA , InsecureSkipTLSVerify : & insecure }
3019+ img := v1.Image {Name : ref , CaFile : missingCA , InsecureSkipTLSVerify : insecure }
30033020 err := storeImage (ctx , s , img , "" , false ,
30043021 defaultRootOpts (s .Root ), defaultCliOpts (), "" , "" , false )
30053022 if err == nil {
@@ -3017,7 +3034,7 @@ func TestStoreImage_CAFileAndInsecure(t *testing.T) {
30173034 t .Fatal (err )
30183035 }
30193036 insecure := false
3020- img := v1.Image {Name : ref , CaFile : junk , InsecureSkipTLSVerify : & insecure }
3037+ img := v1.Image {Name : ref , CaFile : junk , InsecureSkipTLSVerify : insecure }
30213038 err := storeImage (ctx , s , img , "" , false ,
30223039 defaultRootOpts (s .Root ), defaultCliOpts (), "" , "" , false )
30233040 if err == nil {
@@ -3031,7 +3048,7 @@ func TestStoreImage_CAFileAndInsecure(t *testing.T) {
30313048 // ignored and the pull still succeeds. If caFile were read first, the
30323049 // pull would error and nothing would be stored.
30333050 insecure := true
3034- img := v1.Image {Name : ref , CaFile : missingCA , InsecureSkipTLSVerify : & insecure }
3051+ img := v1.Image {Name : ref , CaFile : missingCA , InsecureSkipTLSVerify : insecure }
30353052 err := storeImage (ctx , s , img , "" , false ,
30363053 defaultRootOpts (s .Root ), defaultCliOpts (), "" , "" , false )
30373054 if err != nil {
@@ -3043,7 +3060,7 @@ func TestStoreImage_CAFileAndInsecure(t *testing.T) {
30433060 t .Run ("valid caFile without insecure is accepted" , func (t * testing.T ) {
30443061 s := newTestStore (t )
30453062 insecure := false
3046- img := v1.Image {Name : ref , CaFile : writeCAFile (t ), InsecureSkipTLSVerify : & insecure }
3063+ img := v1.Image {Name : ref , CaFile : writeCAFile (t ), InsecureSkipTLSVerify : insecure }
30473064 err := storeImage (ctx , s , img , "" , false ,
30483065 defaultRootOpts (s .Root ), defaultCliOpts (), "" , "" , false )
30493066 if err != nil {
0 commit comments