Skip to content

Commit

Permalink
Alias Docker image to avoid deletion on upgrade to v4 (#483)
Browse files Browse the repository at this point in the history
* Add alias to Image

* generate schema and SDKs
  • Loading branch information
guineveresaenger authored Feb 9, 2023
1 parent e5f913e commit 5d852bc
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions provider/cmd/pulumi-resource-docker/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4462,6 +4462,11 @@
},
"requiredInputs": [
"imageName"
],
"aliases": [
{
"type": "docker:image:Image"
}
]
},
"docker:index/network:Network": {
Expand Down
6 changes: 6 additions & 0 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package provider
import (
"fmt"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"path/filepath"
"unicode"

Expand Down Expand Up @@ -274,6 +275,11 @@ func Provider() tfbridge.ProviderInfo {
},
},
RequiredInputs: []string{"imageName"},
Aliases: []schema.AliasSpec{
{
Type: pulumi.StringRef("docker:image:Image"),
},
},
},
},

Expand Down
4 changes: 4 additions & 0 deletions sdk/dotnet/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
Aliases =
{
new global::Pulumi.Alias { Type = "docker:image:Image"},
},
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
6 changes: 6 additions & 0 deletions sdk/go/docker/image.go

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

5 changes: 5 additions & 0 deletions sdk/java/src/main/java/com/pulumi/docker/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

package com.pulumi.docker;

import com.pulumi.core.Alias;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import com.pulumi.docker.ImageArgs;
import com.pulumi.docker.Utilities;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -130,6 +132,9 @@ private Image(String name, Output<String> id, @Nullable com.pulumi.resources.Cus
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.aliases(List.of(
Output.of(Alias.builder().type("docker:image:Image").build())
))
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
Expand Down
2 changes: 2 additions & 0 deletions sdk/nodejs/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export class Image extends pulumi.CustomResource {
resourceInputs["registryServer"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "docker:image:Image" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(Image.__pulumiType, name, resourceInputs, opts);
}
}
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/pulumi_docker/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def _internal_init(__self__,
__props__.__dict__["skip_push"] = skip_push
__props__.__dict__["base_image_name"] = None
__props__.__dict__["registry_server"] = None
alias_opts = pulumi.ResourceOptions(aliases=[pulumi.Alias(type_="docker:image:Image")])
opts = pulumi.ResourceOptions.merge(opts, alias_opts)
super(Image, __self__).__init__(
'docker:index/image:Image',
resource_name,
Expand Down

0 comments on commit 5d852bc

Please sign in to comment.