Skip to content

Commit

Permalink
[mq] working branch - merge 78bb5f6 on top of main at 1c333ed
Browse files Browse the repository at this point in the history
{"baseBranch":"main","baseCommit":"1c333ed90674178de0564a34a599b26357ad1b5d","createdAt":"2024-12-13T10:05:38.421491Z","headSha":"78bb5f6da965d26132c2e0d403e8b4c453b73eef","id":"ebe844af-a817-4774-af95-f532e81ec21b","priority":"200","pullRequestNumber":"1294","queuedAt":"2024-12-13T10:05:38.421014Z","status":"STATUS_QUEUED"}
  • Loading branch information
dd-mergequeue[bot] authored Dec 13, 2024
2 parents 87844ca + 78bb5f6 commit a8dcb2b
Showing 1 changed file with 13 additions and 4 deletions.
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

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

0 comments on commit a8dcb2b

Please sign in to comment.