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

Deprecate extraOptions and env #468

Merged
merged 7 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions provider/cmd/pulumi-resource-docker/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3074,20 +3074,6 @@
"description": "The path to the Dockerfile to use.",
"default": "Dockerfile"
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build."
},
"extraOptions": {
"type": "array",
"items": {
"type": "string"
},
"description": "A bag of extra options to pass on to the docker SDK."
},
"target": {
"type": "string",
"description": "The target of the Dockerfile to build"
Expand Down
27 changes: 0 additions & 27 deletions provider/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ type Build struct {
Context string
Dockerfile string
CachedImages []string
Env map[string]string
Args map[string]*string
ExtraOptions []string
Target string
BuilderVersion types.BuilderVersion
}
Expand Down Expand Up @@ -301,20 +299,9 @@ func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) {
}
build.BuilderVersion = version

// Envs
build.Env = marshalEnvs(buildObject["env"])

// Args
build.Args = marshalArgs(buildObject["args"])

// ExtraOptions
if !buildObject["extraOptions"].IsNull() {
opts := buildObject["extraOptions"].ArrayValue()
for _, v := range opts {
build.ExtraOptions = append(build.ExtraOptions, v.StringValue())
}
}

// Target
if !buildObject["target"].IsNull() {
build.Target = buildObject["target"].StringValue()
Expand Down Expand Up @@ -375,20 +362,6 @@ func marshalArgs(a resource.PropertyValue) map[string]*string {
return args
}

func marshalEnvs(e resource.PropertyValue) map[string]string {
envs := make(map[string]string)
if !e.IsNull() {
for k, v := range e.ObjectValue() {
key := fmt.Sprintf("%v", k)
envs[key] = v.StringValue()
}
}
if len(envs) == 0 {
return nil
}
return envs
}

func marshalBuilder(builder resource.PropertyValue) (types.BuilderVersion, error) {
var version types.BuilderVersion

Expand Down
81 changes: 0 additions & 81 deletions provider/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,64 +125,6 @@ func TestMarshalBuildAndApplyDefaults(t *testing.T) {
assert.NoError(t, err)
})

t.Run("Setting Env", func(t *testing.T) {

expected := Build{
Context: ".",
Dockerfile: "Dockerfile",
Env: map[string]string{
"Strawberry": "fruit",
},
BuilderVersion: "2",
}

input := resource.NewObjectProperty(resource.PropertyMap{
"env": resource.NewObjectProperty(resource.PropertyMap{
"Strawberry": resource.NewStringProperty("fruit"),
}),
})

actual, err := marshalBuildAndApplyDefaults(input)
assert.Equal(t, expected, actual)
assert.NoError(t, err)
})

t.Run("Sets Extra Options", func(t *testing.T) {
expected := Build{
Context: ".",
Dockerfile: "Dockerfile",
ExtraOptions: []string{"cat", "dog", "pot-bellied pig"},
BuilderVersion: "2",
}

input := resource.NewObjectProperty(resource.PropertyMap{
"extraOptions": resource.NewArrayProperty([]resource.PropertyValue{
resource.NewStringProperty("cat"),
resource.NewStringProperty("dog"),
resource.NewStringProperty("pot-bellied pig"),
}),
})

actual, err := marshalBuildAndApplyDefaults(input)
assert.Equal(t, expected, actual)
assert.NoError(t, err)
})

t.Run("Does Not Set Extra Options on Empty Input", func(t *testing.T) {
expected := Build{
Context: ".",
Dockerfile: "Dockerfile",
BuilderVersion: "2",
}

input := resource.NewObjectProperty(resource.PropertyMap{
"extraOptions": resource.NewArrayProperty([]resource.PropertyValue{}),
})

actual, err := marshalBuildAndApplyDefaults(input)
assert.Equal(t, expected, actual)
assert.NoError(t, err)
})
t.Run("Sets Target", func(t *testing.T) {
expected := Build{
Context: ".",
Expand Down Expand Up @@ -256,29 +198,6 @@ func TestMarshalArgs(t *testing.T) {
})
}

func TestMarshalEnvs(t *testing.T) {
t.Run("Set any environment variables", func(t *testing.T) {
expected := map[string]string{
"Strawberry": "fruit",
"Carrot": "veggie",
"Docker": "a bit of a mess tbh",
}
input := resource.NewObjectProperty(resource.PropertyMap{
"Strawberry": resource.NewStringProperty("fruit"),
"Carrot": resource.NewStringProperty("veggie"),
"Docker": resource.NewStringProperty("a bit of a mess tbh"),
})
actual := marshalEnvs(input)
assert.Equal(t, expected, actual)
})
t.Run("Returns nil when no environment variables set", func(t *testing.T) {
expected := map[string]string(nil)
input := resource.NewObjectProperty(resource.PropertyMap{})
actual := marshalEnvs(input)
assert.Equal(t, expected, actual)
})
}

func TestMarshalCachedImages(t *testing.T) {
t.Run("Test Cached Images", func(t *testing.T) {
expected := []string{"apple", "banana", "cherry"}
Expand Down
19 changes: 0 additions & 19 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ func Provider() tfbridge.ProviderInfo {
Ref: "#/types/docker:index/cacheFrom:CacheFrom",
},
},
"env": {
Description: "Environment variables to set on the invocation of docker build, " +
"for example to support DOCKER_BUILDKIT=1 docker build.",
TypeSpec: schema.TypeSpec{
Type: "object",
AdditionalProperties: &schema.TypeSpec{
Type: "string",
},
},
},
"args": {
Description: "An optional map of named build-time argument variables to set " +
"during the Docker build. This flag allows you to pass built-time variables" +
Expand All @@ -178,15 +168,6 @@ func Provider() tfbridge.ProviderInfo {
},
},
},
"extraOptions": {
Description: "A bag of extra options to pass on to the docker SDK.",
TypeSpec: schema.TypeSpec{
Type: "array",
Items: &schema.TypeSpec{
Type: "string",
},
},
},
"target": {
Description: "The target of the Dockerfile to build",
TypeSpec: schema.TypeSpec{Type: "string"},
Expand Down
24 changes: 0 additions & 24 deletions sdk/dotnet/Inputs/DockerBuildArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,6 @@ public InputMap<string> Args
[Input("dockerfile")]
public Input<string>? Dockerfile { get; set; }

[Input("env")]
private InputMap<string>? _env;

/// <summary>
/// Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
/// </summary>
public InputMap<string> Env
{
get => _env ?? (_env = new InputMap<string>());
set => _env = value;
}

[Input("extraOptions")]
private InputList<string>? _extraOptions;

/// <summary>
/// A bag of extra options to pass on to the docker SDK.
/// </summary>
public InputList<string> ExtraOptions
{
get => _extraOptions ?? (_extraOptions = new InputList<string>());
set => _extraOptions = value;
}

/// <summary>
/// The target of the Dockerfile to build
/// </summary>
Expand Down
18 changes: 0 additions & 18 deletions sdk/go/docker/pulumiTypes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.pulumi.docker.enums.BuilderVersion;
import com.pulumi.docker.inputs.CacheFromArgs;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -99,36 +98,6 @@ public Optional<Output<String>> dockerfile() {
return Optional.ofNullable(this.dockerfile);
}

/**
* Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
*
*/
@Import(name="env")
private @Nullable Output<Map<String,String>> env;

/**
* @return Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
*
*/
public Optional<Output<Map<String,String>>> env() {
return Optional.ofNullable(this.env);
}

/**
* A bag of extra options to pass on to the docker SDK.
*
*/
@Import(name="extraOptions")
private @Nullable Output<List<String>> extraOptions;

/**
* @return A bag of extra options to pass on to the docker SDK.
*
*/
public Optional<Output<List<String>>> extraOptions() {
return Optional.ofNullable(this.extraOptions);
}

/**
* The target of the Dockerfile to build
*
Expand All @@ -152,8 +121,6 @@ private DockerBuildArgs(DockerBuildArgs $) {
this.cacheFrom = $.cacheFrom;
this.context = $.context;
this.dockerfile = $.dockerfile;
this.env = $.env;
this.extraOptions = $.extraOptions;
this.target = $.target;
}

Expand Down Expand Up @@ -280,58 +247,6 @@ public Builder dockerfile(String dockerfile) {
return dockerfile(Output.of(dockerfile));
}

/**
* @param env Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
*
* @return builder
*
*/
public Builder env(@Nullable Output<Map<String,String>> env) {
$.env = env;
return this;
}

/**
* @param env Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
*
* @return builder
*
*/
public Builder env(Map<String,String> env) {
return env(Output.of(env));
}

/**
* @param extraOptions A bag of extra options to pass on to the docker SDK.
*
* @return builder
*
*/
public Builder extraOptions(@Nullable Output<List<String>> extraOptions) {
$.extraOptions = extraOptions;
return this;
}

/**
* @param extraOptions A bag of extra options to pass on to the docker SDK.
*
* @return builder
*
*/
public Builder extraOptions(List<String> extraOptions) {
return extraOptions(Output.of(extraOptions));
}

/**
* @param extraOptions A bag of extra options to pass on to the docker SDK.
*
* @return builder
*
*/
public Builder extraOptions(String... extraOptions) {
return extraOptions(List.of(extraOptions));
}

/**
* @param target The target of the Dockerfile to build
*
Expand Down
8 changes: 0 additions & 8 deletions sdk/nodejs/types/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,6 @@ export interface DockerBuild {
* The path to the Dockerfile to use.
*/
dockerfile?: pulumi.Input<string>;
/**
* Environment variables to set on the invocation of docker build, for example to support DOCKER_BUILDKIT=1 docker build.
*/
env?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
/**
* A bag of extra options to pass on to the docker SDK.
*/
extraOptions?: pulumi.Input<pulumi.Input<string>[]>;
/**
* The target of the Dockerfile to build
*/
Expand Down
Loading