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

Invalid Password definition for docker.NewImage #954

Open
cgradwohl opened this issue Jan 19, 2024 · 1 comment
Open

Invalid Password definition for docker.NewImage #954

cgradwohl opened this issue Jan 19, 2024 · 1 comment
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec

Comments

@cgradwohl
Copy link

File: themes/default/content/registry/packages/docker/api-docs/image/_index.md

Currently the example for Docker image build using caching with AWS Elastic Container Registry is as follows:

package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecr"
	"github.com/pulumi/pulumi-docker/sdk/v4/go/docker"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		ecrRepository, err := ecr.NewRepository(ctx, "ecr-repository", &ecr.RepositoryArgs{
			Name: pulumi.String("docker-repository"),
		})
		if err != nil {
			return err
		}
		authToken := ecr.GetAuthorizationTokenOutput(ctx, ecr.GetAuthorizationTokenOutputArgs{
			RegistryId: ecrRepository.RegistryId,
		}, nil)
		myAppImage, err := docker.NewImage(ctx, "my-app-image", &docker.ImageArgs{
			Build: &docker.DockerBuildArgs{
				Args: pulumi.StringMap{
					"BUILDKIT_INLINE_CACHE": pulumi.String("1"),
				},
				CacheFrom: &docker.CacheFromArgs{
					Images: pulumi.StringArray{
						ecrRepository.RepositoryUrl.ApplyT(func(repositoryUrl string) (string, error) {
							return fmt.Sprintf("%v:latest", repositoryUrl), nil
						}).(pulumi.StringOutput),
					},
				},
				Context:    pulumi.String("app/"),
				Dockerfile: pulumi.String("Dockerfile"),
			},
			ImageName: ecrRepository.RepositoryUrl.ApplyT(func(repositoryUrl string) (string, error) {
				return fmt.Sprintf("%v:latest", repositoryUrl), nil
			}).(pulumi.StringOutput),
			Registry: &docker.RegistryArgs{
				Password: pulumi.ToSecret(authToken.ApplyT(func(authToken ecr.GetAuthorizationTokenResult) (*string, error) {
					return &authToken.Password, nil
				}).(pulumi.StringPtrOutput)).(*pulumi.StringOutput),
				Server: ecrRepository.RepositoryUrl,
			},
		})
		if err != nil {
			return err
		}
		ctx.Export("imageName", myAppImage.ImageName)
		return nil
	})
}

But the Password field of the docker.RegistryArgs is incorrect. It should be this instead:

Password: authToken.ApplyT(func(authToken ecr.GetAuthorizationTokenResult) (*string, error) {
	return &authToken.Password, nil
}).(pulumi.StringPtrOutput).ToStringPtrOutput(),
@github-actions github-actions bot added the needs-triage Needs attention from the triage team label Jan 19, 2024
@cnunciato
Copy link

Thanks for submitting this @cgradwohl! We'll get this looked at.

@cnunciato cnunciato added kind/bug Some behavior is incorrect or out of spec area/docs Improvements or additions to documentation and removed needs-triage Needs attention from the triage team labels Jan 20, 2024
@cnunciato cnunciato transferred this issue from pulumi/pulumi-hugo Jan 20, 2024
@cnunciato cnunciato moved this from 🤔 Triage to 🧳 Backlog in Docs 📚 Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation kind/bug Some behavior is incorrect or out of spec
Projects
Status: 🧳 Backlog
Development

No branches or pull requests

2 participants