Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plus-17): L2 default child #389

Merged
merged 16 commits into from
Nov 18, 2020
Merged
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 @@ -46,7 +46,7 @@ Array [
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": Object {
"name": "test-chart-deployment-c5d38cbe",
"name": "test-chart-deployment-e606f14e",
},
"spec": Object {
"replicas": 1,
Expand Down Expand Up @@ -99,7 +99,7 @@ Array [
"volumeMounts": Array [
Object {
"mountPath": "/root",
"name": "configmap-test-chart-config-configmap-233db8e7",
"name": "configmap-test-chart-config-c3f7d3c0",
},
],
"workingDir": "/root",
Expand All @@ -108,9 +108,9 @@ Array [
"volumes": Array [
Object {
"configMap": Object {
"name": "test-chart-config-configmap-233db8e7",
"name": "test-chart-config-c3f7d3c0",
},
"name": "configmap-test-chart-config-configmap-233db8e7",
"name": "configmap-test-chart-config-c3f7d3c0",
},
],
},
Expand All @@ -121,7 +121,7 @@ Array [
"apiVersion": "v1",
"kind": "Service",
"metadata": Object {
"name": "test-chart-deployment-service-pod-28e7837f",
"name": "test-chart-deployment-service-7f4c5401",
},
"spec": Object {
"externalIPs": Array [],
Expand Down Expand Up @@ -210,7 +210,7 @@ function doSearch(uri, callback) {
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-chart-config-configmap-233db8e7",
"name": "test-chart-config-c3f7d3c0",
},
},
]
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/config-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ConfigMap extends Resource implements IConfigMap {
public constructor(scope: Construct, id: string, props: ConfigMapProps = { }) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubeConfigMap(this, 'ConfigMap', {
this.apiObject = new k8s.KubeConfigMap(this, 'Resource', {
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
metadata: props.metadata,

// we need lazy here because we filter empty
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Deployment extends Resource implements IPodTemplate {
constructor(scope: Construct, id: string, props: DeploymentProps = {}) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubeDeployment(this, 'Deployment', {
this.apiObject = new k8s.KubeDeployment(this, 'Resource', {
metadata: props.metadata,
spec: Lazy.any({ produce: () => this._toKube() }),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/ingress-v1beta1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class IngressV1Beta1 extends Resource {
constructor(scope: Construct, id: string, props: IngressV1Beta1Props = {}) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubeIngressV1Beta1(this, 'Ingress', {
this.apiObject = new k8s.KubeIngressV1Beta1(this, 'Resource', {
metadata: props.metadata,
spec: {
backend: Lazy.any({ produce: () => this._defaultBackend?._toKube() }),
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Job extends Resource implements IPodTemplate {
constructor(scope: Construct, id: string, props: JobProps = {}) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubeJob(this, 'Default', {
this.apiObject = new k8s.KubeJob(this, 'Resource', {
metadata: props.metadata,
spec: Lazy.any({ produce: () => this._toKube() }),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class Pod extends Resource implements IPodSpec {
constructor(scope: Construct, id: string, props: PodProps = {}) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubePod(this, 'Pod', {
this.apiObject = new k8s.KubePod(this, 'Resource', {
metadata: props.metadata,
spec: Lazy.any({ produce: () => this._spec._toPodSpec() }),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Secret extends Resource implements ISecret {

this.stringData = props.stringData ?? {};

this.apiObject = new k8s.KubeSecret(this, 'Secret', {
this.apiObject = new k8s.KubeSecret(this, 'Resource', {
metadata: props.metadata,
stringData: this.stringData,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk8s-plus-17/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Service extends Resource {
constructor(scope: Construct, id: string, props: ServiceProps = {}) {
super(scope, id, { metadata: props.metadata });

this.apiObject = new k8s.KubeService(this, 'Pod', {
this.apiObject = new k8s.KubeService(this, 'Resource', {
metadata: props.metadata,
spec: cdk8s.Lazy.any({ produce: () => this._toKube() }),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Array [
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-my-config-map-configmap-d0fa5644",
"name": "test-my-config-map-91419662",
},
},
]
Expand All @@ -25,7 +25,7 @@ Array [
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-my-config-map-configmap-d0fa5644",
"name": "test-my-config-map-91419662",
},
},
]
Expand All @@ -41,7 +41,7 @@ Array [
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-my-config-map-configmap-d0fa5644",
"name": "test-my-config-map-91419662",
},
},
]
Expand All @@ -56,7 +56,7 @@ Array [
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-my-config-map-configmap-d0fa5644",
"name": "test-my-config-map-91419662",
},
},
]
Expand All @@ -72,7 +72,7 @@ Array [
},
"kind": "ConfigMap",
"metadata": Object {
"name": "test-my-config-map-configmap-d0fa5644",
"name": "test-my-config-map-91419662",
},
},
]
Expand Down
23 changes: 17 additions & 6 deletions packages/cdk8s-plus-17/test/config-map.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Testing } from 'cdk8s';
import { Testing, ApiObject } from 'cdk8s';
import { Node } from 'constructs';
import { ConfigMap } from '../src';

test('defaultChild', () => {

const chart = Testing.chart();

const defaultChild = Node.of(new ConfigMap(chart, 'ConfigMap')).defaultChild as ApiObject;

expect(defaultChild.kind).toEqual('ConfigMap');

});

test('minimal', () => {
// GIVEN
const chart = Testing.chart();
Expand All @@ -14,7 +25,7 @@ test('minimal', () => {
apiVersion: 'v1',
kind: 'ConfigMap',
metadata: {
name: 'test-my-config-map-configmap-d0fa5644',
name: 'test-my-config-map-91419662',
},
},
]);
Expand Down Expand Up @@ -42,7 +53,7 @@ test('with data', () => {
key2: 'bar',
},
metadata: {
name: 'test-my-config-map-configmap-d0fa5644',
name: 'test-my-config-map-91419662',
},
},
]);
Expand Down Expand Up @@ -70,7 +81,7 @@ test('with binaryData', () => {
key2: 'bar',
},
metadata: {
name: 'test-my-config-map-configmap-d0fa5644',
name: 'test-my-config-map-91419662',
},
},
]);
Expand Down Expand Up @@ -104,7 +115,7 @@ test('with binaryData and data', () => {
key2: 'bar',
},
metadata: {
name: 'test-my-config-map-configmap-d0fa5644',
name: 'test-my-config-map-91419662',
},
},
]);
Expand Down Expand Up @@ -163,7 +174,7 @@ test('addData()/addBinaryDataq() can be used to add data', () => {
},
kind: 'ConfigMap',
metadata: {
name: 'test-my-config-map-configmap-d0fa5644',
name: 'test-my-config-map-91419662',
},
},
]);
Expand Down
13 changes: 12 additions & 1 deletion packages/cdk8s-plus-17/test/deployment.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { Testing } from 'cdk8s';
import { Testing, ApiObject } from 'cdk8s';
import { Node } from 'constructs';
import * as kplus from '../src';

test('defaultChild', () => {
iliapolo marked this conversation as resolved.
Show resolved Hide resolved

const chart = Testing.chart();

const defaultChild = Node.of(new kplus.Deployment(chart, 'Deployment')).defaultChild as ApiObject;

expect(defaultChild.kind).toEqual('Deployment');

});

test('A label selector is automatically allocated', () => {

const chart = Testing.chart();
Expand Down
Loading