mirror of https://github.com/kubernetes/kops.git
Always set canonical location of assets
This commit is contained in:
parent
5e7c6da57e
commit
1c33270f91
|
@ -120,9 +120,10 @@ func (a *AssetBuilder) RemapManifest(data []byte) ([]byte, error) {
|
||||||
|
|
||||||
// RemapImage normalizes a containers location if a user sets the AssetsLocation ContainerRegistry location.
|
// RemapImage normalizes a containers location if a user sets the AssetsLocation ContainerRegistry location.
|
||||||
func (a *AssetBuilder) RemapImage(image string) (string, error) {
|
func (a *AssetBuilder) RemapImage(image string) (string, error) {
|
||||||
asset := &ContainerAsset{}
|
asset := &ContainerAsset{
|
||||||
|
DockerImage: image,
|
||||||
asset.DockerImage = image
|
CanonicalLocation: image,
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(image, "k8s.gcr.io/kops/dns-controller:") {
|
if strings.HasPrefix(image, "k8s.gcr.io/kops/dns-controller:") {
|
||||||
// To use user-defined DNS Controller:
|
// To use user-defined DNS Controller:
|
||||||
|
@ -167,7 +168,6 @@ func (a *AssetBuilder) RemapImage(image string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
asset.DockerImage = normalized
|
asset.DockerImage = normalized
|
||||||
asset.CanonicalLocation = image
|
|
||||||
|
|
||||||
// Run the new image
|
// Run the new image
|
||||||
image = asset.DockerImage
|
image = asset.DockerImage
|
||||||
|
@ -192,8 +192,6 @@ func (a *AssetBuilder) RemapImage(image string) (string, error) {
|
||||||
asset.DockerImage = registryMirror + "/" + normalized
|
asset.DockerImage = registryMirror + "/" + normalized
|
||||||
}
|
}
|
||||||
|
|
||||||
asset.CanonicalLocation = image
|
|
||||||
|
|
||||||
// Run the new image
|
// Run the new image
|
||||||
image = asset.DockerImage
|
image = asset.DockerImage
|
||||||
}
|
}
|
||||||
|
@ -210,11 +208,11 @@ func (a *AssetBuilder) RemapFileAndSHA(fileURL *url.URL) (*url.URL, *hashing.Has
|
||||||
}
|
}
|
||||||
|
|
||||||
fileAsset := &FileAsset{
|
fileAsset := &FileAsset{
|
||||||
DownloadURL: fileURL,
|
DownloadURL: fileURL,
|
||||||
|
CanonicalURL: fileURL,
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.AssetsLocation != nil && a.AssetsLocation.FileRepository != nil {
|
if a.AssetsLocation != nil && a.AssetsLocation.FileRepository != nil {
|
||||||
fileAsset.CanonicalURL = fileURL
|
|
||||||
|
|
||||||
normalizedFileURL, err := a.remapURL(fileURL)
|
normalizedFileURL, err := a.remapURL(fileURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -245,13 +243,12 @@ func (a *AssetBuilder) RemapFileAndSHAValue(fileURL *url.URL, shaValue string) (
|
||||||
}
|
}
|
||||||
|
|
||||||
fileAsset := &FileAsset{
|
fileAsset := &FileAsset{
|
||||||
DownloadURL: fileURL,
|
DownloadURL: fileURL,
|
||||||
SHAValue: shaValue,
|
CanonicalURL: fileURL,
|
||||||
|
SHAValue: shaValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
if a.AssetsLocation != nil && a.AssetsLocation.FileRepository != nil {
|
if a.AssetsLocation != nil && a.AssetsLocation.FileRepository != nil {
|
||||||
fileAsset.CanonicalURL = fileURL
|
|
||||||
|
|
||||||
normalizedFile, err := a.remapURL(fileURL)
|
normalizedFile, err := a.remapURL(fileURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -283,7 +280,7 @@ func (a *AssetBuilder) findHash(file *FileAsset) (*hashing.Hash, error) {
|
||||||
// rest of the time. If not we get a chicken and the egg problem where we are reading the sha file
|
// rest of the time. If not we get a chicken and the egg problem where we are reading the sha file
|
||||||
// before it exists.
|
// before it exists.
|
||||||
u := file.DownloadURL
|
u := file.DownloadURL
|
||||||
if a.Phase == "assets" && file.CanonicalURL != nil {
|
if a.Phase == "assets" {
|
||||||
u = file.CanonicalURL
|
u = file.CanonicalURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ func (l *Loader) BuildTasks(assetBuilder *assets.AssetBuilder, lifecycle *fi.Lif
|
||||||
|
|
||||||
func (l *Loader) addAssetCopyTasks(assets []*assets.ContainerAsset, lifecycle *fi.Lifecycle) error {
|
func (l *Loader) addAssetCopyTasks(assets []*assets.ContainerAsset, lifecycle *fi.Lifecycle) error {
|
||||||
for _, asset := range assets {
|
for _, asset := range assets {
|
||||||
if asset.CanonicalLocation != "" && asset.DockerImage != asset.CanonicalLocation {
|
if asset.DockerImage != asset.CanonicalLocation {
|
||||||
context := &fi.ModelBuilderContext{
|
context := &fi.ModelBuilderContext{
|
||||||
Tasks: l.tasks,
|
Tasks: l.tasks,
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (l *Loader) addAssetFileCopyTasks(assets []*assets.FileAsset, lifecycle *fi
|
||||||
}
|
}
|
||||||
|
|
||||||
// test if the asset needs to be copied
|
// test if the asset needs to be copied
|
||||||
if asset.CanonicalURL != nil && asset.DownloadURL.String() != asset.CanonicalURL.String() {
|
if asset.DownloadURL.String() != asset.CanonicalURL.String() {
|
||||||
klog.V(10).Infof("processing asset: %q, %q", asset.DownloadURL.String(), asset.CanonicalURL.String())
|
klog.V(10).Infof("processing asset: %q, %q", asset.DownloadURL.String(), asset.CanonicalURL.String())
|
||||||
context := &fi.ModelBuilderContext{
|
context := &fi.ModelBuilderContext{
|
||||||
Tasks: l.tasks,
|
Tasks: l.tasks,
|
||||||
|
|
|
@ -262,10 +262,8 @@ func (t *DryRunTarget) PrintReport(taskMap map[string]Task, out io.Writer) error
|
||||||
if len(t.assetBuilder.FileAssets) != 0 {
|
if len(t.assetBuilder.FileAssets) != 0 {
|
||||||
klog.V(4).Infof("FileAssets:")
|
klog.V(4).Infof("FileAssets:")
|
||||||
for _, a := range t.assetBuilder.FileAssets {
|
for _, a := range t.assetBuilder.FileAssets {
|
||||||
if a.DownloadURL != nil && a.CanonicalURL != nil {
|
if a.DownloadURL != nil {
|
||||||
klog.V(4).Infof(" %s %s", a.DownloadURL.String(), a.CanonicalURL.String())
|
klog.V(4).Infof(" %s %s", a.DownloadURL.String(), a.CanonicalURL.String())
|
||||||
} else if a.DownloadURL != nil {
|
|
||||||
klog.V(4).Infof(" %s", a.DownloadURL.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue