Skip to content

Commit

Permalink
feat: begin referencing status.lastPromotedImage
Browse files Browse the repository at this point in the history
Attempt to use status.lastPrommotedImage as the source of truth
for the gcl.  Fall back on the spec.containerImage field, despite
the fact that it may have been changed by imageRepository

Signed-off-by: Ryan Cole <[email protected]>
  • Loading branch information
14rcole committed Nov 25, 2024
1 parent b2b5741 commit d508ad2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gitops/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,10 @@ func PrepareSnapshot(ctx context.Context, adapterClient client.Client, applicati
var snapshotComponents []applicationapiv1alpha1.SnapshotComponent
for _, applicationComponent := range *applicationComponents {
applicationComponent := applicationComponent // G601
containerImage := applicationComponent.Spec.ContainerImage
containerImage := applicationComponent.Status.LastPromotedImage
if containerImage == "" {
containerImage = applicationComponent.Spec.ContainerImage
}

var componentSource *applicationapiv1alpha1.ComponentSource
if applicationComponent.Name == component.Name {
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/component/component_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func (a *Adapter) EnsureComponentIsCleanedUp() (controller.OperationResult, erro
for _, individualComponent := range *applicationComponents {
component := individualComponent
if a.component.Name != component.Name {
containerImage := component.Spec.ContainerImage
containerImage := component.Status.LastPromotedImage
if containerImage == "" {
containerImage = component.Spec.ContainerImage
}
componentSource := gitops.GetComponentSourceFromComponent(&component)
snapshotComponents = append(snapshotComponents, applicationapiv1alpha1.SnapshotComponent{
Name: component.Name,
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/snapshot/snapshot_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,10 @@ func (a *Adapter) prepareGroupSnapshot(application *applicationapiv1alpha1.Appli
a.logger.Info("can't find snapshot with open pull/merge request for component, try to find snapshotComponent from Global Candidate List", "component", applicationComponent.Name)
// if there is no component snapshot found for open PR/MR, we get snapshotComponent from gcl
componentSource := gitops.GetComponentSourceFromComponent(&applicationComponent)
containerImage := applicationComponent.Spec.ContainerImage
containerImage := applicationComponent.Status.LastPromotedImage
if containerImage == "" {
containerImage = applicationComponent.Spec.ContainerImage
}
if containerImage == "" {
a.logger.Info("component cannot be added to snapshot for application due to missing containerImage", "component.Name", applicationComponent.Name)
continue
Expand Down

0 comments on commit d508ad2

Please sign in to comment.