Skip to content

Commit

Permalink
Merge pull request #944 from 14rcole/image-repository-workaround
Browse files Browse the repository at this point in the history
feat: begin referencing status.lastPromotedImage
  • Loading branch information
14rcole authored Nov 26, 2024
2 parents f17608e + d508ad2 commit b547faa
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 b547faa

Please sign in to comment.