mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-13 01:44:22 -05:00
0d12e37c96
* Include EXC0014 and fix issues. * Include EXC0012 and fix issues. Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Otto Bittner <cobittner@posteo.net>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"os"
|
|
|
|
"github.com/edgelesssys/constellation/v2/hack/build-manifest/azure"
|
|
"github.com/edgelesssys/constellation/v2/hack/build-manifest/gcp"
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
const (
|
|
// AzureSubscriptionIDEnv environment variable to provide Azure Subscription ID with.
|
|
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)
|
|
}
|
|
}
|