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(cli): handle multi-resource yaml in offline lint. Fixes #12137 #13531

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wang-wayne
Copy link

@wang-wayne wang-wayne commented Aug 30, 2024

Fixes #12137
Fixes #10608

Motivation

If there are multiple templates in one yaml file. The argo lint --offline can only get the first template.
Because the yaml.Unmarshal function is used to parse a single YAML document.

Modifications

Read yaml file with common.ParseObjects in offline mode.

Verification

e2e test.
argo lint --offline test.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-template-local-arg-1
spec:
  templates:
    - name: hello-world
      inputs:
        parameters:
          - name: msg
            value: "hello world"
      container:
        image: docker/whalesay
        command: [cowsay]
        args: ["{{inputs.parameters.msg}}"]
---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-template-local-arg-2
spec:
  templates:
    - name: hello-world
      inputs:
        parameters:
          - name: msg
            value: "hello world"
      container:
        image: docker/whalesay
        command: [cowsay]
        args: ["{{inputs.parameters.msg}}"]
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-local-arg-
spec:
  entrypoint: whalesay
  templates:
    - name: whalesay
      steps:
        - - name: hello-world
            templateRef:
              name: hello-world-template-local-arg-2
              template: hello-world

Add unittest case.

Signed-off-by: Wang, Wayne <Wayne.Wang@fmr.com>
@agilgur5 agilgur5 changed the title fix: Fixed argo lint offline issue on multi-documents yaml. Fixes #12137 fix(cli): handle multi-resource yaml in offline lint. Fixes #12137 Aug 30, 2024
@agilgur5 agilgur5 added the area/cli The `argo` CLI label Aug 30, 2024
@kayhern kayhern force-pushed the fix-argo-lint-offline-issue-on-multi-documents-yaml-file branch from 693db02 to 70c5e90 Compare August 30, 2024 13:46
@agilgur5
Copy link
Member

@miltalex do you want to try reviewing this? Since you've worked on argo lint before

@agilgur5 agilgur5 requested a review from miltalex August 31, 2024 23:21
@agilgur5
Copy link
Member

I'm curious if this also fixes #10608?

@miltalex
Copy link
Member

miltalex commented Sep 1, 2024

@miltalex do you want to try reviewing this? Since you've worked on argo lint before

I would be happy to review it

@wang-wayne
Copy link
Author

wang-wayne commented Sep 6, 2024

I'm curious if this also fixes #10608?

@agilgur5 Yes, I had a validation. This PR also fixes #10608.

@wang-wayne
Copy link
Author

@miltalex do you want to try reviewing this? Since you've worked on argo lint before

I would be happy to review it

Hi @miltalex , thank you for reviewing my PR! Do you have any comments or suggestions to share? I would appreciate any feedback you might have. Thank you!

Copy link
Member

@miltalex miltalex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you very much for submitting the fix. I have a small stylistic suggestion otherwise LGTM

cmd/argo/commands/lint_test.go Outdated Show resolved Hide resolved
cmd/argo/commands/lint_test.go Outdated Show resolved Hide resolved
Signed-off-by: Wang, Wayne <Wayne.Wang@fmr.com>
Signed-off-by: Wang, Wayne <Wayne.Wang@fmr.com>
@miltalex
Copy link
Member

/retest

@miltalex miltalex self-requested a review September 26, 2024 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli The `argo` CLI
Projects
None yet
3 participants