@@ -211,6 +211,59 @@ func Test_optionsFromDataModel(t *testing.T) {
211211 },
212212 expectNumErrorDiags : 2 ,
213213 },
214+ {
215+ name : "errors when git ssh private key path and base64 are set" ,
216+ data : CachedImageResourceModel {
217+ BuilderImage : basetypes .NewStringValue ("envbuilder:latest" ),
218+ CacheRepo : basetypes .NewStringValue ("localhost:5000/cache" ),
219+ GitURL :
basetypes .
NewStringValue (
"[email protected] /devcontainer.git" ),
220+ GitSSHPrivateKeyPath : basetypes .NewStringValue ("/tmp/id_rsa" ),
221+ GitSSHPrivateKeyBase64 : basetypes .NewStringValue ("cHJpdmF0ZUtleQo=" ),
222+ },
223+ expectOpts : eboptions.Options {
224+ CacheRepo : "localhost:5000/cache" ,
225+ GitURL :
"[email protected] /devcontainer.git" ,
226+ RemoteRepoBuildMode : true ,
227+ GitSSHPrivateKeyPath : "/tmp/id_rsa" ,
228+ GitSSHPrivateKeyBase64 : "cHJpdmF0ZUtleQo=" ,
229+ },
230+ expectNumErrorDiags : 1 ,
231+ },
232+ {
233+ name : "extra_env override errors when git ssh private key path and base64 are set" ,
234+ data : CachedImageResourceModel {
235+ BuilderImage : basetypes .NewStringValue ("envbuilder:latest" ),
236+ CacheRepo : basetypes .NewStringValue ("localhost:5000/cache" ),
237+ GitURL :
basetypes .
NewStringValue (
"[email protected] /devcontainer.git" ),
238+ GitSSHPrivateKeyBase64 : basetypes .NewStringValue ("cHJpdmF0ZUtleQo=" ),
239+ ExtraEnv : extraEnvMap (t ,
240+ "ENVBUILDER_GIT_SSH_PRIVATE_KEY_PATH" , "/tmp/id_rsa" ,
241+ ),
242+ },
243+ expectOpts : eboptions.Options {
244+ CacheRepo : "localhost:5000/cache" ,
245+ GitURL :
"[email protected] /devcontainer.git" ,
246+ RemoteRepoBuildMode : true ,
247+ GitSSHPrivateKeyPath : "/tmp/id_rsa" ,
248+ GitSSHPrivateKeyBase64 : "cHJpdmF0ZUtleQo=" ,
249+ },
250+ expectNumErrorDiags : 1 ,
251+ },
252+ {
253+ name : "required only with base64 ssh key" ,
254+ data : CachedImageResourceModel {
255+ BuilderImage : basetypes .NewStringValue ("envbuilder:latest" ),
256+ CacheRepo : basetypes .NewStringValue ("localhost:5000/cache" ),
257+ GitURL :
basetypes .
NewStringValue (
"[email protected] /devcontainer.git" ),
258+ GitSSHPrivateKeyBase64 : basetypes .NewStringValue ("cHJpdmF0ZUtleQo=" ),
259+ },
260+ expectOpts : eboptions.Options {
261+ CacheRepo : "localhost:5000/cache" ,
262+ GitURL :
"[email protected] /devcontainer.git" ,
263+ RemoteRepoBuildMode : true ,
264+ GitSSHPrivateKeyBase64 : "cHJpdmF0ZUtleQo=" ,
265+ },
266+ },
214267 } {
215268 t .Run (tc .name , func (t * testing.T ) {
216269 t .Parallel ()
0 commit comments