Fix a panic that could occur when context was omitted (#83)

I could have sworn the context property was required, but evidently it
isn't and we weren't handling the case when it was missing.

This PR updates things to set a default location of the current
directory if the context is absent. Some unit tests are also added.

Fixes #78.
This commit is contained in:
Bryce Lampe
2024-05-31 07:41:22 -07:00
committed by GitHub
parent 44e082a0a0
commit 4e8cf8f4ba
27 changed files with 137 additions and 66 deletions

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -239,10 +239,6 @@ COPY hello.c ./
RUN echo ""This uses an inline Dockerfile! 👍""
",
},
Context = new DockerBuild.Inputs.BuildContextArgs
{
Location = "./app",
},
});
var dockerLoad = new DockerBuild.Image("dockerLoad", new()

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -207,9 +207,6 @@ func main() {
Dockerfile: &dockerbuild.DockerfileArgs{
Inline: pulumi.String("FROM alpine\nRUN echo \"This uses an inline Dockerfile! 👍\"\n"),
},
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String("./app"),
},
})
if err != nil {
return err

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -185,9 +185,6 @@ FROM alpine
RUN echo "This uses an inline Dockerfile! 👍"
""")
.build())
.context(BuildContextArgs.builder()
.location("./app")
.build())
.build());
var dockerLoad = new Image("dockerLoad", ImageArgs.builder()

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -154,9 +154,6 @@ const inline = new docker_build.Image("inline", {
RUN echo "This uses an inline Dockerfile! 👍"
`,
},
context: {
location: "./app",
},
});
const dockerLoad = new docker_build.Image("dockerLoad", {
push: false,

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -141,9 +141,6 @@ inline = docker_build.Image("inline",
inline="""FROM alpine
RUN echo "This uses an inline Dockerfile! 👍"
""",
),
context=docker_build.BuildContextArgs(
location="./app",
))
docker_load = docker_build.Image("dockerLoad",
push=False,

View File

@@ -0,0 +1,2 @@
command-output
tmp

View File

@@ -166,8 +166,6 @@ resources:
inline: |
FROM alpine
RUN echo "This uses an inline Dockerfile! 👍"
context:
location: "./app"
# docker buildx build --load .
dockerLoad: