Skip to content

Export fails when no name is present #135

@michaelsauter

Description

@michaelsauter

E.g. tailor export rolebinding -n foo-dev might fail with:

2019/10/07 16:06:03 Could not export Kinds: [RoleBinding], Name: , Label: , ExcludedKinds: [], ExcludedNames: [], ExcludedLabels: [] resources as template: Could not parse object of exported template: Object has no key 'name'

The reason is that

namePointer, _ := gojsonpointer.NewJsonPointer("/metadata/name")
name, _, err := namePointer.Get(m)
if err != nil {
return err
}
expects /metadata/name to exist, however some resources might not have it, e.g.:

- apiVersion: authorization.openshift.io/v1
  groupNames: null
  kind: RoleBinding
  metadata:
    creationTimestamp: null
    generateName: system:image-pusher-
  roleRef:
    name: system:image-pusher
  subjects:
  - kind: ServiceAccount
    name: default
    namespace: foo-dev
  userNames:
  - system:serviceaccount:foo-dev:default

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions