Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,26 @@ public void construct(pulumirpc.Provider.ConstructRequest request,
.map(reference -> new DependencyProviderResource(reference))
.toArray(DependencyProviderResource[]::new);

var opts = ComponentResourceOptions.builder()
var optsBuilder = ComponentResourceOptions.builder()
.aliases(aliases)
.dependsOn(dependsOn)
.protect(request.getProtect())
.providers(providers)
.parent(new DependencyResource(request.getParent()))
.customTimeouts(deserializeTimeouts(request.getCustomTimeouts()))
// TODO deletedWith: https://github.com/pulumi/pulumi-java/issues/944
.ignoreChanges(request.getIgnoreChangesList())
.retainOnDelete(request.getRetainOnDelete())
.replaceOnChanges(request.getReplaceOnChangesList())
.build();
.replaceOnChanges(request.getReplaceOnChangesList());

if (request.getProtect()) {
optsBuilder = optsBuilder.protect();
}
if (request.getRetainOnDelete()) {
optsBuilder = optsBuilder.retainOnDelete();
}


var opts = optsBuilder.build();

var domRequest = new com.pulumi.provider.internal.models.ConstructRequest(
request.getType(), request.getName(), unmarshal(request.getInputs()), opts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public ComponentResourceOptions(
@Nullable Output<String> id,
@Nullable Resource parent,
@Nullable Output<List<Resource>> dependsOn,
boolean protect,
@Nullable boolean protect,
@Nullable List<String> ignoreChanges,
@Nullable String version,
@Nullable CustomTimeouts customTimeouts,
@Nullable List<ResourceTransformation> resourceTransformations,
@Nullable List<Output<Alias>> aliases,
@Nullable String urn,
@Nullable List<String> replaceOnChanges,
boolean retainOnDelete,
@Nullable boolean retainOnDelete,
@Nullable String pluginDownloadURL,
@Nullable List<String> hideDiffs,
@Nullable List<ProviderResource> providers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ private CustomResourceOptions(
@Nullable Output<String> id,
@Nullable Resource parent,
@Nullable Output<List<Resource>> dependsOn,
boolean protect,
@Nullable boolean protect,
@Nullable List<String> ignoreChanges,
@Nullable String version,
@Nullable ProviderResource provider,
@Nullable CustomTimeouts customTimeouts,
@Nullable List<ResourceTransformation> resourceTransformations,
@Nullable List<Output<Alias>> aliases,
@Nullable String urn,
boolean deleteBeforeReplace,
@Nullable boolean deleteBeforeReplace,
@Nullable List<String> additionalSecretOutputs,
@Nullable String importId,
@Nullable List<String> replaceOnChanges,
boolean retainOnDelete,
@Nullable boolean retainOnDelete,
@Nullable String pluginDownloadURL,
@Nullable List<String> hideDiffs,
@Nullable List<Resource> replaceWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public abstract class Resource {
/**
* When set to true, protect ensures this resource cannot be deleted.
*/
@Nullable
private final boolean protect;

private final List<ResourceTransformation> transformations;
Expand Down Expand Up @@ -118,7 +119,7 @@ protected Resource(
// this.urn will be set using setter in the subtype constructor after this supertype constructor finishes
this.type = "";
this.name = "";
this.protect = false;
this.protect = null;
this.transformations = List.of();
this.providers = Map.of();
this.provider = null;
Expand Down Expand Up @@ -200,7 +201,9 @@ protected Resource(
// the 'childResources' is a Synchronized Collection, so this is safe operation
parentResource.childResources.add(this);

options.protect = options.protect || parentResource.protect; // TODO: is this logic good?
if (options.protect == null) {
options.protect = parentResource.protect;
}
thisProviders.putAll(options.parent.providers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class ResourceOptions {
protected Resource parent;
@Nullable
protected Output<List<Resource>> dependsOn;
@Nullable
protected boolean protect;
@Nullable
protected List<String> ignoreChanges;
Expand All @@ -40,6 +41,7 @@ public abstract class ResourceOptions {
protected String urn;
@Nullable
protected List<String> replaceOnChanges;
@Nullable
protected boolean retainOnDelete;
@Nullable
protected String pluginDownloadURL;
Expand All @@ -54,7 +56,7 @@ protected ResourceOptions(
@Nullable Output<String> id,
@Nullable Resource parent,
@Nullable Output<List<Resource>> dependsOn,
boolean protect,
@Nullable boolean protect,
@Nullable List<String> ignoreChanges,
@Nullable String version,
@Nullable ProviderResource provider,
Expand All @@ -63,7 +65,7 @@ protected ResourceOptions(
@Nullable List<Output<Alias>> aliases,
@Nullable String urn,
@Nullable List<String> replaceOnChanges,
boolean retainOnDelete,
@Nullable boolean retainOnDelete,
@Nullable String pluginDownloadURL,
@Nullable List<String> hideDiffs,
@Nullable List<Resource> replaceWith
Expand Down Expand Up @@ -455,7 +457,7 @@ protected static <T extends ResourceOptions> T mergeSharedOptions(T options1, T

options1.id = options2.id == null ? options1.id : options2.id;
options1.parent = options2.parent == null ? options1.parent : options2.parent;
options1.protect = options1.protect || options2.protect;
options1.protect = options2.protect == null ? options1.protect : options2.protect;
options1.urn = options2.urn == null ? options1.urn : options2.urn;
options1.version = options2.version == null ? options1.version : options2.version;
options1.provider = options2.provider == null ? options1.provider : options2.provider;
Expand Down
Loading