Skip to content

Commit

Permalink
Adapt to Java with string literals (pulumi#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Sep 23, 2022
1 parent 32070d6 commit cc61b6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions gcp-java-gke-hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<properties>
<encoding>UTF-8</encoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<maven.compiler.release>15</maven.compiler.release>
<mainClass>gcpgke.App</mainClass>
<mainArgs/>
</properties>
Expand Down
12 changes: 7 additions & 5 deletions gcp-java-gke-hello-world/src/main/java/gcpgke/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ private static void stack(Context ctx) {
var masterAuthClusterCaCertificate = cluster.masterAuth()
.applyValue(a -> a.clusterCaCertificate().orElseThrow());

var kubeconfig = cluster.endpoint()
.apply(endpoint -> masterAuthClusterCaCertificate.applyValue(
caCert -> MessageFormat.format("""
var yamlTemplate = """
apiVersion: v1,
clusters:,
- cluster:,
Expand All @@ -125,8 +123,12 @@ private static void stack(Context ctx) {
installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
provideClusterInfo: true
"""), clusterName, endpoint, caCert)
));
""";

var kubeconfig = cluster.endpoint()
.apply(endpoint -> masterAuthClusterCaCertificate.applyValue(
caCert -> MessageFormat.format(yamlTemplate, clusterName, endpoint, caCert)));

ctx.export("kubeconfig", kubeconfig);

// Create a Kubernetes provider instance that uses our cluster from above.
Expand Down

0 comments on commit cc61b6c

Please sign in to comment.