...

Source file src/github.com/redhat-developer/odo/tests/helper/component_interface.go

Documentation: github.com/redhat-developer/odo/tests/helper

     1  package helper
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo/v2"
     5  	batchv1 "k8s.io/api/batch/v1"
     6  	corev1 "k8s.io/api/core/v1"
     7  )
     8  
     9  // Component is an abstraction for a Devfile Component deployed on a specific platform
    10  type Component interface {
    11  	// ExpectIsDeployed checks that the component is deployed
    12  	ExpectIsDeployed()
    13  	// ExpectIsNotDeployed checks that the component is not deployed
    14  	ExpectIsNotDeployed()
    15  	// Exec executes the command in specific container of the component.
    16  	// If expectedSuccess is nil, the command is just supposed to run, with no assertion on its exit code.
    17  	// If *expectedSuccess is true, the command exit code is expected to be 0.
    18  	// If *expectedSuccess is false, the command exit code is expected to be non-zero.
    19  	Exec(container string, args []string, expectedSuccess *bool) (string, string)
    20  	// GetEnvVars returns the environment variables defined for the container
    21  	GetEnvVars(container string) map[string]string
    22  	// GetLabels returns the labels defined for the component
    23  	GetLabels() map[string]string
    24  	// GetAnnotations returns the annotations defined for the component
    25  	GetAnnotations() map[string]string
    26  	// GetPodDef returns the definition of the pod
    27  	GetPodDef() *corev1.Pod
    28  	// GetJobDef returns the definition of the job
    29  	GetJobDef() *batchv1.Job
    30  	// GetPodLogs returns logs for the pod
    31  	GetPodLogs() string
    32  }
    33  
    34  func NewComponent(componentName string, app string, mode string, namespace string, cli CliRunner) Component {
    35  	if NeedsCluster(CurrentSpecReport().Labels()) {
    36  		return NewClusterComponent(componentName, app, mode, namespace, cli)
    37  	} else {
    38  		return NewPodmanComponent(componentName, app)
    39  	}
    40  }
    41  

View as plain text