Use random namespace for helm example to allow test parallelism
-// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
+// Copyright 2016-2019, Pulumi Corporation.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
import * as k8s from "@pulumi/kubernetes";
+import * as pulumi from "@pulumi/pulumi";
+
+const namespace = new k8s.core.v1.Namespace("test");
+const namespaceName = namespace.metadata.apply(metadata => metadata.name);
const nginx = new k8s.helm.v2.Chart("simple-nginx", {
// Represents chart `stable/nginx-lego@v0.3.1`.
@@ -24,13 +40,23 @@ const nginx = new k8s.helm.v2.Chart("simple-nginx", {
obj.spec.type = "ClusterIP";
}
}
+ },
+ // Put every resource in the created namespace.
+ (obj: any) => {
+ if (obj.metadata !== undefined) {
+ obj.metadata.namespace = namespaceName
+ } else {
+ obj.metadata = {namespace: namespaceName}
+ }
}
]
});
+// TODO(levi): Uncomment this once https://github.com/pulumi/pulumi-kubernetes/issues/419 is fixed.
// Export the (cluster-private) IP address of the Guestbook frontend.
-export const frontendClusterIp = nginx.getResourceProperty("v1/Service", "simple-nginx-nginx-lego", "spec")
- .apply(spec => spec.clusterIP);
+// const frontendServiceSpec = pulumi.all([namespaceName, nginx]).apply(([nsName, nginx]) =>
+// nginx.getResourceProperty("v1/Service", nsName, "simple-nginx-nginx-lego", "spec"));
+// export const frontendServiceIP = frontendServiceSpec.apply(spec => spec.clusterIP);
// Test a variety of other inputs on a chart that creates no resources.
const empty1 = new k8s.helm.v2.Chart("empty1", {
