Trying to upload docker image to a repo... ```// ...
# typescript
a
Trying to upload docker image to a repo...
Copy code
// import { Repository, RepositoryImage } from "@pulumi/awsx/ecr";

export function createImage() : RepositoryImage {
  const repository = new Repository("myrepo");
  const repImage = repository.buildAndPushImage("./Application");

  return repImage
}
and I get this error on the return line
error TS2739: Type 'OutputInstance<string> & LiftedObject<String, number | "length">' is missing the following properties from type 'RepositoryImage': repository, imageValue, image, environment
. If I change
createImage() : RepositoryImage
to any I get a string error...whats going on here?
b
Hi Patrick, hereโ€™s a complete example that should help you get up and running. Let us know if you continue to have any issues. https://www.pulumi.com/docs/guides/crosswalk/kubernetes/apps/#build-and-deploy-a-container
a
That example doesn't have the types for buildAndPush, and assumes whatever is consuming the image will magically know what to do with it. My use case involves
aws.ecs.TaskDefinition
which expects you to put a fully formed json blob in it (https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/ecs/taskDefinition.ts#L288) so understanding wtf is coming back from buildAndPushImage is required to construct that blob (i think).
b
cc @white-balloon-205 @lemon-spoon-91807
l
not in front of a computer
but buildAndPushImage shuld return an Output<string>
so this line is effectively:
Copy code
const repImage: Output<string> = repository.buildAndPushImage("./Application");
so TS is complaining that you're assigning an Output<string> to a
RepositoryImage
from cursory glance, feels like your code should be:
Copy code
export function createImage() : Output<string> {
(working from phone fyi. can't validate fully here)
a
hrmm... so like, I will go down that path, but I read
Copy code
export function buildAndPushImage(
    name: string, pathOrBuild: pulumi.Input<string | docker.DockerBuild>, args?: RepositoryArgs, opts?: pulumi.ComponentResourceOptions) {

    const repo = new Repository(name, args, opts);
    const image = repo.buildAndPushImage(pathOrBuild);
    return new RepositoryImage(repo, image);
}
and assumed RepositoryImage was coming back.
l
that's not the buildAndPushImage you're callin though ๐Ÿ™‚
you have... one sec... copy/paste on phoen is awful
Copy code
repository.buildAndPushImage
not: awsx.ecr.buildAndPushImage. One is an instance method on the Repository class. The other is a helper function at the module level.
the module helper basically does all the steps. makes the repo, builds hte image, and returns the RepoImage containing both.
a
oh son of a bitch...
l
๐Ÿ˜•
๐Ÿ˜ž
a
no, that's my fault, i was just reading the whole thing wrong.
l
easy mistake to make. we did name the exact same thnig...
a
Any cursing is at myself.