@@ -120,3 +120,105 @@ requires:
120
120
})
121
121
}
122
122
}
123
+
124
+ func TestRenderWithRemoteGCS (t * testing.T ) {
125
+ tests := []struct {
126
+ description string
127
+ configFile string
128
+ args []string
129
+ shouldErr bool
130
+ expectedOutput string
131
+ expectedErrMsg string
132
+ }{
133
+ {
134
+ description : "download all repo with same folders from subfolder" ,
135
+ configFile : `apiVersion: skaffold/v4beta11
136
+ kind: Config
137
+ requires:
138
+ - googleCloudStorage:
139
+ source: gs://skaffold-remote-dependency-e2e-tests/test1/*
140
+ path: ./skaffold.yaml
141
+ ` ,
142
+ args : []string {"--tag" , "fixed" , "--default-repo=" , "--digest-source" , "tag" },
143
+ expectedOutput : `apiVersion: v1
144
+ kind: Pod
145
+ metadata:
146
+ name: getting-started
147
+ spec:
148
+ containers:
149
+ - image: skaffold-example:fixed
150
+ name: getting-started` ,
151
+ },
152
+ {
153
+ description : "download full repo with top sub folder" ,
154
+ configFile : `apiVersion: skaffold/v4beta11
155
+ kind: Config
156
+ requires:
157
+ - googleCloudStorage:
158
+ source: gs://skaffold-remote-dependency-e2e-tests/test1
159
+ path: ./test1/skaffold.yaml
160
+ ` ,
161
+ args : []string {"--tag" , "fixed" , "--default-repo=" , "--digest-source" , "tag" },
162
+ expectedOutput : `apiVersion: v1
163
+ kind: Pod
164
+ metadata:
165
+ name: getting-started
166
+ spec:
167
+ containers:
168
+ - image: skaffold-example:fixed
169
+ name: getting-started` ,
170
+ },
171
+ {
172
+ description : "download full repo with bucket name as top folder" ,
173
+ configFile : `apiVersion: skaffold/v4beta11
174
+ kind: Config
175
+ requires:
176
+ - googleCloudStorage:
177
+ source: gs://skaffold-remote-dependency-e2e-tests
178
+ path: ./skaffold-remote-dependency-e2e-tests/test1/skaffold.yaml
179
+ ` ,
180
+ args : []string {"--tag" , "fixed" , "--default-repo=" , "--digest-source" , "tag" },
181
+ expectedOutput : `apiVersion: v1
182
+ kind: Pod
183
+ metadata:
184
+ name: getting-started
185
+ spec:
186
+ containers:
187
+ - image: skaffold-example:fixed
188
+ name: getting-started` ,
189
+ },
190
+ {
191
+ description : "download only all yaml files across bucket" ,
192
+ configFile : `apiVersion: skaffold/v4beta11
193
+ kind: Config
194
+ requires:
195
+ - googleCloudStorage:
196
+ source: gs://skaffold-remote-dependency-e2e-tests/test1/**.yaml
197
+ path: ./skaffold.yaml
198
+ ` ,
199
+ args : []string {"--tag" , "fixed" , "--default-repo=" , "--digest-source" , "tag" , "-p" , "flat-structure" },
200
+ expectedOutput : `apiVersion: v1
201
+ kind: Pod
202
+ metadata:
203
+ name: getting-started
204
+ spec:
205
+ containers:
206
+ - image: skaffold-example:fixed
207
+ name: getting-started` ,
208
+ },
209
+ }
210
+
211
+ for _ , test := range tests {
212
+ testutil .Run (t , test .description , func (t * testutil.T ) {
213
+ MarkIntegrationTest (t .T , NeedsGcp )
214
+ tmpDirRemoteRepo := t .NewTempDir ()
215
+ tmpDirTest := t .NewTempDir ()
216
+
217
+ tmpDirTest .Write ("skaffold.yaml" , test .configFile )
218
+ args := append (test .args , "--remote-cache-dir" , tmpDirRemoteRepo .Root ())
219
+ output , err := skaffold .Render (args ... ).InDir (tmpDirTest .Root ()).RunWithCombinedOutput (t .T )
220
+ t .CheckNoError (err )
221
+ t .CheckDeepEqual (test .expectedOutput , string (output ), testutil .YamlObj (t .T ))
222
+ })
223
+ }
224
+ }
0 commit comments