Skip to content

Commit 41d4db6

Browse files
committed
Use defined host when not equal to target
1 parent c2e899a commit 41d4db6

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

internal/manifest/manifest.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ func (m Manifest) Update(images []string) Manifest {
7575
//
7676
// In the event the source cannot be found in the manifest, we must rely on
7777
// trying to find the source registry from the repository the image is sourced from.
78-
//
79-
// This is more of a nice-to-have. The worst case is that we get it wrong and the
80-
// user has to update the host value to the correct one. Once defined in the manifest
81-
// we can continue to use the host that was set.
8278
foundSource, exists := m.findSourceInManifest(updatedImage)
8379
if !exists {
84-
updatedSource.Host = getSourceHostFromRepository(updatedRegistryPath.Repository())
80+
81+
// When the source host and the target host are the same, this means that the
82+
// images that were retrieved are target images.
83+
//
84+
// When the source host and target host are different, we can safely use the
85+
// host found in the image definition as the source.
86+
updatedSource.Host = updatedRegistryPath.Host()
87+
if updatedRegistryPath.Host() == m.Target.Host {
88+
updatedSource.Host = getSourceHostFromRepository(updatedRegistryPath.Repository())
89+
}
8590

8691
updatedRepository := updatedRegistryPath.Repository()
8792
updatedRepository = strings.Replace(updatedRepository, m.Target.Repository, "", 1)

0 commit comments

Comments
 (0)