2023-02-24 06:00:04 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
// cli-k8s-compatibility generates JSON output for a CLI version and its supported Kubernetes versions.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
2024-02-08 09:20:01 -05:00
|
|
|
"fmt"
|
|
|
|
"log/slog"
|
|
|
|
"os"
|
2023-02-24 06:00:04 -05:00
|
|
|
|
2023-06-07 10:16:32 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
2024-01-09 13:37:56 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
2023-02-24 06:00:04 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
refFlag = flag.String("ref", "", "the reference name of the image")
|
|
|
|
streamFlag = flag.String("stream", "", "the stream name of the image")
|
|
|
|
versionFlag = flag.String("version", "", "the version of the image")
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-02-08 09:20:01 -05:00
|
|
|
log := logger.NewTextLogger(slog.LevelDebug)
|
2023-02-24 06:00:04 -05:00
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
if *refFlag == "" {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error("ref must be set")
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
if *streamFlag == "" {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error("stream must be set")
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
if *versionFlag == "" {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error("version must be set")
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cliInfo := versionsapi.CLIInfo{
|
|
|
|
Ref: *refFlag,
|
|
|
|
Stream: *streamFlag,
|
|
|
|
Version: *versionFlag,
|
|
|
|
Kubernetes: []string{},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, v := range versions.VersionConfigs {
|
|
|
|
cliInfo.Kubernetes = append(cliInfo.Kubernetes, v.ClusterVersion)
|
|
|
|
}
|
|
|
|
|
2024-01-09 13:37:56 -05:00
|
|
|
c, cclose, err := versionsapi.NewClient(ctx, "eu-central-1", "cdn-constellation-backend", constants.CDNDefaultDistributionID, false, log)
|
2023-02-24 06:00:04 -05:00
|
|
|
if err != nil {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error(fmt.Sprintf("creating s3 client: %s", err))
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
defer func() {
|
2023-06-02 05:20:01 -04:00
|
|
|
if err := cclose(ctx); err != nil {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error(fmt.Sprintf("invalidating cache: %s", err))
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
if err := c.UpdateCLIInfo(ctx, cliInfo); err != nil {
|
2024-02-08 09:20:01 -05:00
|
|
|
log.Error(fmt.Sprintf("updating cli info: %s", err))
|
|
|
|
os.Exit(1)
|
2023-02-24 06:00:04 -05:00
|
|
|
}
|
|
|
|
}
|