Skip to content

Commit 61789d5

Browse files
committed
use append semantics for otherFields
1 parent 49dff94 commit 61789d5

9 files changed

+871
-9
lines changed

provider/pkg/gen/java-templates/src/main/java/com/pulumi/kubernetes/apiextensions/CustomResourceArgsBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public U metadata(ObjectMetaArgs metadata) {
172172
*
173173
*/
174174
public U otherFields(Map<String, ?> fields) {
175-
var map = new LinkedHashMap<String, Output<?>>();
175+
var map = $.otherFields != null ? new LinkedHashMap($.otherFields) : new LinkedHashMap<String, Output>();
176176
for (var entry : fields.entrySet()) {
177177
var value = entry.getValue();
178178
map.put(entry.getKey(), (value instanceof Output) ? (Output) value : Output.of(value));

provider/pkg/gen/java-templates/src/main/java/com/pulumi/kubernetes/apiextensions/CustomResourcePatchArgsBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public U metadata(ObjectMetaPatchArgs metadata) {
172172
*
173173
*/
174174
public U otherFields(Map<String, ?> fields) {
175-
var map = new LinkedHashMap<String, Output<?>>();
175+
var map = $.otherFields != null ? new LinkedHashMap($.otherFields) : new LinkedHashMap<String, Output>();
176176
for (var entry : fields.entrySet()) {
177177
var value = entry.getValue();
178178
map.put(entry.getKey(), (value instanceof Output) ? (Output) value : Output.of(value));

sdk/java/src/main/java/com/pulumi/kubernetes/apiextensions/CustomResource.java

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
// *** WARNING: this file was generated by pulumi-java-gen. ***
2+
// *** Do not edit by hand unless you're certain you know what you are doing! ***
3+
4+
package com.pulumi.kubernetes.apiextensions;
5+
6+
import java.util.Optional;
7+
import java.util.concurrent.ExecutionException;
8+
9+
import javax.annotation.Nullable;
10+
11+
import com.pulumi.core.Output;
12+
import com.pulumi.core.annotations.Export;
13+
import com.pulumi.core.annotations.ResourceType;
14+
import com.pulumi.core.internal.Codegen;
15+
import com.pulumi.core.internal.Internal;
16+
import com.pulumi.core.internal.OutputInternal;
17+
import com.pulumi.kubernetes.Utilities;
18+
import com.pulumi.kubernetes.meta.v1.outputs.ObjectMeta;
19+
import com.pulumi.resources.ResourceArgs;
20+
21+
/**
22+
* CustomResource represents an instance of a CustomResourceDefinition (CRD). For example, the
23+
* CoreOS Prometheus operator exposes a CRD `monitoring.coreos.com/ServiceMonitor`; to
24+
* instantiate this as a Pulumi resource, one could call `new CustomResource`, passing the
25+
* `ServiceMonitor` resource definition as an argument.
26+
*/
27+
@ResourceType(type="kubernetes:apiextensions:CustomResource")
28+
public class CustomResource extends com.pulumi.resources.CustomResource {
29+
/**
30+
* APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
31+
*
32+
*/
33+
@Export(name="apiVersion", refs={String.class}, tree="[0]")
34+
private Output<String> apiVersion;
35+
36+
/**
37+
* @return APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
38+
*
39+
*/
40+
public Output<String> apiVersion() {
41+
return this.apiVersion;
42+
}
43+
44+
/**
45+
* Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
46+
*
47+
*/
48+
@Export(name="kind", refs={String.class}, tree="[0]")
49+
private Output<String> kind;
50+
51+
/**
52+
* @return Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
53+
*
54+
*/
55+
public Output<String> kind() {
56+
return this.kind;
57+
}
58+
59+
/**
60+
* Standard object&#39;s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
61+
*
62+
*/
63+
@Export(name="metadata", refs={ObjectMeta.class}, tree="[0]")
64+
private Output<ObjectMeta> metadata;
65+
66+
/**
67+
* @return Standard object&#39;s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
68+
*
69+
*/
70+
public Output<ObjectMeta> metadata() {
71+
return this.metadata;
72+
}
73+
74+
/**
75+
*
76+
* @param name The _unique_ name of the resulting resource.
77+
*/
78+
public CustomResource(String name) {
79+
this(name, CustomResourceArgs.Empty);
80+
}
81+
82+
/**
83+
*
84+
* @param name The _unique_ name of the resulting resource.
85+
* @param args The arguments to use to populate this resource's properties.
86+
*/
87+
public CustomResource(String name, @Nullable CustomResourceArgsBase args) {
88+
this(name, args, null);
89+
}
90+
91+
/**
92+
*
93+
* @param name The _unique_ name of the resulting resource.
94+
* @param args The arguments to use to populate this resource's properties.
95+
* @param options A bag of options that control this resource's behavior.
96+
*/
97+
public CustomResource(String name, @Nullable CustomResourceArgsBase args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
98+
super(makeType(args), name, makeArgs(args), makeResourceOptions(options, Codegen.empty()));
99+
}
100+
101+
protected CustomResource(String name, String apiVersion, String kind, Output<String> id,
102+
@Nullable com.pulumi.resources.CustomResourceOptions options) {
103+
super(String.format("kubernetes:%s:%s", apiVersion, kind), name, null, makeResourceOptions(options, id));
104+
}
105+
106+
private static String makeType(@Nullable CustomResourceArgsBase args) {
107+
String apiVersion = args.apiVersion().map(Internal::of).map(CustomResource::getOutputValue).orElse("");
108+
String kind = args.kind().map(Internal::of).map(CustomResource::getOutputValue).orElse("");
109+
return String.format("kubernetes:%s:%s", apiVersion, kind);
110+
}
111+
112+
private static String getOutputValue(OutputInternal<String> o) {
113+
try {
114+
return o.getValueOrDefault("").get();
115+
} catch (InterruptedException | ExecutionException e) {
116+
throw new RuntimeException(e);
117+
}
118+
}
119+
120+
private static ResourceArgs makeArgs(@Nullable CustomResourceArgsBase args) {
121+
if (args == null) {
122+
return null;
123+
}
124+
if (args.otherFields().isEmpty() || args.otherFields().get().isEmpty()) {
125+
// optimization: if there are no "other" fields, we can just return the args as-is.
126+
return args;
127+
}
128+
return Util.generateResourceArgs(args, args.otherFields().get());
129+
}
130+
131+
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(
132+
@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
133+
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
134+
.version(Utilities.getVersion())
135+
.build();
136+
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
137+
}
138+
139+
/**
140+
* Get the state of an existing `CustomResource` resource, as identified by `id`.
141+
* Typically this ID is of the form [namespace]/[name]; if [namespace] is omitted,
142+
* then (per Kubernetes convention) the ID becomes default/[name].
143+
*
144+
* @param name The _unique_ name of the resulting resource.
145+
* @param apiVersion The API version of the CustomResource we wish to select, as defined by the CRD.
146+
* @param kind The kind of the CustomResource we wish to select, as defined by the CRD.
147+
* @param id An ID for the Kubernetes resource to retrieve.
148+
* @param options Optional settings to control the behavior of the CustomResource.
149+
*/
150+
public static CustomResource get(String name, String apiVersion, String kind, Output<String> id,
151+
@Nullable com.pulumi.resources.CustomResourceOptions options) {
152+
return new CustomResource(name, apiVersion, kind, id, options);
153+
}
154+
}

sdk/java/src/main/java/com/pulumi/kubernetes/apiextensions/CustomResourceArgs.java

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// *** WARNING: this file was generated by pulumi-java-gen. ***
2+
// *** Do not edit by hand unless you're certain you know what you are doing! ***
3+
4+
package com.pulumi.kubernetes.apiextensions;
5+
6+
/**
7+
* The set of arguments for constructing a CustomResource resource.
8+
*
9+
* NOTE: This type is fairly loose, since other than `apiVersion` and `kind`,
10+
* there are no fields required across all CRDs. Use otherFields(...) to specify
11+
* additional fields.
12+
*/
13+
public final class CustomResourceArgs extends CustomResourceArgsBase {
14+
15+
public static final CustomResourceArgs Empty = new CustomResourceArgs();
16+
17+
public static Builder builder() {
18+
return new Builder();
19+
}
20+
21+
public static Builder builder(CustomResourceArgs defaults) {
22+
return new Builder(defaults);
23+
}
24+
25+
public static final class Builder extends CustomResourceArgsBase.Builder<CustomResourceArgs, Builder> {
26+
public Builder() {
27+
super(new CustomResourceArgs());
28+
}
29+
30+
public Builder(CustomResourceArgs defaults) {
31+
super(new CustomResourceArgs(), defaults);
32+
}
33+
}
34+
}

sdk/java/src/main/java/com/pulumi/kubernetes/apiextensions/CustomResourceArgsBase.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)