Skip to content

Commit

Permalink
[RHTAPBUGS-462] Always update the SEB status (#358)
Browse files Browse the repository at this point in the history
* [RHTAPBUGS-462] Always update the SEB status

Signed-off-by: John Collier <[email protected]>

* Fix test failure

Signed-off-by: John Collier <[email protected]>

* Fix rebase

Signed-off-by: John Collier <[email protected]>

---------

Signed-off-by: John Collier <[email protected]>
  • Loading branch information
johnmcollier authored Jul 6, 2023
1 parent f92b56b commit d615f43
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions controllers/applicationsnapshotenvironmentbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (r *SnapshotEnvironmentBindingReconciler) Reconcile(ctx context.Context, re
var tempDir string
clone := true

appSnapshotEnvBinding.Status.Components = []appstudiov1alpha1.BindingComponentStatus{}
for _, component := range components {
componentName := component.Name

Expand Down Expand Up @@ -278,14 +279,6 @@ func (r *SnapshotEnvironmentBindingReconciler) Reconcile(ctx context.Context, re
return ctrl.Result{}, err
}

isStatusUpdated := false
for _, bindingStatusComponent := range appSnapshotEnvBinding.Status.Components {
if bindingStatusComponent.Name == componentName {
isStatusUpdated = true
break
}
}

if clone {
// Create a temp folder to create the gitops resources in
tempDir, err = ioutils.CreateTempPath(appSnapshotEnvBinding.Name, r.AppFS)
Expand Down Expand Up @@ -371,30 +364,29 @@ func (r *SnapshotEnvironmentBindingReconciler) Reconcile(ctx context.Context, re
return ctrl.Result{}, err
}

if !isStatusUpdated {
componentStatus := appstudiov1alpha1.BindingComponentStatus{
Name: componentName,
GitOpsRepository: appstudiov1alpha1.BindingComponentGitOpsRepository{
URL: hasComponent.Status.GitOps.RepositoryURL,
Branch: gitOpsBranch,
Path: filepath.Join(gitOpsContext, "components", componentName, "overlays", environmentName),
CommitID: commitID,
},
}

// On OpenShift, we generate a unique route name for each Component, so include that in the status
if !isKubernetesCluster {
componentStatus.GeneratedRouteName = routeName
log.Info(fmt.Sprintf("added RouteName %s for Component %s to status", routeName, componentName))
}
// Set the BindingComponent status
componentStatus := appstudiov1alpha1.BindingComponentStatus{
Name: componentName,
GitOpsRepository: appstudiov1alpha1.BindingComponentGitOpsRepository{
URL: hasComponent.Status.GitOps.RepositoryURL,
Branch: gitOpsBranch,
Path: filepath.Join(gitOpsContext, "components", componentName, "overlays", environmentName),
CommitID: commitID,
},
}

if _, ok := componentGeneratedResources[componentName]; ok {
componentStatus.GitOpsRepository.GeneratedResources = componentGeneratedResources[componentName]
}
// On OpenShift, we generate a unique route name for each Component, so include that in the status
if !isKubernetesCluster {
componentStatus.GeneratedRouteName = routeName
log.Info(fmt.Sprintf("added RouteName %s for Component %s to status", routeName, componentName))
}

appSnapshotEnvBinding.Status.Components = append(appSnapshotEnvBinding.Status.Components, componentStatus)
if _, ok := componentGeneratedResources[componentName]; ok {
componentStatus.GitOpsRepository.GeneratedResources = componentGeneratedResources[componentName]
}

appSnapshotEnvBinding.Status.Components = append(appSnapshotEnvBinding.Status.Components, componentStatus)

// Set the clone to false, since we dont want to clone the repo again for the other components
clone = false
}
Expand Down

0 comments on commit d615f43

Please sign in to comment.