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

Merge Key Language-Independent Type support for YAML anchor/alias #4215

Closed
RE-codes opened this issue Sep 29, 2021 · 5 comments
Closed

Merge Key Language-Independent Type support for YAML anchor/alias #4215

RE-codes opened this issue Sep 29, 2021 · 5 comments
Labels
area/anchors related to yaml anchors kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@RE-codes
Copy link

RE-codes commented Sep 29, 2021

Describe the bug

Following up on #3675. I have found anchor/alias support improved. However, when using Merge Key Language-Independent Type notation (i.e. <<: *some_anchor) I am presented with this error:

Error: map[string]interface {}{"apiVersion":"apps/v1", "kind":"Deployment", "metadata":map[string]interface {}{"annotations":map[string]interface {}{"annotation1":"annotation1", "annotation2":"annotation2", "annotation3":"annotation3"}, "labels":map[string]interface {}{"app":"myApp", "label1":"label1", "label2":"label2", "label3":"label3"}, "name":"myApp", "namespace":"app-namespace"}, "spec":map[string]interface {}{"replicas":3, "selector":map[string]interface {}{"matchLabels":map[string]interface {}{"app":"myApp"}}, "template":map[string]interface {}{"copy-of-metadata":map[string]interface {}{"annotations":map[string]interface {}{"annotation1":"annotation1", "annotation2":"annotation2", "annotation3":"annotation3"}, "labels":map[string]interface {}{"app":"myApp", "label1":"label1", "label2":"label2", "label3":"label3"}, "name":"myApp", "namespace":"app-namespace"}, "metadata":map[string]interface {}{"annotations":map[interface {}]interface {}{"annotation1":"annotation1", "annotation2":"annotation2", "annotation3":"annotation3", "annotation4":"annotation4"}, "labels":map[string]interface {}{"app":"myApp", "label1":"label1", "label2":"label2", "label3":"label3"}, "name":"myApp", "namespace":"app-namespace"}, "spec":map[string]interface {}{"containers":[]interface {}{map[string]interface {}{"image":"some-registry/some-namespace/myApp:latest", "name":"myApp"}}, "imagePullSecrets":[]interface {}{map[string]interface {}{"name":"some_secret"}}}}}}: json: unsupported type: map[interface {}]interface {}

Files that can reproduce the issue

kustomization.yaml

resources:
- test-deployment.yaml

test-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata: &meta
  name: &name myApp
  namespace: &ns app-namespace
  annotations: &annotations
    annotation1: annotation1
    annotation2: annotation2
    annotation3: annotation3
  labels: &labels
    app: *name
    label1: label1
    label2: label2
    label3: label3
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myApp
  template:
    copy-of-metadata: *meta
    metadata: 
      name: *name
      namespace: *ns
      labels: *labels
      annotations:
        <<: *annotations
        annotation4: annotation4
    spec:
      imagePullSecrets:
        - name: some_secret
      containers:
        - name: myApp
          image: some-registry/some-namespace/myApp:latest

Expected output

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    annotation1: annotation1
    annotation2: annotation2
    annotation3: annotation3
  labels:
    app: myApp
    label1: label1
    label2: label2
    label3: label3
  name: myApp
  namespace: app-namespace
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myApp
  template:
    copy-of-metadata:
      annotations:
        annotation1: annotation1
        annotation2: annotation2
        annotation3: annotation3
      labels:
        app: myApp
        label1: label1
        label2: label2
        label3: label3
      name: myApp
      namespace: app-namespace
    metadata:
      annotations:
        annotation1: annotation1
        annotation2: annotation2
        annotation3: annotation3
        annotation4: annotation4
      labels:
        app: myApp
        label1: label1
        label2: label2
        label3: label3
      name: myApp
      namespace: app-namespace
    spec:
      containers:
      - image: some-registry/some-namespace/myApp:latest
        name: myApp
      imagePullSecrets:
      - name: some_secret

Actual output

See error message above.

Kustomize version

{Version:kustomize/v4.4.0 GitCommit:63ec6bdb3d737a7c66901828c5743656c49b60e1 BuildDate:2021-09-27T16:13:36Z GoOs:darwin GoArch:amd64}

Platform

macOS Big Sur

Additional context

The same error is noted in #4212.

@RE-codes RE-codes added the kind/bug Categorizes issue or PR as related to a bug. label Sep 29, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 29, 2021
@k8s-ci-robot
Copy link
Contributor

@RE-codes: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@RE-codes RE-codes changed the title Error using [Merge Key Language-Independent Type](https://yaml.org/type/merge.html) support for YAML anchor/alias Error using Merge Key Language-Independent Type support for YAML anchor/alias Sep 29, 2021
@RE-codes RE-codes changed the title Error using Merge Key Language-Independent Type support for YAML anchor/alias Merge Key Language-Independent Type support for YAML anchor/alias Sep 29, 2021
@natasha41575
Copy link
Contributor

@monopole seems related, possibly a duplicate of #4212. Could you take a look?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 28, 2021
@natasha41575
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 30, 2021
@natasha41575 natasha41575 added area/anchors related to yaml anchors anchors triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. anchors labels Dec 30, 2021
@KnVerey
Copy link
Contributor

KnVerey commented Mar 23, 2022

Closed by #4383

@KnVerey KnVerey closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/anchors related to yaml anchors kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

5 participants