Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: infer filtered or function-guarded yaml tool parameter #406

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

Merged

Conversation

mainred
Copy link
Contributor

@mainred mainred commented May 7, 2025

Besides the normal yaml template parameter wrapped by bracket, a valid parameter can also be manipulated by filters appended with dot . or functions appended with vertical bar |.

test the following template will generate command like Running command: kubectl exec -n test-ns dnsutils -- nslookup kubernetes.default.svc.cluster.local

      - name: "exec_on_dns_debug_pod"
        description: "Run a command inside the DNS debugging pod"
        command: "kubectl exec -n {{namespace|trim}} {{ pod_name }} -- {{ command.strip(\"'\") }}"

NOTE, {{namespace|trim}} has no practical use, and is for test only.

@mainred
Copy link
Contributor Author

mainred commented May 7, 2025

AFAIK, there's off-the-shelf function to find all variables defined in a jinja2 template, though we can easily use jinja2.use meta.find_undeclared_variables() to get undeclared variables.

@mainred
Copy link
Contributor Author

mainred commented May 7, 2025

quoting the command using kubectl exec will raise error.
image

Copy link
Contributor

@arikalon1 arikalon1 left a comment

Choose a reason for hiding this comment

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

thanks for the fix @mainred , nice work

@arikalon1 arikalon1 merged commit eeae65d into robusta-dev:master May 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants