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

Remove OneOf implementation for Build type #518

Merged
merged 3 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 1 addition & 8 deletions provider/cmd/pulumi-resource-docker/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4436,14 +4436,7 @@
"type": "object",
"inputProperties": {
"build": {
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/types/docker:index/dockerBuild:DockerBuild"
}
],
"$ref": "#/types/docker:index/dockerBuild:DockerBuild",
"description": "The Docker build context"
},
"imageName": {
Expand Down
7 changes: 0 additions & 7 deletions provider/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,6 @@ func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) {
build.Context = "."
return build, nil
}
if b.IsString() {
// use the filepath as context
build.Context = b.StringValue()
build.Dockerfile = defaultDockerfile
return build, nil
}

// read in the build type fields
buildObject := b.ObjectValue()
// Dockerfile
Expand Down
11 changes: 0 additions & 11 deletions provider/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ func TestMarshalBuildAndApplyDefaults(t *testing.T) {
assert.NoError(t, err)
})

t.Run("String input Build", func(t *testing.T) {
expected := Build{
Context: "/twilight/sparkle/bin",
Dockerfile: "Dockerfile",
}
input := resource.NewStringProperty("/twilight/sparkle/bin")
actual, err := marshalBuildAndApplyDefaults(input)
assert.Equal(t, expected, actual)
assert.NoError(t, err)
})

t.Run("Custom Dockerfile with default context", func(t *testing.T) {
expected := Build{
Context: ".",
Expand Down
9 changes: 1 addition & 8 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,7 @@ func Provider() tfbridge.ProviderInfo {
"build": {
Description: "The Docker build context",
TypeSpec: schema.TypeSpec{
OneOf: []schema.TypeSpec{
{
Type: "string",
},
{
Ref: "#/types/docker:index/dockerBuild:DockerBuild",
},
},
Ref: "#/types/docker:index/dockerBuild:DockerBuild",
},
},
"skipPush": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public sealed class ImageArgs : global::Pulumi.ResourceArgs
/// The Docker build context
/// </summary>
[Input("build")]
public InputUnion<string, Inputs.DockerBuildArgs>? Build { get; set; }
public Input<Inputs.DockerBuildArgs>? Build { get; set; }

/// <summary>
/// The image name
Expand Down
7 changes: 5 additions & 2 deletions sdk/go/docker/image.go

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

147 changes: 147 additions & 0 deletions sdk/go/docker/pulumiTypes.go

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

29 changes: 4 additions & 25 deletions sdk/java/src/main/java/com/pulumi/docker/ImageArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.pulumi.docker;

import com.pulumi.core.Either;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Import;
import com.pulumi.core.internal.Codegen;
Expand All @@ -25,13 +24,13 @@ public final class ImageArgs extends com.pulumi.resources.ResourceArgs {
*
*/
@Import(name="build")
private @Nullable Output<Either<String,DockerBuildArgs>> build;
private @Nullable Output<DockerBuildArgs> build;

/**
* @return The Docker build context
*
*/
public Optional<Output<Either<String,DockerBuildArgs>>> build() {
public Optional<Output<DockerBuildArgs>> build() {
return Optional.ofNullable(this.build);
}

Expand Down Expand Up @@ -113,39 +112,19 @@ public Builder(ImageArgs defaults) {
* @return builder
*
*/
public Builder build(@Nullable Output<Either<String,DockerBuildArgs>> build) {
public Builder build(@Nullable Output<DockerBuildArgs> build) {
$.build = build;
return this;
}

/**
* @param build The Docker build context
*
* @return builder
*
*/
public Builder build(Either<String,DockerBuildArgs> build) {
return build(Output.of(build));
}

/**
* @param build The Docker build context
*
* @return builder
*
*/
public Builder build(String build) {
return build(Either.ofLeft(build));
}

/**
* @param build The Docker build context
*
* @return builder
*
*/
public Builder build(DockerBuildArgs build) {
return build(Either.ofRight(build));
return build(Output.of(build));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Image extends pulumi.CustomResource {
if ((!args || args.imageName === undefined) && !opts.urn) {
throw new Error("Missing required property 'imageName'");
}
resourceInputs["build"] = args ? args.build : undefined;
resourceInputs["build"] = args ? (args.build ? pulumi.output(args.build).apply(inputs.dockerBuildProvideDefaults) : undefined) : undefined;
resourceInputs["imageName"] = args ? args.imageName : undefined;
resourceInputs["registry"] = args ? args.registry : undefined;
resourceInputs["skipPush"] = (args ? args.skipPush : undefined) ?? false;
Expand All @@ -109,7 +109,7 @@ export interface ImageArgs {
/**
* The Docker build context
*/
build?: pulumi.Input<string | inputs.DockerBuild>;
build?: pulumi.Input<inputs.DockerBuild>;
/**
* The image name
*/
Expand Down
Loading