Skip to content

Commit

Permalink
fix linter issues + integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Jul 11, 2023
1 parent f299c07 commit e5af26d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions operator/apis/lifecycle/v1alpha3/common/phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var phases = []KeptnPhaseType{
PhaseWorkloadCompleted,
PhaseDeprecateAppVersion,
PhaseDeprecated,
PhaseAppCompleted,
}

func (p KeptnPhaseType) IsEvaluation() bool {
Expand Down Expand Up @@ -104,6 +105,7 @@ var (
PhaseDeprecateAppVersion = KeptnPhaseType{LongName: "Deprecate AppVersion", ShortName: "DeprecateAppVersion"}
PhaseAppCompleted = KeptnPhaseType{LongName: "App Completed", ShortName: "AppCompleted"}
PhaseWorkloadCompleted = KeptnPhaseType{LongName: "Workload Completed", ShortName: "WorkloadCompleted"}
PhaseCompleted = KeptnPhaseType{LongName: "Completed", ShortName: "Completed"}
PhaseDeprecated = KeptnPhaseType{LongName: "Deprecated", ShortName: "Deprecated"}
)

Expand Down
1 change: 1 addition & 0 deletions operator/controllers/common/evaluationhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

//nolint:dupl
func TestEvaluationHandler(t *testing.T) {
tests := []struct {
name string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r *KeptnAppVersionReconciler) Reconcile(ctx context.Context, req ctrl.Requ
func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.Context, appVersion *klcv1alpha3.KeptnAppVersion, spanAppTrace trace.Span) (ctrl.Result, error) {

if !appVersion.IsEndTimeSet() {
appVersion.Status.CurrentPhase = apicommon.PhaseAppCompleted.ShortName
appVersion.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName
appVersion.SetEndTime()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestKeptnAppVersionReconciler_ReconcileReachCompletion(t *testing.T) {

func createFinishedAppVersionStatus() lfcv1alpha3.KeptnAppVersionStatus {
return lfcv1alpha3.KeptnAppVersionStatus{
CurrentPhase: apicommon.PhaseAppCompleted.ShortName,
CurrentPhase: apicommon.PhaseCompleted.ShortName,
PreDeploymentStatus: apicommon.StateSucceeded,
PostDeploymentStatus: apicommon.StateSucceeded,
PreDeploymentEvaluationStatus: apicommon.StateSucceeded,
Expand Down
2 changes: 1 addition & 1 deletion operator/controllers/lifecycle/keptntask/job_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (r *KeptnTaskReconciler) createJob(ctx context.Context, req ctrl.Request, t
jobName := ""
definition, err := controllercommon.GetTaskDefinition(r.Client, r.Log, ctx, task.Spec.TaskDefinition, req.Namespace)
if err != nil {
fmt.Sprintf("could not find KeptnTaskDefinition: %s ", task.Spec.TaskDefinition)
r.Log.Error(err, fmt.Sprintf("could not find KeptnTaskDefinition: %s ", task.Spec.TaskDefinition))
r.EventSender.SendK8sEvent(apicommon.PhaseCreateTask, "Warning", task, apicommon.PhaseStateNotFound, fmt.Sprintf("could not find KeptnTaskDefinition: %s ", task.Spec.TaskDefinition), "")
return err
}
Expand Down
4 changes: 2 additions & 2 deletions operator/controllers/lifecycle/keptntask/runtime_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (fb *RuntimeBuilder) handleParent(ctx context.Context, params *RuntimeExecu
var parentJobParams RuntimeExecutionParams
parentDefinition, err := controllercommon.GetTaskDefinition(fb.options.Client, fb.options.Log, ctx, fb.options.funcSpec.FunctionReference.Name, fb.options.req.Namespace)
if err != nil {
fmt.Sprintf("could not finc KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition)
fb.options.Log.Error(err, fmt.Sprintf("could not finc KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition))
fb.options.eventSender.SendK8sEvent(apicommon.PhaseCreateTask, "Warning", fb.options.task, apicommon.PhaseStateNotFound, fmt.Sprintf("could not find KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition), "")
return err
}
Expand All @@ -225,7 +225,7 @@ func (fb *RuntimeBuilder) handleParent(ctx context.Context, params *RuntimeExecu
// merge parameter to make sure we use child task data for env var and secrets
err = mergo.Merge(params, parentJobParams)
if err != nil {
fmt.Sprintf("could not merge KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition)
fb.options.Log.Error(err, fmt.Sprintf("could not merge KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition))
fb.options.eventSender.SendK8sEvent(apicommon.PhaseCreateTask, "Warning", fb.options.task, apicommon.PhaseStateFailed, fmt.Sprintf("could not merge KeptnTaskDefinition: %s ", fb.options.task.Spec.TaskDefinition), "")
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (r *KeptnWorkloadInstanceReconciler) Reconcile(ctx context.Context, req ctr

func (r *KeptnWorkloadInstanceReconciler) finishKeptnWorkloadInstanceReconcile(ctx context.Context, workloadInstance *klcv1alpha3.KeptnWorkloadInstance, spanWorkloadTrace trace.Span, span trace.Span, phase apicommon.KeptnPhaseType) (ctrl.Result, error) {
if !workloadInstance.IsEndTimeSet() {
workloadInstance.Status.CurrentPhase = apicommon.PhaseWorkloadCompleted.ShortName
workloadInstance.Status.CurrentPhase = apicommon.PhaseCompleted.ShortName
workloadInstance.Status.Status = apicommon.StateSucceeded
workloadInstance.SetEndTime()
}
Expand Down

0 comments on commit e5af26d

Please sign in to comment.