-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker:Image - Add flag to enable build on preview (#855)
This pull request's intent is to allow a user to build their image during `pulumi preview` by using the new `buildOnPreview` resource field. This field is added to the Image schema as a boolean and defaults to false. The implementation specifics are as follows, with some things for the reviewer to weigh in on. 1. As a prerequisite, `supportPreview` is enabled and all implemented RPD methods should handle Unknowns. This should also help address #847 and #620. 2. `ContainsUnknowns()` checks are added to the marshaler and some of the `Check()` logic. I wasn't sure if `ContainsUnknowns()` or `IsComputed()`should be used here; the former contains a check for the latter. 3. Unit tests verify the new marshaling behavior. 4. When a Dockerfile is Unknown, we do not verify its location during Preview `Check()`, instead we apply other defaults and carry on. We will calculate the build hash on the `update` call once Unknowns are computed. 5. When in preview mode, and buildOnPreview is false, we return all inputs as-is in Update() and Create(). 6. When an attempt is made to build on preview, but there are Unknowns in the inputs or news, we send an error instructing the user to set `buildOnPreview` to false. 7. An integration test is added that verifies an image builds on preview if the `buildOnPreview` flag is set to true. 8. An integration test is added that verifies an image _fails_ to build on preview if there are Unknown inputs and the `buildOnPreview` flag is set to true Fixes #540. - Handle unknowns in Build object - Handle unknowns in Check; skip dockerfile location finding. - Set SupportPreview to true - Add ContainsUnknowns() checks for build: target, stages, platform, Dockerfile, Context; and registry: username, password, server - Add tests for Unknowns, and tweak Unknown checks as a result of a bit of TDD - Add logic to imageBuild that allows for buildOnPreview - Use Command.stdout to test unknowns - Add a few more Unknown checks in Check() - Add an integration test for Build On Preview - Build SDKs --------- Co-authored-by: Bryce Lampe <[email protected]>
- Loading branch information
1 parent
78c6fd5
commit 11599a3
Showing
23 changed files
with
630 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM python:3.6 AS base | ||
|
||
FROM base AS dependencies | ||
RUN pip install gunicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: dockerfile-build-on-preview | ||
runtime: yaml | ||
resources: | ||
previewImage: | ||
type: docker:Image | ||
properties: | ||
imageName: docker.io/pulumibot/build-on-preview:yaml | ||
skipPush: true | ||
buildOnPreview: true | ||
outputs: | ||
repoDigest: ${previewImage.repoDigest} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as docker from "@pulumi/docker"; | ||
import * as random from "@pulumi/random"; | ||
import * as command from "@pulumi/command"; | ||
|
||
|
||
|
||
const randName = new random.RandomString("random", { | ||
length: 10, | ||
|
||
const randArg = new command.local.Command ("arg", { | ||
create: "echo setMyArg" | ||
}); | ||
|
||
const img = new docker.Image("docker-565-one", { | ||
imageName: "pulumibot/test-image:with-build-args", | ||
|
||
build: { | ||
args: { | ||
"RANDOM_ARG": randName.id | ||
"RANDOM_ARG": randArg.stdout | ||
}, | ||
}, | ||
skipPush: true, | ||
}); | ||
|
||
export const randnameid = randName.id | ||
export const randArgument = randArg.stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM ubuntu | ||
RUN echo "hello ubuntu" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: unknowns-build-on-preview-fail-yaml | ||
runtime: yaml | ||
resources: | ||
extraArg: | ||
type: command:local:Command | ||
properties: | ||
create: echo extra-argument | ||
demo-image: | ||
type: docker:Image | ||
properties: | ||
imageName: docker.io/pulumibot/test-unknowns-build-on-preview-fail:yaml | ||
skipPush: true | ||
build: | ||
args: | ||
RANDOM_ARG: ${extraArg.stdout} | ||
buildOnPreview: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
FROM ubuntu AS base | ||
RUN echo "base" | ||
FROM ubuntu | ||
RUN echo "hello ubuntu" | ||
|
||
FROM base AS stage1 | ||
RUN echo "stage1" | ||
|
||
FROM base AS stage2 | ||
RUN echo "stage2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
name: dockerfile-default-context | ||
name: dockerfile-with-unknowns-yaml | ||
runtime: yaml | ||
resources: | ||
randName: | ||
type: random:RandomString | ||
extraArg: | ||
type: command:local:Command | ||
properties: | ||
length: 8 | ||
create: echo extra-argument | ||
demo-image: | ||
type: docker:Image | ||
properties: | ||
imageName: pulumibot/test-unknowns:yaml | ||
imageName: docker.io/pulumibot/test-unknowns:yaml | ||
skipPush: true | ||
build: | ||
args: | ||
RANDOM_ARG: ${randName.id} | ||
options: | ||
version: v4.1.0 | ||
RANDOM_ARG: ${extraArg.stdout} | ||
outputs: | ||
randNameId: ${randName.id} | ||
extraArgument: ${extraArg.stdout} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.