diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..ff9aa4f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +sdk/**/* linguist-generated=true diff --git a/examples/examples_yaml_test.go b/examples/examples_yaml_test.go index 31acbd87..8e2b59a5 100644 --- a/examples/examples_yaml_test.go +++ b/examples/examples_yaml_test.go @@ -74,3 +74,35 @@ func TestSecretsYAML(t *testing.T) { }, }) } + +func TestBuilderVersionsYAML(t *testing.T) { + cwd, err := os.Getwd() + if !assert.NoError(t, err) { + t.FailNow() + } + + t.Run("v1", func(t *testing.T) { + integration.ProgramTest(t, &integration.ProgramTestOptions{ + Dir: path.Join(cwd, "test-builder-version", "v1"), + Quick: true, + SkipRefresh: true, + ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) { + platform, ok := stack.Outputs["platform"] + assert.True(t, ok) + assert.NotEmpty(t, platform) + }, + }) + }) + t.Run("v2", func(t *testing.T) { + integration.ProgramTest(t, &integration.ProgramTestOptions{ + Dir: path.Join(cwd, "test-builder-version", "v2"), + Quick: true, + SkipRefresh: true, + ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) { + platform, ok := stack.Outputs["platform"] + assert.True(t, ok) + assert.NotEmpty(t, platform) + }, + }) + }) +} diff --git a/examples/test-builder-version/v1/Dockerfile b/examples/test-builder-version/v1/Dockerfile new file mode 100644 index 00000000..8d274a7f --- /dev/null +++ b/examples/test-builder-version/v1/Dockerfile @@ -0,0 +1,3 @@ +FROM bash AS base + +RUN getent hosts metadata.google.internal # Remember to --add-host! diff --git a/examples/test-builder-version/v1/Pulumi.yaml b/examples/test-builder-version/v1/Pulumi.yaml new file mode 100644 index 00000000..24222aa6 --- /dev/null +++ b/examples/test-builder-version/v1/Pulumi.yaml @@ -0,0 +1,22 @@ +name: builder-v1 +runtime: yaml +resources: + v1Image: + type: docker:Image + properties: + imageName: docker.io/pulumi/v1-builder:latest + skipPush: true + build: + builderVersion: BuilderV1 + context: . + dockerfile: Dockerfile + platform: linux/amd64 + target: base + cacheFrom: + images: + - docker.io/pulumi/pulumi-base:latest + addHosts: + - metadata.google.internal:169.254.169.254 + network: host +outputs: + platform: ${v1Image.platform} diff --git a/examples/test-builder-version/v2/Dockerfile b/examples/test-builder-version/v2/Dockerfile new file mode 100644 index 00000000..8d274a7f --- /dev/null +++ b/examples/test-builder-version/v2/Dockerfile @@ -0,0 +1,3 @@ +FROM bash AS base + +RUN getent hosts metadata.google.internal # Remember to --add-host! diff --git a/examples/test-builder-version/v2/Pulumi.yaml b/examples/test-builder-version/v2/Pulumi.yaml new file mode 100644 index 00000000..3911f920 --- /dev/null +++ b/examples/test-builder-version/v2/Pulumi.yaml @@ -0,0 +1,22 @@ +name: builder-v2 +runtime: yaml +resources: + v2Image: + type: docker:Image + properties: + imageName: docker.io/pulumi/v2-builder:latest + skipPush: true + build: + builderVersion: BuilderBuildKit + context: . + dockerfile: Dockerfile + platform: linux/amd64 + target: base + cacheFrom: + images: + - docker.io/pulumi/pulumi-base:latest + addHosts: + - metadata.google.internal:169.254.169.254 + network: host +outputs: + platform: ${v2Image.platform} diff --git a/provider/cmd/pulumi-resource-docker/schema.json b/provider/cmd/pulumi-resource-docker/schema.json index dcd3c88c..16b1ef6c 100644 --- a/provider/cmd/pulumi-resource-docker/schema.json +++ b/provider/cmd/pulumi-resource-docker/schema.json @@ -1882,6 +1882,13 @@ "docker:index/dockerBuild:DockerBuild": { "description": "The Docker build context", "properties": { + "addHosts": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Custom host-to-IP mappings to use while building (format: \"host:ip\")" + }, "args": { "type": "object", "additionalProperties": { @@ -1905,6 +1912,10 @@ "type": "string", "description": "The path to the Dockerfile to use." }, + "network": { + "type": "string", + "description": "Set the networking mode for RUN instructions" + }, "platform": { "type": "string", "description": "The architecture of the platform you want to build this image for, e.g. `linux/arm64`." @@ -3149,6 +3160,10 @@ "type": "string", "description": "The fully qualified image name" }, + "platform": { + "type": "string", + "description": "The image's architecture and OS" + }, "registryServer": { "type": "string", "description": "The name of the registry server hosting the image." diff --git a/provider/image.go b/provider/image.go index d33889ef..67b3f483 100644 --- a/provider/image.go +++ b/provider/image.go @@ -43,8 +43,10 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" ) -const defaultDockerfile = "Dockerfile" -const defaultBuilder = "2" +const ( + defaultDockerfile = "Dockerfile" + defaultBuilder = "2" +) type Image struct { Name string @@ -67,6 +69,8 @@ type Build struct { Args map[string]*string Target string Platform string + Network string + ExtraHosts []string BuilderVersion types.BuilderVersion } @@ -81,10 +85,9 @@ type Config struct { func (p *dockerNativeProvider) dockerBuild(ctx context.Context, urn resource.URN, - props *structpb.Struct) (string, *structpb.Struct, error) { - + props *structpb.Struct, +) (string, *structpb.Struct, error) { inputs, err := plugin.UnmarshalProperties(props, plugin.MarshalOptions{KeepUnknowns: true, SkipNulls: true}) - if err != nil { return "", nil, err } @@ -101,16 +104,9 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, if err != nil { return "", nil, err } - cache, err := marshalCachedImages(inputs["build"]) - if err != nil { - return "", nil, err - } - - build.CachedImages = cache img.Build = build docker, err := configureDockerClient(p.config, true) - if err != nil { return "", nil, err } @@ -232,18 +228,20 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, // make the build options opts := types.ImageBuildOptions{ - Dockerfile: replaceDockerfile, - Tags: []string{img.Name}, // this should build the image locally, sans registry info - CacheFrom: img.Build.CachedImages, - BuildArgs: build.Args, - Version: build.BuilderVersion, - Platform: build.Platform, - Target: build.Target, + Dockerfile: replaceDockerfile, + Tags: []string{img.Name}, // this should build the image locally, sans registry info + CacheFrom: img.Build.CachedImages, + BuildArgs: build.Args, + Version: build.BuilderVersion, + Platform: build.Platform, + Target: build.Target, + ExtraHosts: build.ExtraHosts, + NetworkMode: build.Network, AuthConfigs: authConfigs, } - //Start a session for BuildKit + // Start a session for BuildKit if build.BuilderVersion == defaultBuilder { sess, err := session.NewSession(ctx, "pulumi-docker", identity.NewID()) if err != nil { @@ -305,6 +303,7 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, "baseImageName": img.Name, "registryServer": img.Registry.Server, "imageName": img.Name, + "platform": img.Build.Platform, } imageName, err := reference.ParseNormalizedNamed(img.Name) @@ -331,7 +330,6 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, _ = p.host.LogStatus(ctx, "info", urn, "Pushing Image to the registry") authConfigBytes, err := json.Marshal(regAuth) - if err != nil { return "", nil, fmt.Errorf("error parsing authConfig: %v", err) } @@ -341,7 +339,6 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, // By default, we push our image with the qualified image name from the input, without extra tagging. pushOutput, err := docker.ImagePush(ctx, img.Name, pushOpts) - if err != nil { return "", nil, err } @@ -406,7 +403,8 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context, // If the image is not found in the local store, it returns an error. func (p *dockerNativeProvider) getRepoDigest( ctx context.Context, docker *client.Client, imageID string, - img Image, urn resource.URN) (reference.Reference, error) { + img Image, urn resource.URN, +) (reference.Reference, error) { dist, _, err := docker.ImageInspectWithRaw(ctx, imageID) if err != nil { return nil, err @@ -420,7 +418,6 @@ func (p *dockerNativeProvider) getRepoDigest( var repoDigest reference.Reference for _, d := range dist.RepoDigests { ref, err := reference.ParseNormalizedNamed(d) - if err != nil { _ = p.host.Log(ctx, "warning", urn, fmt.Sprintf("Error parsing digest %q: %v", d, err)) continue @@ -456,7 +453,8 @@ func (p *dockerNativeProvider) getRepoDigest( // 4. We only return an imageID if the image in the store matches both (1.) and (2.) func (p *dockerNativeProvider) runImageBuild( ctx context.Context, docker *client.Client, tar io.Reader, - opts types.ImageBuildOptions, urn resource.URN, name string) (string, error) { + opts types.ImageBuildOptions, urn resource.URN, name string, +) (string, error) { if opts.Labels == nil { opts.Labels = make(map[string]string) } @@ -543,7 +541,8 @@ func (p *dockerNativeProvider) runImageBuild( } func pullDockerImage(ctx context.Context, p *dockerNativeProvider, urn resource.URN, - docker *client.Client, authConfig types.AuthConfig, cachedImage string, platform string) error { + docker *client.Client, authConfig types.AuthConfig, cachedImage string, platform string, +) error { if cachedImage != "" { _ = p.host.LogStatus(ctx, "info", urn, fmt.Sprintf("Pulling cached image %s", cachedImage)) @@ -572,7 +571,6 @@ func pullDockerImage(ctx context.Context, p *dockerNativeProvider, urn resource. } func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) { - // build can be nil, a string or an object; we will also use reasonable defaults here. var build Build if b.IsNull() { @@ -601,7 +599,6 @@ func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) { } // BuildKit version, err := marshalBuilder(buildObject["builderVersion"]) - if err != nil { return build, err } @@ -615,6 +612,25 @@ func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) { build.Target = buildObject["target"].StringValue() } + // CacheFrom + cache, err := marshalCachedImages(b) + if err != nil { + return build, err + } + build.CachedImages = cache + + // AddHosts + hosts, err := marshalExtraHosts(b) + if err != nil { + return build, err + } + build.ExtraHosts = hosts + + // Network + if !buildObject["network"].IsNull() { + build.Network = buildObject["network"].StringValue() + } + // Platform if !buildObject["platform"].IsNull() { build.Platform = buildObject["platform"].StringValue() @@ -622,6 +638,22 @@ func marshalBuildAndApplyDefaults(b resource.PropertyValue) (Build, error) { return build, nil } +func marshalExtraHosts(b resource.PropertyValue) ([]string, error) { + var extraHosts []string + if b.IsNull() || b.ObjectValue()["addHosts"].IsNull() { + return extraHosts, nil + } + hosts := b.ObjectValue()["addHosts"].ArrayValue() + + for _, host := range hosts { + if !host.IsString() { + continue + } + extraHosts = append(extraHosts, host.StringValue()) + } + return extraHosts, nil +} + func marshalCachedImages(b resource.PropertyValue) ([]string, error) { var cacheImages []string if b.IsNull() { @@ -694,7 +726,7 @@ func marshalBuilder(builder resource.PropertyValue) (types.BuilderVersion, error var version types.BuilderVersion if builder.IsNull() { - //set default + // set default return defaultBuilder, nil } // verify valid input @@ -858,7 +890,6 @@ func processLogLine(jm jsonmessage.JSONMessage, info += jm.Status + " " + jm.Progress.String() } else if jm.Stream != "" { info += jm.Stream - } else { info += jm.Status } @@ -888,7 +919,6 @@ func processLogLine(jm jsonmessage.JSONMessage, } for _, log := range resp.Logs { info += fmt.Sprintf("%s\n", string(log.Msg)) - } for _, warn := range resp.Warnings { info += fmt.Sprintf("%s\n", string(warn.Short)) @@ -925,7 +955,6 @@ func processLogLine(jm jsonmessage.JSONMessage, // instead of the system-wide one. // `verify` is a testing affordance and will always be true in production. func configureDockerClient(configs map[string]string, verify bool) (*client.Client, error) { - host, isExplicitHost := configs["host"] if !isExplicitHost { diff --git a/provider/provider.go b/provider/provider.go index 09126312..af66b518 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -38,7 +38,7 @@ type dockerNativeProvider struct { version string schemaBytes []byte config map[string]string - //loginLock sync.Mutex + // loginLock sync.Mutex } // docker native methods @@ -60,7 +60,8 @@ func (p *dockerNativeProvider) Call(ctx context.Context, req *rpc.CallRequest) ( // Construct creates a new component resource. func (p *dockerNativeProvider) Construct(ctx context.Context, req *rpc.ConstructRequest) ( - *rpc.ConstructResponse, error) { + *rpc.ConstructResponse, error, +) { return nil, status.Error(codes.Unimplemented, "construct is not yet implemented") } @@ -76,7 +77,6 @@ func (p *dockerNativeProvider) DiffConfig(ctx context.Context, req *rpc.DiffRequ // Configure configures the resource provider with "globals" that control its behavior. func (p *dockerNativeProvider) Configure(_ context.Context, req *rpc.ConfigureRequest) (*rpc.ConfigureResponse, error) { - config := setConfiguration(req.GetVariables()) for key, val := range config { p.config[key] = val @@ -111,7 +111,8 @@ func (p *dockerNativeProvider) Invoke(_ context.Context, req *rpc.InvokeRequest) // StreamInvoke dynamically executes a built-in function in the provider. The result is streamed // back as a series of messages. func (p *dockerNativeProvider) StreamInvoke( - req *rpc.InvokeRequest, server rpc.ResourceProvider_StreamInvokeServer) error { + req *rpc.InvokeRequest, server rpc.ResourceProvider_StreamInvokeServer, +) error { tok := req.GetTok() return fmt.Errorf("unknown StreamInvoke token '%s'", tok) } @@ -207,9 +208,6 @@ func (p *dockerNativeProvider) Check(ctx context.Context, req *rpc.CheckRequest) } } - if _, err = marshalCachedImages(inputs["build"]); err != nil { - return nil, err - } inputStruct, err := plugin.MarshalProperties(inputs, plugin.MarshalOptions{ KeepUnknowns: true, @@ -258,7 +256,6 @@ func (p *dockerNativeProvider) Diff(ctx context.Context, req *rpc.DiffRequest) ( diff := map[string]*rpc.PropertyDiff{} for key := range d.Adds { diff[string(key)] = &rpc.PropertyDiff{Kind: rpc.PropertyDiff_ADD} - } for key := range d.Deletes { diff[string(key)] = &rpc.PropertyDiff{Kind: rpc.PropertyDiff_DELETE} @@ -371,7 +368,6 @@ func (p *dockerNativeProvider) Read(ctx context.Context, req *rpc.ReadRequest) ( // Return properties as passed, since we do no reconciliation, return &rpc.ReadResponse{Id: id, Inputs: inputs, Properties: properties}, nil - } // Update updates an existing resource with new values. @@ -414,7 +410,6 @@ func (p *dockerNativeProvider) Update(ctx context.Context, req *rpc.UpdateReques SkipNulls: true, }, ) - if err != nil { return nil, err } @@ -441,7 +436,8 @@ func (p *dockerNativeProvider) GetPluginInfo(context.Context, *pbempty.Empty) (* // GetSchema returns the JSON-serialized schema for the provider. func (p *dockerNativeProvider) GetSchema(ctx context.Context, req *rpc.GetSchemaRequest) ( - *rpc.GetSchemaResponse, error) { + *rpc.GetSchemaResponse, error, +) { if v := req.GetVersion(); v != 0 { return nil, fmt.Errorf("unsupported schema version %d", v) } @@ -490,7 +486,8 @@ type contextHashAccumulator struct { func (accumulator *contextHashAccumulator) hashPath( filePath string, relativeNameOfFile string, - fileMode fs.FileMode) error { + fileMode fs.FileMode, +) error { hash := sha256.New() if fileMode.Type() == fs.ModeSymlink { diff --git a/provider/resources.go b/provider/resources.go index 3045facd..b643de71 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -191,6 +191,14 @@ func Provider() tfbridge.ProviderInfo { "e.g. `linux/arm64`.", TypeSpec: schema.TypeSpec{Type: "string"}, }, + "addHosts": { + Description: "Custom host-to-IP mappings to use while building (format: \"host:ip\")", + TypeSpec: schema.TypeSpec{Type: "array", Items: &schema.TypeSpec{Type: "string"}}, + }, + "network": { + Description: "Set the networking mode for RUN instructions", + TypeSpec: schema.TypeSpec{Type: "string"}, + }, }, }, }, @@ -217,10 +225,12 @@ func Provider() tfbridge.ProviderInfo { Type: "string", }, Enum: []schema.EnumValueSpec{ - {Name: "BuilderV1", Value: "BuilderV1", + { + Name: "BuilderV1", Value: "BuilderV1", Description: "The first generation builder for Docker Daemon", }, - {Name: "BuilderBuildKit", Value: "BuilderBuildKit", + { + Name: "BuilderBuildKit", Value: "BuilderBuildKit", Description: "The builder based on moby/buildkit project", }, }, @@ -269,6 +279,10 @@ func Provider() tfbridge.ProviderInfo { "e.g `sha256:826a130323165bb0ccb0374ae774f885c067a951b51a6ee133577f4e5dbc4119` \n", TypeSpec: schema.TypeSpec{Type: "string"}, }, + "platform": { + Description: "The image's architecture and OS", + TypeSpec: schema.TypeSpec{Type: "string"}, + }, }, }, IsComponent: false, @@ -331,7 +345,8 @@ func Provider() tfbridge.ProviderInfo { i := &tfbridge.PythonInfo{ Requires: map[string]string{ "pulumi": ">=3.0.0,<4.0.0", - }} + }, + } i.PyProject.Enabled = true return i })(), diff --git a/sdk/dotnet/Image.cs b/sdk/dotnet/Image.cs index a1d538b4..6100a149 100644 --- a/sdk/dotnet/Image.cs +++ b/sdk/dotnet/Image.cs @@ -176,6 +176,12 @@ public partial class Image : global::Pulumi.CustomResource [Output("imageName")] public Output ImageName { get; private set; } = null!; + /// + /// The image's architecture and OS + /// + [Output("platform")] + public Output Platform { get; private set; } = null!; + /// /// The name of the registry server hosting the image. /// diff --git a/sdk/dotnet/Inputs/DockerBuildArgs.cs b/sdk/dotnet/Inputs/DockerBuildArgs.cs index c33d3314..d69d83fa 100644 --- a/sdk/dotnet/Inputs/DockerBuildArgs.cs +++ b/sdk/dotnet/Inputs/DockerBuildArgs.cs @@ -15,6 +15,18 @@ namespace Pulumi.Docker.Inputs /// public sealed class DockerBuildArgs : global::Pulumi.ResourceArgs { + [Input("addHosts")] + private InputList? _addHosts; + + /// + /// Custom host-to-IP mappings to use while building (format: "host:ip") + /// + public InputList AddHosts + { + get => _addHosts ?? (_addHosts = new InputList()); + set => _addHosts = value; + } + [Input("args")] private InputMap? _args; @@ -51,6 +63,12 @@ public InputMap Args [Input("dockerfile")] public Input? Dockerfile { get; set; } + /// + /// Set the networking mode for RUN instructions + /// + [Input("network")] + public Input? Network { get; set; } + /// /// The architecture of the platform you want to build this image for, e.g. `linux/arm64`. /// diff --git a/sdk/go/docker/image.go b/sdk/go/docker/image.go index 7de61e7f..8fd2d4eb 100644 --- a/sdk/go/docker/image.go +++ b/sdk/go/docker/image.go @@ -172,6 +172,8 @@ type Image struct { Dockerfile pulumi.StringOutput `pulumi:"dockerfile"` // The fully qualified image name ImageName pulumi.StringOutput `pulumi:"imageName"` + // The image's architecture and OS + Platform pulumi.StringPtrOutput `pulumi:"platform"` // The name of the registry server hosting the image. RegistryServer pulumi.StringOutput `pulumi:"registryServer"` // **For pushed images:** @@ -367,6 +369,11 @@ func (o ImageOutput) ImageName() pulumi.StringOutput { return o.ApplyT(func(v *Image) pulumi.StringOutput { return v.ImageName }).(pulumi.StringOutput) } +// The image's architecture and OS +func (o ImageOutput) Platform() pulumi.StringPtrOutput { + return o.ApplyT(func(v *Image) pulumi.StringPtrOutput { return v.Platform }).(pulumi.StringPtrOutput) +} + // The name of the registry server hosting the image. func (o ImageOutput) RegistryServer() pulumi.StringOutput { return o.ApplyT(func(v *Image) pulumi.StringOutput { return v.RegistryServer }).(pulumi.StringOutput) diff --git a/sdk/go/docker/pulumiTypes.go b/sdk/go/docker/pulumiTypes.go index 599d6f93..8bc0ca88 100644 --- a/sdk/go/docker/pulumiTypes.go +++ b/sdk/go/docker/pulumiTypes.go @@ -9941,6 +9941,8 @@ func (o CacheFromPtrOutput) Images() pulumi.StringArrayOutput { // The Docker build context type DockerBuild struct { + // Custom host-to-IP mappings to use while building (format: "host:ip") + AddHosts []string `pulumi:"addHosts"` // An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. Args map[string]string `pulumi:"args"` // The version of the Docker builder. @@ -9951,6 +9953,8 @@ type DockerBuild struct { Context *string `pulumi:"context"` // The path to the Dockerfile to use. Dockerfile *string `pulumi:"dockerfile"` + // Set the networking mode for RUN instructions + Network *string `pulumi:"network"` // The architecture of the platform you want to build this image for, e.g. `linux/arm64`. Platform *string `pulumi:"platform"` // The target of the Dockerfile to build @@ -9970,6 +9974,8 @@ type DockerBuildInput interface { // The Docker build context type DockerBuildArgs struct { + // Custom host-to-IP mappings to use while building (format: "host:ip") + AddHosts pulumi.StringArrayInput `pulumi:"addHosts"` // An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. Args pulumi.StringMapInput `pulumi:"args"` // The version of the Docker builder. @@ -9980,6 +9986,8 @@ type DockerBuildArgs struct { Context pulumi.StringPtrInput `pulumi:"context"` // The path to the Dockerfile to use. Dockerfile pulumi.StringPtrInput `pulumi:"dockerfile"` + // Set the networking mode for RUN instructions + Network pulumi.StringPtrInput `pulumi:"network"` // The architecture of the platform you want to build this image for, e.g. `linux/arm64`. Platform pulumi.StringPtrInput `pulumi:"platform"` // The target of the Dockerfile to build @@ -10064,6 +10072,11 @@ func (o DockerBuildOutput) ToDockerBuildPtrOutputWithContext(ctx context.Context }).(DockerBuildPtrOutput) } +// Custom host-to-IP mappings to use while building (format: "host:ip") +func (o DockerBuildOutput) AddHosts() pulumi.StringArrayOutput { + return o.ApplyT(func(v DockerBuild) []string { return v.AddHosts }).(pulumi.StringArrayOutput) +} + // An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. func (o DockerBuildOutput) Args() pulumi.StringMapOutput { return o.ApplyT(func(v DockerBuild) map[string]string { return v.Args }).(pulumi.StringMapOutput) @@ -10089,6 +10102,11 @@ func (o DockerBuildOutput) Dockerfile() pulumi.StringPtrOutput { return o.ApplyT(func(v DockerBuild) *string { return v.Dockerfile }).(pulumi.StringPtrOutput) } +// Set the networking mode for RUN instructions +func (o DockerBuildOutput) Network() pulumi.StringPtrOutput { + return o.ApplyT(func(v DockerBuild) *string { return v.Network }).(pulumi.StringPtrOutput) +} + // The architecture of the platform you want to build this image for, e.g. `linux/arm64`. func (o DockerBuildOutput) Platform() pulumi.StringPtrOutput { return o.ApplyT(func(v DockerBuild) *string { return v.Platform }).(pulumi.StringPtrOutput) @@ -10123,6 +10141,16 @@ func (o DockerBuildPtrOutput) Elem() DockerBuildOutput { }).(DockerBuildOutput) } +// Custom host-to-IP mappings to use while building (format: "host:ip") +func (o DockerBuildPtrOutput) AddHosts() pulumi.StringArrayOutput { + return o.ApplyT(func(v *DockerBuild) []string { + if v == nil { + return nil + } + return v.AddHosts + }).(pulumi.StringArrayOutput) +} + // An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. func (o DockerBuildPtrOutput) Args() pulumi.StringMapOutput { return o.ApplyT(func(v *DockerBuild) map[string]string { @@ -10173,6 +10201,16 @@ func (o DockerBuildPtrOutput) Dockerfile() pulumi.StringPtrOutput { }).(pulumi.StringPtrOutput) } +// Set the networking mode for RUN instructions +func (o DockerBuildPtrOutput) Network() pulumi.StringPtrOutput { + return o.ApplyT(func(v *DockerBuild) *string { + if v == nil { + return nil + } + return v.Network + }).(pulumi.StringPtrOutput) +} + // The architecture of the platform you want to build this image for, e.g. `linux/arm64`. func (o DockerBuildPtrOutput) Platform() pulumi.StringPtrOutput { return o.ApplyT(func(v *DockerBuild) *string { diff --git a/sdk/java/src/main/java/com/pulumi/docker/Image.java b/sdk/java/src/main/java/com/pulumi/docker/Image.java index 05583b93..da1628d6 100644 --- a/sdk/java/src/main/java/com/pulumi/docker/Image.java +++ b/sdk/java/src/main/java/com/pulumi/docker/Image.java @@ -12,6 +12,7 @@ import com.pulumi.docker.Utilities; import java.lang.String; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; /** @@ -232,6 +233,20 @@ public Output dockerfile() { public Output imageName() { return this.imageName; } + /** + * The image's architecture and OS + * + */ + @Export(name="platform", refs={String.class}, tree="[0]") + private Output platform; + + /** + * @return The image's architecture and OS + * + */ + public Output> platform() { + return Codegen.optional(this.platform); + } /** * The name of the registry server hosting the image. * diff --git a/sdk/java/src/main/java/com/pulumi/docker/inputs/DockerBuildArgs.java b/sdk/java/src/main/java/com/pulumi/docker/inputs/DockerBuildArgs.java index 72803efa..8bb5f484 100644 --- a/sdk/java/src/main/java/com/pulumi/docker/inputs/DockerBuildArgs.java +++ b/sdk/java/src/main/java/com/pulumi/docker/inputs/DockerBuildArgs.java @@ -8,6 +8,7 @@ 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; @@ -22,6 +23,21 @@ public final class DockerBuildArgs extends com.pulumi.resources.ResourceArgs { public static final DockerBuildArgs Empty = new DockerBuildArgs(); + /** + * Custom host-to-IP mappings to use while building (format: "host:ip") + * + */ + @Import(name="addHosts") + private @Nullable Output> addHosts; + + /** + * @return Custom host-to-IP mappings to use while building (format: "host:ip") + * + */ + public Optional>> addHosts() { + return Optional.ofNullable(this.addHosts); + } + /** * An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. * @@ -97,6 +113,21 @@ public Optional> dockerfile() { return Optional.ofNullable(this.dockerfile); } + /** + * Set the networking mode for RUN instructions + * + */ + @Import(name="network") + private @Nullable Output network; + + /** + * @return Set the networking mode for RUN instructions + * + */ + public Optional> network() { + return Optional.ofNullable(this.network); + } + /** * The architecture of the platform you want to build this image for, e.g. `linux/arm64`. * @@ -130,11 +161,13 @@ public Optional> target() { private DockerBuildArgs() {} private DockerBuildArgs(DockerBuildArgs $) { + this.addHosts = $.addHosts; this.args = $.args; this.builderVersion = $.builderVersion; this.cacheFrom = $.cacheFrom; this.context = $.context; this.dockerfile = $.dockerfile; + this.network = $.network; this.platform = $.platform; this.target = $.target; } @@ -157,6 +190,37 @@ public Builder(DockerBuildArgs defaults) { $ = new DockerBuildArgs(Objects.requireNonNull(defaults)); } + /** + * @param addHosts Custom host-to-IP mappings to use while building (format: "host:ip") + * + * @return builder + * + */ + public Builder addHosts(@Nullable Output> addHosts) { + $.addHosts = addHosts; + return this; + } + + /** + * @param addHosts Custom host-to-IP mappings to use while building (format: "host:ip") + * + * @return builder + * + */ + public Builder addHosts(List addHosts) { + return addHosts(Output.of(addHosts)); + } + + /** + * @param addHosts Custom host-to-IP mappings to use while building (format: "host:ip") + * + * @return builder + * + */ + public Builder addHosts(String... addHosts) { + return addHosts(List.of(addHosts)); + } + /** * @param args An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. * @@ -262,6 +326,27 @@ public Builder dockerfile(String dockerfile) { return dockerfile(Output.of(dockerfile)); } + /** + * @param network Set the networking mode for RUN instructions + * + * @return builder + * + */ + public Builder network(@Nullable Output network) { + $.network = network; + return this; + } + + /** + * @param network Set the networking mode for RUN instructions + * + * @return builder + * + */ + public Builder network(String network) { + return network(Output.of(network)); + } + /** * @param platform The architecture of the platform you want to build this image for, e.g. `linux/arm64`. * diff --git a/sdk/nodejs/image.ts b/sdk/nodejs/image.ts index 3208803c..9a2964d2 100644 --- a/sdk/nodejs/image.ts +++ b/sdk/nodejs/image.ts @@ -144,6 +144,10 @@ export class Image extends pulumi.CustomResource { * The fully qualified image name */ public readonly imageName!: pulumi.Output; + /** + * The image's architecture and OS + */ + public /*out*/ readonly platform!: pulumi.Output; /** * The name of the registry server hosting the image. */ @@ -180,6 +184,7 @@ export class Image extends pulumi.CustomResource { resourceInputs["baseImageName"] = undefined /*out*/; resourceInputs["context"] = undefined /*out*/; resourceInputs["dockerfile"] = undefined /*out*/; + resourceInputs["platform"] = undefined /*out*/; resourceInputs["registryServer"] = undefined /*out*/; resourceInputs["repoDigest"] = undefined /*out*/; } else { @@ -187,6 +192,7 @@ export class Image extends pulumi.CustomResource { resourceInputs["context"] = undefined /*out*/; resourceInputs["dockerfile"] = undefined /*out*/; resourceInputs["imageName"] = undefined /*out*/; + resourceInputs["platform"] = undefined /*out*/; resourceInputs["registryServer"] = undefined /*out*/; resourceInputs["repoDigest"] = undefined /*out*/; } diff --git a/sdk/nodejs/types/input.ts b/sdk/nodejs/types/input.ts index fa3a4d54..e40453c4 100644 --- a/sdk/nodejs/types/input.ts +++ b/sdk/nodejs/types/input.ts @@ -281,6 +281,10 @@ export interface ContainerVolume { * The Docker build context */ export interface DockerBuild { + /** + * Custom host-to-IP mappings to use while building (format: "host:ip") + */ + addHosts?: pulumi.Input[]>; /** * An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. */ @@ -301,6 +305,10 @@ export interface DockerBuild { * The path to the Dockerfile to use. */ dockerfile?: pulumi.Input; + /** + * Set the networking mode for RUN instructions + */ + network?: pulumi.Input; /** * The architecture of the platform you want to build this image for, e.g. `linux/arm64`. */ diff --git a/sdk/python/pulumi_docker/_inputs.py b/sdk/python/pulumi_docker/_inputs.py index d35ecb86..4ea12df4 100644 --- a/sdk/python/pulumi_docker/_inputs.py +++ b/sdk/python/pulumi_docker/_inputs.py @@ -4477,23 +4477,29 @@ def images(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]): @pulumi.input_type class DockerBuildArgs: def __init__(__self__, *, + add_hosts: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, args: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None, builder_version: Optional[pulumi.Input['BuilderVersion']] = None, cache_from: Optional[pulumi.Input['CacheFromArgs']] = None, context: Optional[pulumi.Input[str]] = None, dockerfile: Optional[pulumi.Input[str]] = None, + network: Optional[pulumi.Input[str]] = None, platform: Optional[pulumi.Input[str]] = None, target: Optional[pulumi.Input[str]] = None): """ The Docker build context + :param pulumi.Input[Sequence[pulumi.Input[str]]] add_hosts: Custom host-to-IP mappings to use while building (format: "host:ip") :param pulumi.Input[Mapping[str, pulumi.Input[str]]] args: An optional map of named build-time argument variables to set during the Docker build. This flag allows you to pass build-time variables that can be accessed like environment variables inside the RUN instruction. :param pulumi.Input['BuilderVersion'] builder_version: The version of the Docker builder. :param pulumi.Input['CacheFromArgs'] cache_from: A list of image names to use as build cache. Images provided must have a cache manifest. Must provide authentication to cache registry. :param pulumi.Input[str] context: The path to the build context to use. :param pulumi.Input[str] dockerfile: The path to the Dockerfile to use. + :param pulumi.Input[str] network: Set the networking mode for RUN instructions :param pulumi.Input[str] platform: The architecture of the platform you want to build this image for, e.g. `linux/arm64`. :param pulumi.Input[str] target: The target of the Dockerfile to build """ + if add_hosts is not None: + pulumi.set(__self__, "add_hosts", add_hosts) if args is not None: pulumi.set(__self__, "args", args) if builder_version is not None: @@ -4504,11 +4510,25 @@ def __init__(__self__, *, pulumi.set(__self__, "context", context) if dockerfile is not None: pulumi.set(__self__, "dockerfile", dockerfile) + if network is not None: + pulumi.set(__self__, "network", network) if platform is not None: pulumi.set(__self__, "platform", platform) if target is not None: pulumi.set(__self__, "target", target) + @property + @pulumi.getter(name="addHosts") + def add_hosts(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]: + """ + Custom host-to-IP mappings to use while building (format: "host:ip") + """ + return pulumi.get(self, "add_hosts") + + @add_hosts.setter + def add_hosts(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]): + pulumi.set(self, "add_hosts", value) + @property @pulumi.getter def args(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]: @@ -4569,6 +4589,18 @@ def dockerfile(self) -> Optional[pulumi.Input[str]]: def dockerfile(self, value: Optional[pulumi.Input[str]]): pulumi.set(self, "dockerfile", value) + @property + @pulumi.getter + def network(self) -> Optional[pulumi.Input[str]]: + """ + Set the networking mode for RUN instructions + """ + return pulumi.get(self, "network") + + @network.setter + def network(self, value: Optional[pulumi.Input[str]]): + pulumi.set(self, "network", value) + @property @pulumi.getter def platform(self) -> Optional[pulumi.Input[str]]: diff --git a/sdk/python/pulumi_docker/image.py b/sdk/python/pulumi_docker/image.py index 5e97ae2e..ce2a4826 100644 --- a/sdk/python/pulumi_docker/image.py +++ b/sdk/python/pulumi_docker/image.py @@ -323,6 +323,7 @@ def _internal_init(__self__, __props__.__dict__["base_image_name"] = None __props__.__dict__["context"] = None __props__.__dict__["dockerfile"] = None + __props__.__dict__["platform"] = None __props__.__dict__["registry_server"] = None __props__.__dict__["repo_digest"] = None alias_opts = pulumi.ResourceOptions(aliases=[pulumi.Alias(type_="docker:image:Image")]) @@ -353,6 +354,7 @@ def get(resource_name: str, __props__.__dict__["context"] = None __props__.__dict__["dockerfile"] = None __props__.__dict__["image_name"] = None + __props__.__dict__["platform"] = None __props__.__dict__["registry_server"] = None __props__.__dict__["repo_digest"] = None return Image(resource_name, opts=opts, __props__=__props__) @@ -389,6 +391,14 @@ def image_name(self) -> pulumi.Output[str]: """ return pulumi.get(self, "image_name") + @property + @pulumi.getter + def platform(self) -> pulumi.Output[Optional[str]]: + """ + The image's architecture and OS + """ + return pulumi.get(self, "platform") + @property @pulumi.getter(name="registryServer") def registry_server(self) -> pulumi.Output[str]: