github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/renderer/variables.go (about)

     1  package renderer
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
     7  	"github.com/kubeshop/testkube/pkg/ui"
     8  )
     9  
    10  func RenderVariables(variables testkube.Variables) {
    11  	if len(variables) > 0 {
    12  		ui.NL()
    13  		ui.Warn("  Variables:   ", fmt.Sprintf("%d", len(variables)))
    14  		for _, v := range variables {
    15  			t := ""
    16  			if v.IsSecret() {
    17  				if v.SecretRef != nil {
    18  					t = fmt.Sprintf("[secret:%s key:%s]", v.SecretRef.Name, v.SecretRef.Key)
    19  				}
    20  
    21  				if v.Value != "" {
    22  					t = v.Value
    23  				}
    24  
    25  				t += " 🔒"
    26  			} else {
    27  				if v.ConfigMapRef != nil {
    28  					t = fmt.Sprintf("[configmap:%s key:%s]", v.ConfigMapRef.Name, v.ConfigMapRef.Key)
    29  				}
    30  
    31  				if v.Value != "" {
    32  					t = v.Value
    33  				}
    34  			}
    35  
    36  			ui.Info("  -", fmt.Sprintf("%s = %s", v.Name, t))
    37  		}
    38  	}
    39  }