Skip to content

Proposal: Generate expected yaml from a command #552

Open
@gmolau

Description

Hi everyone, what do you think of making it possible to generate the expected yaml from a command? Currently there are two ways of writing the expected state:

  1. Directly in yaml
  2. Together with an assertion in a script

My use case is a controller that installs Helm charts, where I would like to make assertions against the helm status output. Since that output does not live on a cluster I currently have to write a script like this:


apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
  - script: |
      expectedNamespace=test-chart
      expectedRelease=test-chart
      expectedStatus=deployed
      
      helmStatus=$(helm status -n $expectedNamespace $expectedRelease)
      if [ $? -ne 0 ]; then
        echo "Failed to get Helm release status for $expectedRelease in namespace $expectedNamespace"
        exit 1
      fi
      
      status=$(echo "$helmStatus" | grep STATUS | awk '{print $2}')
      
      if [ "$status" != "$expectedStatus" ]; then
        echo "Expected Helm release $expectedRelease in namespace $expectedNamespace to have status '$expectedStatus', but got '$status'"
        exit 1
      fi

It would be much nicer if I could give a command that produces a yaml and an expected yaml, then rely on Kuttls internal machinery to compare the two. E.g. something like:

expected:
  status: deployed
actual: helm status -o yaml

Do you think it would be possible to add something like this? And if so, what would be the best way to implement it?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions