Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix podman/docker config calling ddtool #1294

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
17 changes: 13 additions & 4 deletions resources/local/podman/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type VMArgs struct {

//go:embed data/Dockerfile
var dockerfileContent string
var customDockerConfig = "{}"

func NewInstance(e resourceslocal.Environment, args VMArgs, opts ...pulumi.ResourceOption) (address pulumi.StringOutput, user string, port int, err error) {
interpreter := []string{"/bin/bash", "-c"}
Expand Down Expand Up @@ -49,14 +50,22 @@ func NewInstance(e resourceslocal.Environment, args VMArgs, opts ...pulumi.Resou
return pulumi.StringOutput{}, "", -1, err
}

// Use a config to avoid docker hooks that can call vault or other services (credHelpers)
err = os.WriteFile(path.Join(dataPath, "config.json"), []byte(customDockerConfig), 0600)
if err != nil {
return pulumi.StringOutput{}, "", -1, err
}

podmanCommand := "podman --config " + dataPath
CelianR marked this conversation as resolved.
Show resolved Hide resolved

opts = utils.MergeOptions(opts, e.WithProviders(config.ProviderCommand))
// TODO use NewLocalRunner
// requires a refactor to pass interpreter
buildPodman, err := local.NewCommand(e.Ctx(), e.CommonNamer().ResourceName("podman-build", args.Name), &local.CommandArgs{
Interpreter: pulumi.ToStringArray(interpreter),
Environment: pulumi.StringMap{"DOCKER_HOST_SSH_PUBLIC_KEY": pulumi.String(string(publicKey))},
Create: pulumi.Sprintf("podman build --format=docker --build-arg DOCKER_HOST_SSH_PUBLIC_KEY=\"$DOCKER_HOST_SSH_PUBLIC_KEY\" -t %s .", args.Name),
Delete: pulumi.Sprintf("podman rmi %s", args.Name),
Create: pulumi.Sprintf("%s build --format=docker --build-arg DOCKER_HOST_SSH_PUBLIC_KEY=\"$DOCKER_HOST_SSH_PUBLIC_KEY\" -t %s .", podmanCommand, args.Name),
Delete: pulumi.Sprintf("%s rmi %s", podmanCommand, args.Name),
Triggers: pulumi.Array{},
AssetPaths: pulumi.StringArray{},
Dir: pulumi.String(dataPath),
Expand All @@ -68,8 +77,8 @@ func NewInstance(e resourceslocal.Environment, args VMArgs, opts ...pulumi.Resou
runPodman, err := local.NewCommand(e.Ctx(), e.CommonNamer().ResourceName("podman-run", args.Name), &local.CommandArgs{
Interpreter: pulumi.ToStringArray(interpreter),
Environment: pulumi.StringMap{"DOCKER_HOST_SSH_PUBLIC_KEY": pulumi.String(string(publicKey))},
Create: pulumi.Sprintf("podman run -d --name=%[1]s_run -p 50022:22 %[1]s", args.Name),
Delete: pulumi.Sprintf("podman stop %[1]s_run && podman rm %[1]s_run", args.Name),
Create: pulumi.Sprintf("%s run -d --name=%[2]s_run -p 50022:22 %[2]s", podmanCommand, args.Name),
Delete: pulumi.Sprintf("%s stop %[2]s_run && podman rm %[2]s_run", podmanCommand, args.Name),
Triggers: pulumi.Array{},
AssetPaths: pulumi.StringArray{},
Dir: pulumi.String(dataPath),
Expand Down
Loading