@@ -49,91 +49,96 @@ func TestPushPullPolicy(t *testing.T) {
4949
5050 testData := []struct {
5151 name string
52- toPushPolicyName []string
5352 toPushPolicyFile string
54- toPushManifestFiles []string
55- toPushValueFiles []string
56- toPushSecretFiles []string
57- toPushFileStore string
5853 expectedPullManifestFiles []string
5954 expectedPullValuesFiles []string
6055 expectedPullSecretsFiles []string
61- disableTLS bool
62- overwrite bool
56+ expectedPullAssetsFiles []string
57+ toPushFileStore string
58+ pushData PushData
6359 }{
6460 {
6561 name : "Validate that we can push and pull a policy using the latest tag, even thought the tag is ignored" ,
66- toPushPolicyName : []string {fmt .Sprintf ("localhost:%d/myrepo:latest" , port .Int ())},
67- disableTLS : true ,
68- toPushPolicyFile : "testdata/Policy.yaml" ,
69- toPushManifestFiles : []string {"testdata/venom.yaml" },
70- toPushValueFiles : []string {"testdata/values.yaml" },
71- toPushSecretFiles : []string {"testdata/secrets.yaml" },
7262 expectedPullManifestFiles : []string {"testdata/venom.yaml" },
7363 expectedPullValuesFiles : []string {"testdata/values.yaml" },
7464 expectedPullSecretsFiles : []string {"testdata/secrets.yaml" },
65+ pushData : PushData {
66+ PolicyReferenceNames : []string {fmt .Sprintf ("localhost:%d/myrepo:latest" , port .Int ())},
67+ PolicyMetadataFile : "testdata/Policy.yaml" ,
68+ DisableTLS : true ,
69+ ManifestsFiles : []string {"testdata/venom.yaml" },
70+ ValuesFiles : []string {"testdata/values.yaml" },
71+ SecretsFiles : []string {"testdata/secrets.yaml" },
72+ },
73+ toPushFileStore : "." ,
7574 },
7675 {
7776 name : "Validate that we can push and pull a policy without tag" ,
78- toPushPolicyName : []string {fmt .Sprintf ("localhost:%d/myrepo" , port .Int ())},
79- disableTLS : true ,
80- toPushPolicyFile : "testdata/Policy.yaml" ,
81- toPushManifestFiles : []string {"testdata/venom.yaml" },
82- toPushValueFiles : []string {"testdata/values.yaml" },
83- toPushSecretFiles : []string {"testdata/secrets.yaml" },
8477 expectedPullManifestFiles : []string {"testdata/venom.yaml" },
8578 expectedPullValuesFiles : []string {"testdata/values.yaml" },
8679 expectedPullSecretsFiles : []string {"testdata/secrets.yaml" },
80+ pushData : PushData {
81+ PolicyReferenceNames : []string {fmt .Sprintf ("localhost:%d/myrepo" , port .Int ())},
82+ PolicyMetadataFile : "testdata/Policy.yaml" ,
83+ DisableTLS : true ,
84+ ManifestsFiles : []string {"testdata/venom.yaml" },
85+ ValuesFiles : []string {"testdata/values.yaml" },
86+ SecretsFiles : []string {"testdata/secrets.yaml" },
87+ },
88+ toPushFileStore : "." ,
8789 },
8890 {
8991 name : "Validate that we can push and pull a policy without tag from a different file store" ,
90- toPushPolicyName : []string {fmt .Sprintf ("localhost:%d/myrepo" , port .Int ())},
91- disableTLS : true ,
92- toPushPolicyFile : "testdata/Policy.yaml" ,
93- toPushManifestFiles : []string {"testdata/venom.yaml" },
94- toPushValueFiles : []string {"testdata/values.yaml" },
95- toPushSecretFiles : []string {"testdata/secrets.yaml" },
9692 expectedPullManifestFiles : []string {"testdata/venom.yaml" },
9793 expectedPullValuesFiles : []string {"testdata/values.yaml" },
9894 expectedPullSecretsFiles : []string {"testdata/secrets.yaml" },
9995 toPushFileStore : "." ,
96+ pushData : PushData {
97+ PolicyReferenceNames : []string {fmt .Sprintf ("localhost:%d/myrepo" , port .Int ())},
98+ PolicyMetadataFile : "testdata/Policy.yaml" ,
99+ DisableTLS : true ,
100+ ManifestsFiles : []string {"testdata/venom.yaml" },
101+ ValuesFiles : []string {"testdata/values.yaml" },
102+ SecretsFiles : []string {"testdata/secrets.yaml" },
103+ },
104+ },
105+ {
106+ name : "Validate that we can push and pull a policy with assets" ,
107+ expectedPullManifestFiles : []string {"testdata/venom.yaml" },
108+ expectedPullValuesFiles : []string {"testdata/values.yaml" },
109+ expectedPullSecretsFiles : []string {"testdata/secrets.yaml" },
110+ expectedPullAssetsFiles : []string {"testdata/asset.sh" },
111+ toPushFileStore : "." ,
112+ pushData : PushData {
113+ PolicyReferenceNames : []string {fmt .Sprintf ("localhost:%d/myrepo" , port .Int ())},
114+ DisableTLS : true ,
115+ PolicyMetadataFile : "testdata/Policy.yaml" ,
116+ AssetsFiles : []string {"testdata/asset.sh" },
117+ ManifestsFiles : []string {"testdata/venom.yaml" },
118+ ValuesFiles : []string {"testdata/values.yaml" },
119+ SecretsFiles : []string {"testdata/secrets.yaml" },
120+ },
100121 },
101122 }
102123
103124 for _ , data := range testData {
104125
105126 t .Run (data .name , func (t * testing.T ) {
106- err = Push (
107- data .toPushPolicyFile ,
108- data .toPushManifestFiles ,
109- data .toPushValueFiles ,
110- data .toPushSecretFiles ,
111- data .toPushPolicyName ,
112- data .disableTLS ,
113- data .toPushFileStore ,
114- data .overwrite )
127+ err = Push (data .pushData )
115128 require .NoError (t , err )
116129
117- err = Push (
118- data .toPushPolicyFile ,
119- data .toPushManifestFiles ,
120- data .toPushValueFiles ,
121- data .toPushSecretFiles ,
122- data .toPushPolicyName ,
123- data .disableTLS ,
124- data .toPushFileStore ,
125- data .overwrite )
130+ err = Push (data .pushData )
126131 require .NoError (t , err )
127132
128133 gotManifests , gotValues , gotSecrets , err := Pull (
129- data .toPushPolicyName [0 ],
130- data .disableTLS ,
134+ data .pushData . PolicyReferenceNames [0 ],
135+ data .pushData . DisableTLS ,
131136 )
132137 require .NoError (t , err )
133138
134139 expectedManifest , expectedValues , expectedSecrets , err := sanitizeDirPath (
135- data .toPushPolicyName [0 ],
136- data .disableTLS ,
140+ data .pushData . PolicyReferenceNames [0 ],
141+ data .pushData . DisableTLS ,
137142 data .expectedPullManifestFiles ,
138143 data .expectedPullValuesFiles ,
139144 data .expectedPullSecretsFiles ,
0 commit comments