mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-23 06:24:44 -04:00
Feat/version manifests (#387)
Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Otto Bittner <cobittner@posteo.net>
This commit is contained in:
parent
cdcbed6ff9
commit
ec79484948
8 changed files with 377 additions and 0 deletions
59
hack/build-manifest/main.go
Normal file
59
hack/build-manifest/main.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/edgelesssys/constellation/hack/build-manifest/azure"
|
||||
"github.com/edgelesssys/constellation/hack/build-manifest/gcp"
|
||||
"github.com/edgelesssys/constellation/internal/logger"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
const (
|
||||
AzureSubscriptionIDEnv = "AZURE_SUBSCRIPTION_ID"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
log := logger.New(logger.PlainLog, zapcore.InfoLevel)
|
||||
manifests := OldManifests()
|
||||
|
||||
fetchAzureImages(ctx, manifests, log)
|
||||
fetchGCPImages(ctx, manifests, log)
|
||||
|
||||
if err := json.NewEncoder(os.Stdout).Encode(&manifests); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func fetchAzureImages(ctx context.Context, manifests Manifest, log *logger.Logger) {
|
||||
options := azure.DefaultOptions()
|
||||
if err := options.SetSubscription(os.Getenv(AzureSubscriptionIDEnv)); err != nil {
|
||||
log.Fatalf("please provide a valid subscription UUID via '%s' envar", AzureSubscriptionIDEnv)
|
||||
}
|
||||
|
||||
client := azure.NewClient(log, options)
|
||||
images, err := client.FetchImages(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to fetch Azure image: %v", err)
|
||||
}
|
||||
|
||||
for version, image := range images {
|
||||
manifests.SetAzureImage(version, image)
|
||||
}
|
||||
}
|
||||
|
||||
func fetchGCPImages(ctx context.Context, manifests Manifest, log *logger.Logger) {
|
||||
options := gcp.DefaultOptions()
|
||||
client := gcp.NewClient(ctx, log, options)
|
||||
images, err := client.FetchImages(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to fetch GCP images: %v", err)
|
||||
}
|
||||
|
||||
for version, image := range images {
|
||||
manifests.SetGCPImage(version, image)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue