@@ -241,11 +241,20 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
241241 return args , nil
242242 }
243243
244- sshExtract := func (key string ) []sshprovider.AgentConfig {
244+ sshExtract := func (key string ) ( []sshprovider.AgentConfig , error ) {
245245 values , ok := contextMap [key ]
246246 if ! ok {
247- return nil
247+ return nil , nil
248248 }
249+ if len (values ) != 1 {
250+ return nil , ErrInvalidSSH
251+ }
252+
253+ value := strings .TrimSpace (values [0 ])
254+ if value != "default" {
255+ return nil , ErrInvalidSSH
256+ }
257+
249258 agentConfigs := make ([]sshprovider.AgentConfig , 0 , len (values ))
250259 for _ , value := range values {
251260 id , path , hasPath := strings .Cut (value , "=" )
@@ -267,7 +276,7 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
267276 }
268277 agentConfigs = append (agentConfigs , config )
269278 }
270- return agentConfigs
279+ return agentConfigs , nil
271280 }
272281
273282 labels := mapExtract (KeyLabels )
@@ -276,7 +285,10 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
276285 if err != nil {
277286 return nil , err
278287 }
279- ssh := sshExtract (KeySSH )
288+ ssh , err := sshExtract (KeySSH )
289+ if err != nil {
290+ return nil , err
291+ }
280292 cacheIn := contextMap [KeyCacheIn ]
281293 cacheOut := contextMap [KeyCacheOut ]
282294 outputs := contextMap [KeyOutput ]
0 commit comments