Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pkg/build/buildopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,20 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
return args, nil
}

sshExtract := func(key string) []sshprovider.AgentConfig {
sshExtract := func(key string) ([]sshprovider.AgentConfig, error) {
values, ok := contextMap[key]
if !ok {
return nil
return nil, nil
}
if len(values) != 1 {
Comment thread
saehejkang marked this conversation as resolved.
return nil, ErrInvalidSSH
}

value := strings.TrimSpace(values[0])
if value != "default" {
return nil, ErrInvalidSSH
}

agentConfigs := make([]sshprovider.AgentConfig, 0, len(values))
for _, value := range values {
id, path, hasPath := strings.Cut(value, "=")
Expand All @@ -267,7 +276,7 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
}
agentConfigs = append(agentConfigs, config)
}
return agentConfigs
return agentConfigs, nil
}

labels := mapExtract(KeyLabels)
Expand All @@ -276,7 +285,10 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
if err != nil {
return nil, err
}
ssh := sshExtract(KeySSH)
ssh, err := sshExtract(KeySSH)
if err != nil {
return nil, err
}
cacheIn := contextMap[KeyCacheIn]
cacheOut := contextMap[KeyCacheOut]
outputs := contextMap[KeyOutput]
Expand Down
1 change: 1 addition & 0 deletions pkg/build/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ var (
ErrNoBuildDirectives = fmt.Errorf("no build directives")
ErrInvalidImageContextFormat = fmt.Errorf("image resolver: image name format is invalid")
ErrInvalidProgress = fmt.Errorf("build arg progress value is invalid")
ErrInvalidSSH = fmt.Errorf("build arg ssh value is invalid")
Comment thread
saehejkang marked this conversation as resolved.
Outdated
)