Skip to content

"Remove Metadata Clutter" doesn't preseve order of resources, adds namespaces and turns "---" into "------" #818

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

Closed
adietish opened this issue Jan 27, 2025 · 1 comment · Fixed by #819
Assignees
Milestone

Comments

@adietish
Copy link
Collaborator

adietish commented Jan 27, 2025

related to:

follows up on:

Steps:

  1. EXEC: have the following in an editor:
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  name: "numberguess"
  labels:
    jedi: yoda
spec:
  replicas: 2
  selector:
    matchLabels:
      app: "numberguess"
  template:
    metadata:
      labels:
        app: "numberguess"
    spec:
      containers:
      - name: "my-numberguess"
        image: "numberguess:latest"
        ports:
        - name: "http"
          containerPort: 8081
          protocol: "TCP"
        resources:
          limits:
            memory: "1024Mi"
            cpu: "500m"
---
apiVersion: "v1"
kind: "Service"
metadata:
  name: "numberguess-svc-22"
spec:
  ports:
  - name: "http-8081"
    port: 8081
    protocol: "TCP"
    targetPort: 8081
  selector:
    app: "numberguess"
  1. EXEC: click "Remove Metadata Clutter in Editor" in the toolbar (most right icon in the toolbar)

Result:

  1. the document now has the Service before the Deployment
  2. the Service and the Deployment, both get a namespace property added (which they didnt have before):
namespace: XXXX
  1. the separator --- is now ------ which makes the whole document marked with errors
---
apiVersion: "v1"
kind: "Service"
metadata:
  name: "numberguess-svc-22"
  namespace: "adietish-dev"
spec:
  ports:
  - name: "http-8081"
    port: 8081
    protocol: "TCP"
    targetPort: 8081
  selector:
    app: "numberguess"
------
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  labels:
    jedi: "yoda"
  name: "numberguess"
  namespace: "adietish-dev"
spec:
  replicas: 2
  selector:
    matchLabels:
      app: "numberguess"
  template:
    metadata:
      labels:
        app: "numberguess"
    spec:
      containers:
      - name: "my-numberguess"
        image: "numberguess:latest"
        ports:
        - name: "http"
          containerPort: 8081
          protocol: "TCP"
        resources:
          limits:
            memory: "1024Mi"
            cpu: "500m"
@adietish
Copy link
Collaborator Author

adietish commented Jan 27, 2025

the doubling of the separator --- is caused by the new way kubernetes-client is serializing resources to yaml. It is automatically inserting --- to the start of a resource when serializing it:

https://github.com/fabric8io/kubernetes-client/blob/ab342028411402bc6b584e03f41023625038b8e2/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/KubernetesSerialization.java#L190-L192

  public <T> String asYaml(T object) {
    DumpSettings settings = DumpSettings.builder()
==>     .setExplicitStart(true)
        .setDefaultFlowStyle(FlowStyle.BLOCK).build();

setExplicitStart(boolean)) that's used when constructing the DumpingSettings is javadoc'ed with

Add '---' in the beginning of the document

We can therefore drop explicitly inserting that.

adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 27, 2025
@adietish adietish added this to the 1.5.0 milestone Jan 27, 2025
@adietish adietish self-assigned this Jan 27, 2025
@adietish adietish moved this to 📝 In Progress in IDE Cloudaptors Jan 27, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 27, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
@adietish adietish moved this from 📝 In Progress to 👀 In review in IDE Cloudaptors Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit to adietish/intellij-kubernetes that referenced this issue Jan 28, 2025
adietish added a commit that referenced this issue Jan 28, 2025
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in IDE Cloudaptors Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant