Documentation ¶
Index ¶
- Constants
- func AddFinalizerToComponent(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func AddFinalizerToPipelineRun(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func GetIntegrationTestTaskResultsFromPipelineRunWithChildReferences(ctx context.Context, adapterClient client.Client, ...) (map[string]*IntegrationTestTaskResult, error)
- func HandleLoaderError(logger IntegrationLogger, err error, resource, from string) (ctrl.Result, error)
- func HasPipelineRunFinished(object client.Object) bool
- func HasPipelineRunSucceeded(object client.Object) bool
- func IsEnvironmentNotInNamespaceError(err error) bool
- func IsInvalidImageDigestError(err error) bool
- func IsMissingInfoInPipelineRunError(err error) bool
- func IsMissingValidComponentError(err error) bool
- func IsObjectYoungerThanThreshold(obj metav1.Object, threshold time.Duration) bool
- func IsScenarioValid(scenario *v1beta2.IntegrationTestScenario) bool
- func IsUnrecoverableMetadataError(err error) bool
- func MissingInfoInPipelineRunError(pipelineRunName, paramName string) error
- func NewEnvironmentNotInNamespaceError(environment, namespace string) error
- func NewInvalidImageDigestError(componentName, image_digest string) error
- func NewMissingValidComponentError(componentName string) error
- func NewUnrecoverableMetadataError(msg string) error
- func RemoveFinalizerFromAllIntegrationPipelineRunsOfSnapshot(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func RemoveFinalizerFromComponent(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func RemoveFinalizerFromPipelineRun(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func RemoveFinalizerFromScenario(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, ...) error
- func SetScenarioIntegrationStatusAsInvalid(scenario *v1beta2.IntegrationTestScenario, message string)
- func SetScenarioIntegrationStatusAsValid(scenario *v1beta2.IntegrationTestScenario, message string)
- type AppStudioTestResult
- type IntegrationError
- type IntegrationLogger
- type IntegrationPipelineRunOutcome
- func (ipro *IntegrationPipelineRunOutcome) GetValidationErrorsList() []string
- func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunPassedTesting() bool
- func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunSucceeded() bool
- func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunValidTestOutputs() bool
- func (ipro *IntegrationPipelineRunOutcome) LogResults(logger logr.Logger)
- type IntegrationTestTaskResult
- type LogAction
- type SortTaskRunsByStartTime
- type TaskRun
Constants ¶
const ( ReasonEnvironmentNotInNamespace = "EnvironmentNotInNamespace" ReasonMissingInfoInPipelineRunError = "MissingInfoInPipelineRunError" ReasonInvalidImageDigestError = "InvalidImageDigest" ReasonMissingValidComponentError = "MissingValidComponentError" ReasonUnknownError = "UnknownError" ReasonUnrecoverableMetadataError = "UnrecoverableMetadataError" )
const ( //TestOutputName is the name of the standardized Test output Tekton task result TestOutputName = "TEST_OUTPUT" //LegacyTestOutputName is the previous name of the standardized AppStudio Test output Tekton task result LegacyTestOutputName = "HACBS_TEST_OUTPUT" // AppStudioTestOutputSuccess is the result that's set when the AppStudio test succeeds. AppStudioTestOutputSuccess = "SUCCESS" // AppStudioTestOutputFailure is the result that's set when the AppStudio test fails. AppStudioTestOutputFailure = "FAILURE" // AppStudioTestOutputWarning is the result that's set when the AppStudio test passes with a warning. AppStudioTestOutputWarning = "WARNING" // AppStudioTestOutputSkipped is the result that's set when the AppStudio test gets skipped. AppStudioTestOutputSkipped = "SKIPPED" // AppStudioTestOutputError is the result that's set when the AppStudio test produces an error. AppStudioTestOutputError = "ERROR" )
const ( // IntegrationTestScenarioValid is the condition for marking the AppStudio integration status of the Scenario. IntegrationTestScenarioValid = "IntegrationTestScenarioValid" // AppStudioIntegrationStatusInvalid is the reason that's set when the AppStudio integration gets into an invalid state. AppStudioIntegrationStatusInvalid = "Invalid" // AppStudioIntegrationStatusValid is the reason that's set when the AppStudio integration gets into an valid state. AppStudioIntegrationStatusValid = "Valid" )
const ComponentFinalizer string = "test.appstudio.openshift.io/component"
const CreateSnapshotAnnotationName = "test.appstudio.openshift.io/create-snapshot-status"
const IntegrationPipelineRunFinalizer string = "test.appstudio.openshift.io/pipelinerun"
IntegrationPipelineRunFinalizer is the finalizer name to be added to the Integration PipelineRuns
const IntegrationTestScenarioFinalizer string = "test.appstudio.openshift.io/scenario"
Variables ¶
This section is empty.
Functions ¶
func AddFinalizerToComponent ¶
func AddFinalizerToComponent(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, component *applicationapiv1alpha1.Component, finalizer string) error
AddFinalizerToComponent adds the finalizer to the component. If finalizer was not added successfully, a non-nil error is returned.
func AddFinalizerToPipelineRun ¶
func AddFinalizerToPipelineRun(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, pipelineRun *tektonv1.PipelineRun, finalizer string) error
AddFinalizerToPipelineRun adds the finalizer to the PipelineRun. If finalizer was not added successfully, a non-nil error is returned.
func GetIntegrationTestTaskResultsFromPipelineRunWithChildReferences ¶
func GetIntegrationTestTaskResultsFromPipelineRunWithChildReferences(ctx context.Context, adapterClient client.Client, pipelineRun *tektonv1.PipelineRun) (map[string]*IntegrationTestTaskResult, error)
GetIntegrationTestTaskResultsFromPipelineRunWithChildReferences finds all TaskRuns from childReferences of the PipelineRun that also contain a TEST_OUTPUT result and returns the parsed data or validation error returns map taskName: result
func HandleLoaderError ¶
func HasPipelineRunFinished ¶
HasPipelineRunFinished returns a boolean indicating whether the PipelineRun finished or not. If the object passed to this function is not a PipelineRun, the function will return false.
func HasPipelineRunSucceeded ¶
HasPipelineRunSucceeded returns a boolean indicating whether the PipelineRun succeeded or not. If the object passed to this function is not a PipelineRun, the function will return false.
func IsScenarioValid ¶
func IsScenarioValid(scenario *v1beta2.IntegrationTestScenario) bool
IsScenarioValid sets the IntegrationTestScenarioValid integration status condition for the Scenario to valid.
func RemoveFinalizerFromAllIntegrationPipelineRunsOfSnapshot ¶
func RemoveFinalizerFromAllIntegrationPipelineRunsOfSnapshot(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, snapshot applicationapiv1alpha1.Snapshot, finalizer string) error
RemoveFinalizerFromAllIntegrationPipelineRunsOfSnapshot fetches all the Integration PipelineRuns associated with the given Snapshot. After fetching them, it removes the finalizer from the PipelineRun, and returns error if any.
func RemoveFinalizerFromComponent ¶
func RemoveFinalizerFromComponent(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, component *applicationapiv1alpha1.Component, finalizer string) error
RemoveFinalizerFromComponent removes the finalizer from the Component. If finalizer was not removed successfully, a non-nil error is returned.
func RemoveFinalizerFromPipelineRun ¶
func RemoveFinalizerFromPipelineRun(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, pipelineRun *tektonv1.PipelineRun, finalizer string) error
RemoveFinalizerFromPipelineRun removes the finalizer from the PipelineRun. If finalizer was not removed successfully, a non-nil error is returned.
func RemoveFinalizerFromScenario ¶
func RemoveFinalizerFromScenario(ctx context.Context, adapterClient client.Client, logger IntegrationLogger, scenario *v1beta2.IntegrationTestScenario, finalizer string) error
RemoveFinalizerFromScenario removes the finalizer from the IntegrationTestScenario. If finalizer was not removed successfully, a non-nil error is returned.
func SetScenarioIntegrationStatusAsInvalid ¶
func SetScenarioIntegrationStatusAsInvalid(scenario *v1beta2.IntegrationTestScenario, message string)
SetScenarioIntegrationStatusAsInvalid sets the IntegrationTestScenarioValid status condition for the Scenario to invalid.
func SetScenarioIntegrationStatusAsValid ¶
func SetScenarioIntegrationStatusAsValid(scenario *v1beta2.IntegrationTestScenario, message string)
SetScenarioIntegrationStatusAsValid sets the IntegrationTestScenarioValid integration status condition for the Scenario to valid.
Types ¶
type AppStudioTestResult ¶
type AppStudioTestResult struct { Result string `json:"result"` Namespace string `json:"namespace"` Timestamp string `json:"timestamp"` Note string `json:"note"` Successes int `json:"successes"` Failures int `json:"failures"` Warnings int `json:"warnings"` }
AppStudioTestResult matches AppStudio TaskRun result contract
type IntegrationError ¶
func (*IntegrationError) Error ¶
func (ie *IntegrationError) Error() string
type IntegrationLogger ¶
func (*IntegrationLogger) LogAuditEvent ¶
func (il *IntegrationLogger) LogAuditEvent(msg string, obj runtime.Object, action LogAction, keysAndValues ...interface{})
LogAuditEvent should be used for auditable events to log all required metadata msg is a user friendly log message obj is k8s runtime object audit action type and any extra keyAndValues being passed to logger
func (IntegrationLogger) WithApp ¶
func (il IntegrationLogger) WithApp(app applicationapiv1alpha1.Application) IntegrationLogger
WithApp returns a new logger with application namespacedName key-value
type IntegrationPipelineRunOutcome ¶
type IntegrationPipelineRunOutcome struct {
// contains filtered or unexported fields
}
IntegrationPipelineRunOutcome is struct for pipeline outcome metadata
func GetIntegrationPipelineRunOutcome ¶
func GetIntegrationPipelineRunOutcome(ctx context.Context, adapterClient client.Client, pipelineRun *tektonv1.PipelineRun) (*IntegrationPipelineRunOutcome, error)
GetIntegrationPipelineRunOutcome returns the IntegrationPipelineRunOutcome which can be used for further inspection of the results and general outcome This function must be called on the finished pipeline
func (*IntegrationPipelineRunOutcome) GetValidationErrorsList ¶
func (ipro *IntegrationPipelineRunOutcome) GetValidationErrorsList() []string
GetValidationErrorsList returns validation error messages for each invalid task result in a list.
func (*IntegrationPipelineRunOutcome) HasPipelineRunPassedTesting ¶
func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunPassedTesting() bool
HasPipelineRunPassedTesting returns general outcome If any of the tasks with the TEST_OUTPUT result don't have the `result` field set to SUCCESS or SKIPPED, it returns false.
func (*IntegrationPipelineRunOutcome) HasPipelineRunSucceeded ¶
func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunSucceeded() bool
HasPipelineRunSucceeded returns true when pipeline in outcome succeeded
func (*IntegrationPipelineRunOutcome) HasPipelineRunValidTestOutputs ¶
func (ipro *IntegrationPipelineRunOutcome) HasPipelineRunValidTestOutputs() bool
HasPipelineRunValidTestOutputs returns false when we failed to parse results of TEST_OUTPUT in tasks
func (*IntegrationPipelineRunOutcome) LogResults ¶
func (ipro *IntegrationPipelineRunOutcome) LogResults(logger logr.Logger)
LogResults writes tasks names with results into given logger, each task on separate line
type IntegrationTestTaskResult ¶
type IntegrationTestTaskResult struct { TestOutput *AppStudioTestResult ValidationError error }
IntegrationTestTaskResult provides results from integration test task including metadata about validity of results
type SortTaskRunsByStartTime ¶
type SortTaskRunsByStartTime []*TaskRun
SortTaskRunsByStartTime can sort TaskRuns by their start time. It implements sort.Interface.
func (SortTaskRunsByStartTime) Len ¶
func (s SortTaskRunsByStartTime) Len() int
Len returns the length of the slice being sorted.
func (SortTaskRunsByStartTime) Less ¶
func (s SortTaskRunsByStartTime) Less(i int, j int) bool
Less determines if TaskRun in position i started before TaskRun in position j.
func (SortTaskRunsByStartTime) Swap ¶
func (s SortTaskRunsByStartTime) Swap(i int, j int)
Swap switches the position of two elements in the slice.
type TaskRun ¶
type TaskRun struct {
// contains filtered or unexported fields
}
TaskRun is an integration specific wrapper around the status of a Tekton TaskRun.
func GetAllChildTaskRunsForPipelineRun ¶
func GetAllChildTaskRunsForPipelineRun(ctx context.Context, adapterClient client.Client, pipelineRun *tektonv1.PipelineRun) ([]*TaskRun, error)
GetAllChildTaskRunsForPipelineRun finds all Child TaskRuns for a given PipelineRun and returns integration TaskRun wrappers for them sorted by start time.
func NewTaskRunFromTektonTaskRun ¶
func NewTaskRunFromTektonTaskRun(pipelineTaskName string, status *tektonv1.TaskRunStatus) *TaskRun
NewTaskRunFromTektonTaskRun creates and returns am integration TaskRun from the TaskRunStatus.
func (*TaskRun) GetDuration ¶
GetDuration returns the time it took to execute the Task. If the start or end times are unknown, a duration of 0 is returned.
func (*TaskRun) GetPipelineTaskName ¶
GetPipelineTaskName returns the name of the PipelineTask.
func (*TaskRun) GetStartTime ¶
GetStartTime returns the start time of the TaskRun. If the start time is unknown, the zero start time is returned.
func (*TaskRun) GetStatusCondition ¶
GetStatusCondition returns the status condition of the TaskRun.
func (*TaskRun) GetTestResult ¶
func (t *TaskRun) GetTestResult() (*IntegrationTestTaskResult, error)
GetTestResult returns a IntegrationTestTaskResult if the TaskRun produced the result. It will return nil otherwise.