Git Product home page Git Product logo

helm-chartsnap's People

Contributors

dependabot[bot] avatar florianrusch avatar github-actions[bot] avatar jlandowner avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

helm-chartsnap's Issues

[Feature] Warning message with indentation error

Hi,
I am writing to request a feature enhancement in your chartsnap plugin. Specifically, I would like the system to generate a warning when the indexing of YAML files is incorrect. For example, this example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
    spec:
      imagePullSecrets:
      - name: {{ .Values.imagePullSecrets }}

Currently, when there is an issue with the indexing of these files, it can lead to unexpected behavior in our application, which is difficult to debug due to the lack of explicit warnings or error messages.

Implementing this feature would greatly improve our ability to identify and resolve issues more efficiently, thereby improving the overall robustness of our application.

I look forward to your positive response. Because this approach, we could resolve a lot of issues in our debugging.

Thank you for all your help.
Best regards,
Sofía

Unknow warning

First of all, thank you so much for this amazing tool.
I'm creating this issue due since several days I'm facing this issue

WARN: failed to recognize a resource. snapshot as Unknown:
---
object:
    apiVersion: helm-chartsnap.jlandowner.dev/v1alpha1
    kind: Unknown
    raw: |
        coalesce.go:286: warning: cannot overwrite table with non table for certificate-exporter.hostPathsExporter.securityContext (map[capabilities:map[drop:[ALL]] readOnlyRootFilesystem:true runAsGroup:0 runAsUser:0])
        coalesce.go:286: warning: cannot overwrite table with non table for certificate-exporter.secretsExporter.securityContext (map[capabilities:map[drop:[ALL]] readOnlyRootFilesystem:true runAsGroup:65534 runAsUser:65534])

I don't know but maybe could be related with the array section
this is my values.yaml:

certificate-exporter:
  exposePerCertificateErrorMetrics: true
  exposeRelativeMetrics: true
  secretsExporter:
    securityContext: []    
  hostPathsExporter:
    securityContext: []

My helm version is 3.14.2

Add CLI options properties in`testSpec`

Support to run cmd without args such as chartsnap -f values.yaml by using the values file like:

testSpec:
  chart: cilium
  additionalArgs: |
    --repo https://helm.cilium.io
    --namespace kube-system
...

Validator integration

@jlandowner thanks for this amazing tool!

I was looking for exactly something like this, because I work in a project with multiple different developers, which all have different levels of experiences with helm and how to write and modify helm charts.

I'm just wondering, if it's somehow possible to also integrate a validator tool to validate the generated yaml code against the kubernetes api. Did you or someone else already thought about something like that? It would be really easy, if the snapshots would be stored as plain yaml files.

Allow defining global dynamic fields rules

Context

I have a use case in which I would like to test multiple test values files located in a single directory (let's say, named tests). For every values file, my Helm chart generates Kubernetes Secrets with dynamically generated data. Secrets are always named the same. Now, to make my tests pass, I need to separately add the same testSpec.dynamicFields to every test values file which is redundant. I would like to be able to define global dynamicFields-like rules that would be used when generating snapshots for every values file in my tests directory.

Expected behavior

It's possible to set a global dynamic fields configuration that is used for every values file. Dynamic fields configuration is used to replace all dynamically generated content with ###DYNAMIC_FIELD### constant when the rule matches an object's field.

Sample command:

 helm chartsnap -c <chart> -f <directory-with-test-values-files> --dynamic-fields-config=./exclude-secrets-data.yaml 

Sample config file (exclude-secrets-data.yaml):

  dynamicFields:
    - apiVersion: v1
      kind: Secret
      name: chartsnap-postgresql
      jsonPath:
        - /data/postgres-password

Alternatively, this could be a config file used by the tool, e.g. .chartsnap.yaml in which the global configuration would be defined (I believe there could be more global settings to tune than just dynamicFields in the future).

Support user-provided fixed value for dynamic field

Option 1

dynamicFields:
  - apiVersion: v1
    kind: Secret
    name: cosmo-auth-env
    jsonPath:
      - /data/COOKIE_HASHKEY
      - /data/COOKIE_BLOCKKEY
      - /data/COOKIE_HASHKEY
      - /data/COOKIE_SESSION_NAME
    base64: true
    value: '###DYNAMIC_FIELD###' # Add

Option 2

dynamicFields:
  - apiVersion: v1
    kind: Secret
    name: cosmo-auth-env
    jsonPath:                         # Support both string and struct array
      - path: /data/COOKIE_HASHKEY    # Change as path property
        value: '###COOKIE_HASHKEY###'
      - path: /data/COOKIE_BLOCKKEY
        value: '###COOKIE_BLOCKKEY###' # This option can set values on each path.

Failed to snapshot helm `required` error output

Hello again,

today I wanted to integrate helm-chartsnap into another project where I discovered an edge case that I'm not sure how to handle.

Let's imagine we have a template that contains the following:

testValue: {{ required "testValue is required" .Values.testValue }}

and a values.yaml that contains the following:

testValue:

Executing helm template and also helm chartsnap -c . would now result in the following "error" message:

Error: execution error at (<TEMPLATE_PATH>.yaml:1:3): testValue is required

The question now is, how should I handle this? I don't want to put a default value in the values.yaml because there is no "default" value as the value always depends on the environment the helm chart will applied to.

One idea would be to provide a separate "default" values.yaml file just for chartsnap. But this feels somehow ugly for me. Also I would need to provide testValue in each of my test values.yaml files which is very repetitive.

Another idea would be to somehow provide these kind of values within the .chartsnap.yaml, but I guess that's not supported at the moment, right?

success even if chart is not found

After #110 chartsnap can take a error output snapshot with success exitcode. But also it unintentionally takes a error snapshot that chart is not found.

It should take only helm's rendering output(including rendering error) and it should exit with errors excluding rendering error.

dynamicFields with / in key

Hi,

I would like to use dynamicFields with kyes which has '/' characters.
Part of the templated yaml:

spec:
    template:
        metadata:
            annotations:
                checksum/values: 30da9af9da506b1fc3aa378d47e2d916f1d62e0e30dda84b25e855053233fd33

This is the .chartignore

dynamicFields:
  - apiVersion: apps/v1
    kind: Deployment
    name: cosmo-auth-env
    jsonPath:
      - /spec/template/metadata/annotaions/checksum/values

I got the following error:

chart=. values=test/test.yaml err=failed to replace json path: failed to replace json path: failed to patch JSON6902: replace operation does not apply: doc is missing path: /spec/template/metadata/annotaions/checksum/values: missing value:

I tried the following escape segments:
/spec/template/metadata/annotaions/"checksum/values"
/spec/template/metadata/annotaions/'checksum/values'
/spec/template/metadata/annotaions/checksum%2Fvalues

None of the worked for me.

How can I escape the / in the key character?

Thank you for your help!

Take an empty snapshot for empty Helm output

My default values for my chart do not produce any manifests. I have templates in there but they are all guarded by if statements.

helm chartsnap -c charts/project -u
 RUNS  Snapshot testing chart=charts/project values=
 FAIL  chart=charts/ace-project values= err=failed to encode manifests: failed to close encoder: yaml: expected STREAM-START
time=2024-04-09T14:12:24.545-04:00 level=ERROR msg="failed to get snapshot chart=charts/project values=: failed to encode manifests: failed to close encoder: yaml: expected STREAM-START"
Error: plugin "chartsnap" exited with error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.