forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhcos: ami regions from rhcos stream at runtime
Currently, the installer relies on a generated go file for determining the AWS region in which the RHCOS image is published. The `go generate` directive was inadvertently removed in openshift#4582. Rather than resurrecting the directive, this commit removes the generated code in favor of gathering the regions directly from the rhcos stream data when needed. https://issues.redhat.com/browse/CORS-1838
- Loading branch information
Showing
7 changed files
with
36 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package rhcos | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/coreos/stream-metadata-go/arch" | ||
"github.com/sirupsen/logrus" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
|
||
"github.com/openshift/installer/pkg/types" | ||
) | ||
|
||
// AMIRegions returns the AWS regions in which an RHCOS AMI for the specified architecture is published. | ||
func AMIRegions(architecture types.Architecture) sets.String { | ||
stream, err := FetchCoreOSBuild(context.Background()) | ||
if err != nil { | ||
logrus.Error("could not fetch the rhcos stream data: %w", err) | ||
return nil | ||
} | ||
rpmArch := arch.RpmArch(string(architecture)) | ||
awsImages := stream.Architectures[rpmArch].Images.Aws | ||
if awsImages == nil { | ||
return nil | ||
} | ||
regions := make([]string, 0, len(awsImages.Regions)) | ||
for name, r := range awsImages.Regions { | ||
if r.Image == "" { | ||
continue | ||
} | ||
regions = append(regions, name) | ||
} | ||
return sets.NewString(regions...) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.