github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/modules/helm/rollback.go (about)

     1  package helm
     2  
     3  import (
     4  	"github.com/gruntwork-io/terratest/modules/testing"
     5  	"github.com/stretchr/testify/require"
     6  )
     7  
     8  // Rollback will downgrade the release to the specified version. This will fail
     9  // the test if there is an error.
    10  func Rollback(t testing.TestingT, options *Options, releaseName string, revision string) {
    11  	require.NoError(t, RollbackE(t, options, releaseName, revision))
    12  }
    13  
    14  // RollbackE will downgrade the release to the specified version
    15  func RollbackE(t testing.TestingT, options *Options, releaseName string, revision string) error {
    16  	var err error
    17  	args := []string{}
    18  	if options.ExtraArgs != nil {
    19  		if rollbackArgs, ok := options.ExtraArgs["rollback"]; ok {
    20  			args = append(args, rollbackArgs...)
    21  		}
    22  	}
    23  	args = append(args, releaseName)
    24  	if revision != "" {
    25  		args = append(args, revision)
    26  	}
    27  	_, err = RunHelmCommandAndGetOutputE(t, options, "rollback", args...)
    28  	return err
    29  }