Skip to content

Commit

Permalink
Remove @Deprecated Java SDK members
Browse files Browse the repository at this point in the history
As part of the 1.0.0 release, this change removes parts of the Java SDK that
have been marked as deprecated and are no longer in use by internal Pulumi
functions. The `Config.of` method has been left as it looks like we might still
be generating code that uses it -- this will be addressed in a future piece of
work if so.

> [!NOTE]
> This is incompatible with some old SDKs that use annotations or annotation
> fields that are no longer present (or searched for), such as the `type` and
> `parameters` fields of the `Export` annotation. Some rough checking seems that
> we made this change a few years ago, so it should be relatively safe, but it is
> still breaking nonetheless (as is to be expected, arguably).
  • Loading branch information
lunaris committed Jan 15, 2025
1 parent a3a2508 commit 98344ac
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 405 deletions.
23 changes: 15 additions & 8 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
### Improvements

- Fix emitted functions for `assetArchive` and `remoteAsset` in generated programs
- Fix generation of `double` literals in generated programs
- Avoid calling invokes with dependencies on unknown resources
- Fix generation of untyped maps and array literals
- Implement `InvokeOptionsBuilder` and `InvokeOutputOptionsBuilder`
- Emit invoke options and invoke output options in generated programs

### Bug Fixes
- Fix emitted functions for `assetArchive` and `remoteAsset` in generated programs

- Fix generation of `double` literals in generated programs

- Avoid calling invokes with dependencies on unknown resources

- Fix generation of untyped maps and array literals

- Implement `InvokeOptionsBuilder` and `InvokeOutputOptionsBuilder`

- Emit invoke options and invoke output options in generated programs

- Remove `@Deprecated` members from the Java SDK

### Bug Fixes
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void testJumboCustomType() {
}).throwOnError();

var resource = result.resources().stream()
.filter(r -> r.getResourceName().equals("testResource"))
.filter(r -> r.pulumiResourceName().equals("testResource"))
.filter(r -> r instanceof ACustomResource)
.map(r -> (ACustomResource) r)
.findFirst()
Expand All @@ -581,4 +581,4 @@ public CompletableFuture<ResourceResult> newResourceAsync(ResourceArgs args) {
throw new IllegalArgumentException(String.format("Unknown resource '%s'", args.type));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,14 @@
* Annotation used by a Pulumi Cloud Provider Package to mark complex types used for a Resource
* output property.
* <p>
* A complex type must have a single constructor
* marked with the @see {@link CustomType.Constructor} annotation,
* or a single builder marked with the @see {@link CustomType.Builder} annotation.
* A complex type must have a single builder marked with the {@link CustomType.Builder} annotation.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface CustomType {

/**
* Annotation used by a Pulumi provider to mark the constructor for a complex
* property type so that it can be instantiated by the Pulumi runtime.
* <p>
* <b>WARNING:</b> nested classes will have a reference to the parent class
* as the first parameter of the constructor ({@code arg0})
* and this type also needs to be deserializable
* or the class needs to be made static.
* This is unlikely scenario, but theoretically possible.
* The invisible fist argument needs also to be named in the annotation value.
* <p>
* The constructor must take parameters annotated with {@link Parameter} that map to
* the resultant @see {@link com.google.protobuf.Struct} returned by the engine.
*
* @deprecated use {@link CustomType.Builder} and {@link CustomType.Setter}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.CONSTRUCTOR)
@Deprecated
@interface Constructor {
/* Empty */
}

/**
* Annotation used by a Pulumi provider to mark a builder for a complex
* property type so that it can be instantiated by the Pulumi runtime.
* <p>
* The setter must take a parameter annotated with {@link Parameter} that map to
* the resultant @see {@link com.google.protobuf.Struct} returned by the engine.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand All @@ -56,9 +27,6 @@
/**
* Annotation used by a Pulumi provider to mark a setter for a complex
* property type so that it can be instantiated by the Pulumi runtime.
* <p>
* The setter must take a parameter annotated with {@link Parameter} that map to
* the resultant @see {@link com.google.protobuf.Struct} returned by the engine.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
Expand All @@ -71,23 +39,4 @@
*/
String value() default "";
}

/**
* Annotation used by a Pulumi Cloud Provider Package to marks a constructor parameter for a complex
* property type so that it can be instantiated by the Pulumi runtime.
*
* @deprecated use {@link CustomType.Builder} and {@link CustomType.Setter}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@Deprecated
@interface Parameter {
/**
* We need to know the name of a constructor parameter,
* and unfortunately Java compiler does not give this information through reflection (by default)
*
* @return name of a constructor parameter
*/
String value();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@
*/
String name() default "";

/**
* @return the generic type parameter of the annotated @see {@link com.pulumi.core.Output}
* @deprecated use {@link #tree()} and {@link #refs()}
*/
@Deprecated
Class<?> type() default Object.class;

/**
* @return the generic type parameters of the @see {@link #type()}
* If not set, the assumption is that the @see {@link #type()} is not a generic type.
* @deprecated use {@link #tree()} and {@link #refs()}
*/
@Deprecated
Class<?>[] parameters() default {};

