engine: secretsCommand via HostExecutor (closes #23) by bilby91 · Pull Request #35 · crunchloop/devcontainer · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions config/raw.go
7 changes: 7 additions & 0 deletions config/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ func resolveFromRaw(raw *rawConfig, input ResolveInput) (*ResolvedConfig, error)
out.Lifecycle = lifecycle
out.Warnings = append(out.Warnings, addSource(lcWarns, input.ConfigPath)...)

secretsCmd, err := decodeLifecycleCommand(raw.SecretsCommand)
if err != nil {
return nil, &ConfigInvalidError{Path: input.ConfigPath, Message: fmt.Sprintf("/secretsCommand: %v", err)}
}
out.SecretsCommand = secretsCmd

// WaitFor passes through verbatim; the spec default (postCreate, or
// updateContent if any layer contributes one) is applied by Finalize
// after the metadata-merge pipeline.
Expand Down Expand Up @@ -490,6 +496,7 @@ func substituteAll(out *ResolvedConfig, ctx SubstitutionContext, source string)
}

substituteLifecycle(&out.Lifecycle, subStr)
substituteCommand(&out.SecretsCommand, "/secretsCommand", subStr)

switch s := out.Source.(type) {
case *ImageSource:
Expand Down
9 changes: 9 additions & 0 deletions config/resolved.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ type ResolvedConfig struct {
Lifecycle LifecycleCommands
WaitFor LifecyclePhase

// SecretsCommand is a host-side hook that runs before container start
// (analogous to initializeCommand) and whose stdout is parsed as
// key=value lines and merged into the container's environment. Unlike
// the lifecycle phases, it is not contributed by feature/base-image
// metadata layers — only the user's devcontainer.json sources it —
// so it is a single LifecycleCommand rather than a slice. Empty
// when devcontainer.json has no `secretsCommand`.
SecretsCommand LifecycleCommand

ForwardPorts []PortSpec
PortsAttributes map[string]PortAttributes
OtherPortsAttributes *PortAttributes
Expand Down
166 changes: 166 additions & 0 deletions secrets.go
Loading
Loading