Skip to content

Commit

Permalink
image: upload OpenStack images to OpenStack
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Feb 19, 2024
1 parent 8f087e7 commit 97a95f3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 55 deletions.
63 changes: 9 additions & 54 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
};
uplosi = {
url = "github:edgelesssys/uplosi";
inputs.nixpkgs.follows = "nixpkgsUnstable";
inputs.flake-utils.follows = "flake-utils";
};
};

Expand Down
2 changes: 1 addition & 1 deletion image/upload/internal/cmd/uplosi.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func runUplosi(cmd *cobra.Command, _ []string) error {

var uploadC uploader
switch flags.provider {
case cloudprovider.AWS, cloudprovider.Azure, cloudprovider.GCP:
case cloudprovider.AWS, cloudprovider.Azure, cloudprovider.GCP, cloudprovider.OpenStack:
uploadC = uplosiupload.New(flags.uplosiPath, log)
default:
uploadC = nopupload.New(log)
Expand Down
5 changes: 5 additions & 0 deletions internal/osimage/uplosi/uplosi.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ publisher = "edgelesssys"
project = "constellation-images"
location = "europe-west3"
bucket = "constellation-os-images"

[base.openstack]
cloud = "stackit"
visibility = "private"
properties = { "hw_firmware_type" = "uefi", "os_type" = "linux" }
6 changes: 6 additions & 0 deletions internal/osimage/uplosi/uplosiupload.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ func prepareUplosiConfig(req *osimage.UploadRequest) ([]byte, error) {
awsConfig := baseConfig["aws"].(map[string]any)
azureConfig := baseConfig["azure"].(map[string]any)
gcpConfig := baseConfig["gcp"].(map[string]any)
openstackConfig := baseConfig["openstack"].(map[string]any)

baseConfig["imageVersion"] = imageVersionStr
baseConfig["provider"] = strings.ToLower(req.Provider.String())
extendAWSConfig(awsConfig, req.Version, req.AttestationVariant, req.Timestamp)
extendAzureConfig(azureConfig, req.Version, req.AttestationVariant, req.Timestamp)
extendGCPConfig(gcpConfig, req.Version, req.AttestationVariant)
extendOpenStackConfig(openstackConfig, req.Version, req.AttestationVariant)

buf := new(bytes.Buffer)
if err := toml.NewEncoder(buf).Encode(config); err != nil {
Expand Down Expand Up @@ -264,6 +266,10 @@ func extendGCPConfig(gcpConfig map[string]any, version versionsapi.Version, atte
gcpConfig["blobName"] = gcpImageName(version, attestationVariant) + ".tar.gz"
}

func extendOpenStackConfig(openstackConfig map[string]any, version versionsapi.Version, attestationVariant string) {
openstackConfig["imageName"] = fmt.Sprintf("constellation-%s-%s-%s", version.Stream(), version.Version(), attestationVariant)
}

func gcpImageFamily(version versionsapi.Version) string {
if version.Stream() == "stable" {
return "constellation"
Expand Down

0 comments on commit 97a95f3

Please sign in to comment.