/**
* @return the generic type parameter tree shape of the annotated @see {@link com.pulumi.core.Output}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,8 @@ public static ImmutableMap<String, ExportMetadata<?>> of(Class<?> extractionType
)));

var fieldType = field.getType();
if (export.refs().length == 0) {
var exportType = export.type();
var parameters = export.parameters();
return of(field, export, fieldType, exportType, parameters);
} else {
var exportTypeNew = TypeShape.fromTree(export.refs(), export.tree());
return of(field, export, fieldType, exportTypeNew);
}
var exportTypeNew = TypeShape.fromTree(export.refs(), export.tree());
return of(field, export, fieldType, exportTypeNew);
})
.collect(toImmutableMap(
ImportExportMetadata::getName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ protected Optional<CompletableFuture<Output<String>>> idFuture() {
return Optional.of(this.idFuture);
}

/**
* ID is the provider-assigned unique ID for this managed resource. It is set during
* deployments and may be missing (unknown) during planning phases.
*
* @return the provider-assigned unique ID
* @deprecated use {@link #id()}
*/
@Deprecated
public Output<String> getId() {
return id();
}

/**
* Pulumi ID is the provider-assigned unique ID for this managed resource.
* It is set during deployments and may be missing (unknown) during planning phases.
Expand Down
56 changes: 0 additions & 56 deletions sdk/java/pulumi/src/main/java/com/pulumi/resources/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,6 @@ protected Optional<CompletableFuture<Output<String>>> idFuture() {
return Optional.empty();
}

/**
* The type assigned to the resource at construction.
*
* @return the type of the resource
* @deprecated use {@link #pulumiResourceType()}
*/
@Deprecated
public String getResourceType() {
return type;
}

/**
* The Pulumi type assigned to the resource at construction.
*
Expand All @@ -273,17 +262,6 @@ public String pulumiResourceType() {
return type;
}

/**
* The name assigned to the resource at construction.
*
* @return the name of the resource
* @deprecated use {@link #pulumiResourceName()}
*/
@Deprecated
public String getResourceName() {
return name;
}

/**
* The Pulumi name assigned to the resource at construction.
*
Expand All @@ -293,29 +271,6 @@ public String pulumiResourceName() {
return name;
}

/**
* The child resources of this resource. We use these (only from a @see {@link ComponentResource}) to
* allow code to "dependOn" a @see {@link ComponentResource} and have that effectively mean that it is
* depending on all the @see {@link ComponentResource} children of that component.
* <p>
* Important! We only walk through @see {@link ComponentResource}s. They're the only resources that
* serve as an aggregation of other primitive (i.e.custom) resources.
* While a custom resource can be a parent of other resources, we don't want to ever depend
* on those child resource.
* If we do, it's simple to end up in a situation where we end up depending on a
* child resource that has a data cycle dependency due to the data passed into it.
* This would be pretty nonsensical as there is zero need for a custom resource to
* ever need to reference the urn of a component resource.
* So it's acceptable if that sort of pattern failed in practice.
*
* @return the child resources of this resource
* @deprecated use {@link #pulumiChildResources()}
*/
@Deprecated
public Set<Resource> getChildResources() {
return childResources;
}

/**
* The child resources of this Pulumi resource. We use these (only from a @see {@link ComponentResource}) to
* allow code to "dependOn" a @see {@link ComponentResource} and have that effectively mean that it is
Expand All @@ -337,17 +292,6 @@ public Set<Resource> pulumiChildResources() {
return childResources;
}

/**
* Urn is the stable logical URN used to distinctly address a resource, both before and after deployments.
*
* @return the stable logical URN
* @deprecated use {@link #urn()}
*/
@Deprecated
public Output<String> getUrn() {
return this.urn;
}

/**
* Pulumi URN is the stable logical identifier used to distinctly address a resource,
* both before and after deployments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,19 @@ public Resource resource() {
return this.resource;
}

/**
* @return the {@link Resource} instance that is being transformed.
* @deprecated use {@link #resource()}
*/
@Deprecated
public Resource getResource() {
return this.resource;
}

/**
* @return the original properties passed to the {@link Resource} constructor.
*/
public ResourceArgs args() {
return this.args;
}

/**
* @return the original properties passed to the {@link Resource} constructor.
* @deprecated use {@link #args()}
*/
@Deprecated
public ResourceArgs getArgs() {
return this.args;
}

/**
* @return the original resource options passed to the {@link Resource} constructor.
*/
public ResourceOptions options() {
return this.options;
}

/**
* @return the original resource options passed to the {@link Resource} constructor.
* @deprecated use {@link #options()}
*/
@Deprecated
public ResourceOptions getOptions() {
return this.options;
}
}

/**
Expand All @@ -112,29 +85,11 @@ public ResourceArgs args() {
return args;
}

/**
* @return the original properties passed to the Resource constructor.
* @deprecated use {@link #args()}
*/
@Deprecated
public ResourceArgs getArgs() {
return args;
}

/**
* @return the original resource options passed to the Resource constructor.
*/
public ResourceOptions options() {
return options;
}

/**
* @return the original resource options passed to the Resource constructor.
* @deprecated use {@link #options()}
*/
@Deprecated
public ResourceOptions getOptions() {
return options;
}
}
}
}
Loading

0 comments on commit 98344ac

Please sign in to comment.