Skip to content

Commit

Permalink
Don't require names for anything that looks like a list
Browse files Browse the repository at this point in the history
  • Loading branch information
hausdorff committed Nov 24, 2018
1 parent 067ef8a commit 5ed7938
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/gen/nodejs-templates/provider.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export namespace yaml {

// Flatten `v1.List`. `v1.List` is an undocumented Kubernetes resource, and does not appear
// in the Kubernetes OpenAPI spec. `kubectl`, ksonnet, and Helm all flatten it.
if (apiVersion == "v1" && kind == "List") {
if ((apiVersion == "v1" && kind == "List") || ("items" in obj && !("metadata" in obj) || !("name" in obj["metadata"]))) {
const objs = [];
const items = obj["items"] || [];
for (const item of items) {
Expand All @@ -229,7 +229,7 @@ export namespace yaml {
}

if (!("metadata" in obj) || !("name" in obj["metadata"])) {
throw new Error(`YAML object does not have a .metadata.name: ${JSON.stringify(obj)}`)
throw new Error(`YAML object does not have a .metadata.name: ${obj.apiVersion}/${obj.kind} ${JSON.stringify(obj.metadata)}`)
}

const meta = obj["metadata"];
Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ export namespace yaml {

// Flatten `v1.List`. `v1.List` is an undocumented Kubernetes resource, and does not appear
// in the Kubernetes OpenAPI spec. `kubectl`, ksonnet, and Helm all flatten it.
if (apiVersion == "v1" && kind == "List") {
if ((apiVersion == "v1" && kind == "List") || ("items" in obj && !("metadata" in obj) || !("name" in obj["metadata"]))) {
const objs = [];
const items = obj["items"] || [];
for (const item of items) {
Expand All @@ -2053,7 +2053,7 @@ export namespace yaml {
}

if (!("metadata" in obj) || !("name" in obj["metadata"])) {
throw new Error(`YAML object does not have a .metadata.name: ${JSON.stringify(obj)}`)
throw new Error(`YAML object does not have a .metadata.name: ${obj.apiVersion}/${obj.kind} ${JSON.stringify(obj.metadata)}`)
}

const meta = obj["metadata"];
Expand Down

0 comments on commit 5ed7938

Please sign in to comment.