mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-10 10:15:03 -04:00
bazel tidy
This commit is contained in:
parent
3f51297db5
commit
5bcd295921
81 changed files with 430 additions and 429 deletions
|
@ -7,15 +7,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"io"
|
"fmt"
|
||||||
"log/slog"
|
"io"
|
||||||
"os"
|
"log/slog"
|
||||||
"strconv"
|
"os"
|
||||||
"fmt"
|
"strconv"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes"
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
|
||||||
|
@ -38,24 +38,24 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// constellationCSP is the environment variable stating which Cloud Service Provider Constellation is running on.
|
// constellationCSP is the environment variable stating which Cloud Service Provider Constellation is running on.
|
||||||
constellationCSP = "CONSTEL_CSP"
|
constellationCSP = "CONSTEL_CSP"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gRPCDebug := flag.Bool("debug", false, "Enable gRPC debug logging")
|
gRPCDebug := flag.Bool("debug", false, "Enable gRPC debug logging")
|
||||||
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)})).WithGroup("bootstrapper")
|
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)})).WithGroup("bootstrapper")
|
||||||
|
|
||||||
if *gRPCDebug {
|
if *gRPCDebug {
|
||||||
logger.ReplaceGRPCLogger(log.WithGroup("gRPC"))
|
logger.ReplaceGRPCLogger(log.WithGroup("gRPC"))
|
||||||
} else {
|
} else {
|
||||||
logger.ReplaceGRPCLogger(slog.New(logger.NewLevelHandler(slog.LevelWarn, log.Handler())).WithGroup("gRPC"))
|
logger.ReplaceGRPCLogger(slog.New(logger.NewLevelHandler(slog.LevelWarn, log.Handler())).WithGroup("gRPC"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
bindIP := "0.0.0.0"
|
bindIP := "0.0.0.0"
|
||||||
bindPort := strconv.Itoa(constants.BootstrapperPort)
|
bindPort := strconv.Itoa(constants.BootstrapperPort)
|
||||||
|
@ -64,25 +64,25 @@ func main() {
|
||||||
var openDevice vtpm.TPMOpenFunc
|
var openDevice vtpm.TPMOpenFunc
|
||||||
var fs afero.Fs
|
var fs afero.Fs
|
||||||
|
|
||||||
attestVariant, err := variant.FromString(os.Getenv(constants.AttestationVariant))
|
attestVariant, err := variant.FromString(os.Getenv(constants.AttestationVariant))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
issuer, err := choose.Issuer(attestVariant, log)
|
issuer, err := choose.Issuer(attestVariant, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to select issuer")
|
log.With(slog.Any("error", err)).Error("Failed to select issuer")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch cloudprovider.FromString(os.Getenv(constellationCSP)) {
|
switch cloudprovider.FromString(os.Getenv(constellationCSP)) {
|
||||||
case cloudprovider.AWS:
|
case cloudprovider.AWS:
|
||||||
metadata, err := awscloud.New(ctx)
|
metadata, err := awscloud.New(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to set up AWS metadata API")
|
log.With(slog.Any("error", err)).Error("Failed to set up AWS metadata API")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
metadataAPI = metadata
|
metadataAPI = metadata
|
||||||
|
|
||||||
clusterInitJoiner = kubernetes.New(
|
clusterInitJoiner = kubernetes.New(
|
||||||
"aws", k8sapi.NewKubernetesUtil(), &k8sapi.KubdeadmConfiguration{}, kubectl.NewUninitialized(),
|
"aws", k8sapi.NewKubernetesUtil(), &k8sapi.KubdeadmConfiguration{}, kubectl.NewUninitialized(),
|
||||||
|
@ -91,13 +91,13 @@ func main() {
|
||||||
openDevice = vtpm.OpenVTPM
|
openDevice = vtpm.OpenVTPM
|
||||||
fs = afero.NewOsFs()
|
fs = afero.NewOsFs()
|
||||||
|
|
||||||
case cloudprovider.GCP:
|
case cloudprovider.GCP:
|
||||||
metadata, err := gcpcloud.New(ctx)
|
metadata, err := gcpcloud.New(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create GCP metadata client")
|
log.With(slog.Any("error", err)).Error("Failed to create GCP metadata client")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer metadata.Close()
|
defer metadata.Close()
|
||||||
|
|
||||||
metadataAPI = metadata
|
metadataAPI = metadata
|
||||||
clusterInitJoiner = kubernetes.New(
|
clusterInitJoiner = kubernetes.New(
|
||||||
|
@ -117,14 +117,14 @@ func main() {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to prepare Azure control plane node")
|
log.With(zap.Error(err)).Fatalf("Failed to prepare Azure control plane node")
|
||||||
}
|
}
|
||||||
|
|
||||||
metadataAPI = metadata
|
metadataAPI = metadata
|
||||||
clusterInitJoiner = kubernetes.New(
|
clusterInitJoiner = kubernetes.New(
|
||||||
"azure", k8sapi.NewKubernetesUtil(), &k8sapi.KubdeadmConfiguration{}, kubectl.NewUninitialized(),
|
"azure", k8sapi.NewKubernetesUtil(), &k8sapi.KubdeadmConfiguration{}, kubectl.NewUninitialized(),
|
||||||
metadata, &kubewaiter.CloudKubeAPIWaiter{},
|
metadata, &kubewaiter.CloudKubeAPIWaiter{},
|
||||||
)
|
)
|
||||||
|
|
||||||
openDevice = vtpm.OpenVTPM
|
openDevice = vtpm.OpenVTPM
|
||||||
fs = afero.NewOsFs()
|
fs = afero.NewOsFs()
|
||||||
|
|
||||||
case cloudprovider.QEMU:
|
case cloudprovider.QEMU:
|
||||||
metadata := qemucloud.New()
|
metadata := qemucloud.New()
|
||||||
|
@ -166,7 +166,7 @@ func main() {
|
||||||
fs = afero.NewMemMapFs()
|
fs = afero.NewMemMapFs()
|
||||||
}
|
}
|
||||||
|
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
|
|
||||||
run(issuer, openDevice, fileHandler, clusterInitJoiner, metadataAPI, bindIP, bindPort, log)
|
run(issuer, openDevice, fileHandler, clusterInitJoiner, metadataAPI, bindIP, bindPort, log)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,61 +41,61 @@ func run(issuer atls.Issuer, openDevice vtpm.TPMOpenFunc, fileHandler file.Handl
|
||||||
log.Infof("Disk UUID: %s", uuid)
|
log.Infof("Disk UUID: %s", uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeBootstrapped, err := initialize.IsNodeBootstrapped(openDevice)
|
nodeBootstrapped, err := initialize.IsNodeBootstrapped(openDevice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to check if node was previously bootstrapped")
|
log.With(slog.Any("error", err)).Error("Failed to check if node was previously bootstrapped")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nodeBootstrapped {
|
if nodeBootstrapped {
|
||||||
if err := kube.StartKubelet(); err != nil {
|
if err := kube.StartKubelet(); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to restart kubelet")
|
log.With(slog.Any("error", err)).Error("Failed to restart kubelet")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeLock := nodelock.New(openDevice)
|
nodeLock := nodelock.New(openDevice)
|
||||||
initServer, err := initserver.New(context.Background(), nodeLock, kube, issuer, fileHandler, metadata, log)
|
initServer, err := initserver.New(context.Background(), nodeLock, kube, issuer, fileHandler, metadata, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create init server")
|
log.With(slog.Any("error", err)).Error("Failed to create init server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
dialer := dialer.New(issuer, nil, &net.Dialer{})
|
dialer := dialer.New(issuer, nil, &net.Dialer{})
|
||||||
joinClient := joinclient.New(nodeLock, dialer, kube, metadata, log)
|
joinClient := joinclient.New(nodeLock, dialer, kube, metadata, log)
|
||||||
|
|
||||||
cleaner := clean.New().With(initServer).With(joinClient)
|
cleaner := clean.New().With(initServer).With(joinClient)
|
||||||
go cleaner.Start()
|
go cleaner.Start()
|
||||||
defer cleaner.Done()
|
defer cleaner.Done()
|
||||||
|
|
||||||
joinClient.Start(cleaner)
|
joinClient.Start(cleaner)
|
||||||
|
|
||||||
if err := initServer.Serve(bindIP, bindPort, cleaner); err != nil {
|
if err := initServer.Serve(bindIP, bindPort, cleaner); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to serve init server")
|
log.With(slog.Any("error", err)).Error("Failed to serve init server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("bootstrapper done")
|
log.Infof("bootstrapper done")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDiskUUID() (string, error) {
|
func getDiskUUID() (string, error) {
|
||||||
disk := diskencryption.New()
|
disk := diskencryption.New()
|
||||||
free, err := disk.Open()
|
free, err := disk.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer free()
|
defer free()
|
||||||
return disk.UUID()
|
return disk.UUID()
|
||||||
}
|
}
|
||||||
|
|
||||||
type clusterInitJoiner interface {
|
type clusterInitJoiner interface {
|
||||||
joinclient.ClusterJoiner
|
joinclient.ClusterJoiner
|
||||||
initserver.ClusterInitializer
|
initserver.ClusterInitializer
|
||||||
StartKubelet() error
|
StartKubelet() error
|
||||||
}
|
}
|
||||||
|
|
||||||
type metadataAPI interface {
|
type metadataAPI interface {
|
||||||
joinclient.MetadataAPI
|
joinclient.MetadataAPI
|
||||||
initserver.MetadataAPI
|
initserver.MetadataAPI
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -26,6 +25,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
kmssetup "github.com/edgelesssys/constellation/v2/internal/kms/setup"
|
kmssetup "github.com/edgelesssys/constellation/v2/internal/kms/setup"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -67,7 +67,7 @@ func TestNew(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
server, err := New(context.TODO(), newFakeLock(), &stubClusterInitializer{}, atls.NewFakeIssuer(variant.Dummy{}), fh, &tc.metadata, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
server, err := New(context.TODO(), newFakeLock(), &stubClusterInitializer{}, atls.NewFakeIssuer(variant.Dummy{}), fh, &tc.metadata, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -215,7 +215,7 @@ func TestInit(t *testing.T) {
|
||||||
initializer: tc.initializer,
|
initializer: tc.initializer,
|
||||||
disk: tc.disk,
|
disk: tc.disk,
|
||||||
fileHandler: tc.fileHandler,
|
fileHandler: tc.fileHandler,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
grpcServer: serveStopper,
|
grpcServer: serveStopper,
|
||||||
cleaner: &fakeCleaner{serveStopper: serveStopper},
|
cleaner: &fakeCleaner{serveStopper: serveStopper},
|
||||||
initSecretHash: tc.initSecretHash,
|
initSecretHash: tc.initSecretHash,
|
||||||
|
|
|
@ -16,13 +16,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/atlscredentials"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/atlscredentials"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/role"
|
"github.com/edgelesssys/constellation/v2/internal/role"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
||||||
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
||||||
|
@ -221,7 +221,7 @@ func TestClient(t *testing.T) {
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
metadataAPI: metadataAPI,
|
metadataAPI: metadataAPI,
|
||||||
clock: clock,
|
clock: clock,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
serverCreds := atlscredentials.New(nil, nil)
|
serverCreds := atlscredentials.New(nil, nil)
|
||||||
|
@ -276,7 +276,7 @@ func TestClientConcurrentStartStop(t *testing.T) {
|
||||||
fileHandler: file.NewHandler(afero.NewMemMapFs()),
|
fileHandler: file.NewHandler(afero.NewMemMapFs()),
|
||||||
metadataAPI: &stubRepeaterMetadataAPI{},
|
metadataAPI: &stubRepeaterMetadataAPI{},
|
||||||
clock: testclock.NewFakeClock(time.Now()),
|
clock: testclock.NewFakeClock(time.Now()),
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
|
|
|
@ -14,12 +14,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/kubewaiter"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/kubewaiter"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
"github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/role"
|
"github.com/edgelesssys/constellation/v2/internal/role"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
||||||
|
@ -188,7 +188,7 @@ func TestInitCluster(t *testing.T) {
|
||||||
|
|
||||||
_, err := kube.InitCluster(
|
_, err := kube.InitCluster(
|
||||||
context.Background(), string(tc.k8sVersion), "kubernetes",
|
context.Background(), string(tc.k8sVersion), "kubernetes",
|
||||||
false, nil, nil, "", slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
false, nil, nil, "", slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
)
|
)
|
||||||
|
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/gcpshared"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/gcpshared"
|
||||||
|
@ -29,6 +28,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
@ -197,7 +197,7 @@ func TestBackupHelmCharts(t *testing.T) {
|
||||||
applier: &stubConstellApplier{
|
applier: &stubConstellApplier{
|
||||||
stubKubernetesUpgrader: tc.backupClient,
|
stubKubernetesUpgrader: tc.backupClient,
|
||||||
},
|
},
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := a.backupHelmCharts(context.Background(), tc.helmApplier, tc.includesUpgrades, "")
|
err := a.backupHelmCharts(context.Background(), tc.helmApplier, tc.includesUpgrades, "")
|
||||||
|
@ -443,7 +443,7 @@ func TestValidateInputs(t *testing.T) {
|
||||||
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
||||||
|
|
||||||
a := applyCmd{
|
a := applyCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
flags: tc.flags,
|
flags: tc.flags,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
|
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
|
@ -22,6 +21,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -181,7 +181,7 @@ func TestConfigFetchMeasurements(t *testing.T) {
|
||||||
err := fileHandler.WriteYAML(constants.ConfigFilename, gcpConfig, file.OptMkdirAll)
|
err := fileHandler.WriteYAML(constants.ConfigFilename, gcpConfig, file.OptMkdirAll)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
fetcher := stubVerifyFetcher{err: tc.err}
|
fetcher := stubVerifyFetcher{err: tc.err}
|
||||||
cfm := &configFetchMeasurementsCmd{canFetchMeasurements: true, log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), verifyFetcher: fetcher}
|
cfm := &configFetchMeasurementsCmd{canFetchMeasurements: true, log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), verifyFetcher: fetcher}
|
||||||
cfm.flags.insecure = tc.insecureFlag
|
cfm.flags.insecure = tc.insecureFlag
|
||||||
cfm.flags.force = true
|
cfm.flags.force = true
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -93,7 +93,7 @@ func TestConfigGenerateDefault(t *testing.T) {
|
||||||
cmd := newConfigGenerateCmd()
|
cmd := newConfigGenerateCmd()
|
||||||
|
|
||||||
cg := &configGenerateCmd{
|
cg := &configGenerateCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
flags: generateFlags{
|
flags: generateFlags{
|
||||||
attestationVariant: variant.Dummy{},
|
attestationVariant: variant.Dummy{},
|
||||||
k8sVersion: versions.Default,
|
k8sVersion: versions.Default,
|
||||||
|
@ -145,7 +145,7 @@ func TestConfigGenerateDefaultProviderSpecific(t *testing.T) {
|
||||||
wantConf.RemoveProviderAndAttestationExcept(tc.provider)
|
wantConf.RemoveProviderAndAttestationExcept(tc.provider)
|
||||||
|
|
||||||
cg := &configGenerateCmd{
|
cg := &configGenerateCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
flags: generateFlags{
|
flags: generateFlags{
|
||||||
attestationVariant: variant.Dummy{},
|
attestationVariant: variant.Dummy{},
|
||||||
k8sVersion: versions.Default,
|
k8sVersion: versions.Default,
|
||||||
|
@ -178,7 +178,7 @@ func TestConfigGenerateDefaultExists(t *testing.T) {
|
||||||
cmd := newConfigGenerateCmd()
|
cmd := newConfigGenerateCmd()
|
||||||
|
|
||||||
cg := &configGenerateCmd{
|
cg := &configGenerateCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
flags: generateFlags{attestationVariant: variant.Dummy{}},
|
flags: generateFlags{attestationVariant: variant.Dummy{}},
|
||||||
}
|
}
|
||||||
require.Error(cg.configGenerate(cmd, fileHandler, cloudprovider.Unknown, ""))
|
require.Error(cg.configGenerate(cmd, fileHandler, cloudprovider.Unknown, ""))
|
||||||
|
|
|
@ -12,12 +12,12 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
consemver "github.com/edgelesssys/constellation/v2/internal/semver"
|
consemver "github.com/edgelesssys/constellation/v2/internal/semver"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -228,7 +228,7 @@ func TestCreate(t *testing.T) {
|
||||||
skipPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipImagePhase, skipK8sPhase),
|
skipPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipImagePhase, skipK8sPhase),
|
||||||
},
|
},
|
||||||
|
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
|
|
||||||
newInfraApplier: func(_ context.Context) (cloudApplier, func(), error) {
|
newInfraApplier: func(_ context.Context) (cloudApplier, func(), error) {
|
||||||
|
@ -296,7 +296,7 @@ func TestCheckDirClean(t *testing.T) {
|
||||||
for _, f := range tc.existingFiles {
|
for _, f := range tc.existingFiles {
|
||||||
require.NoError(fh.Write(f, []byte{1, 2, 3}, file.OptNone))
|
require.NoError(fh.Write(f, []byte{1, 2, 3}, file.OptNone))
|
||||||
}
|
}
|
||||||
a := &applyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), fileHandler: fh}
|
a := &applyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), fileHandler: fh}
|
||||||
err := a.checkInitFilesClean()
|
err := a.checkInitFilesClean()
|
||||||
|
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -12,12 +12,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -210,7 +210,7 @@ func TestIAMCreateAWS(t *testing.T) {
|
||||||
|
|
||||||
iamCreator := &iamCreator{
|
iamCreator := &iamCreator{
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
creator: tc.creator,
|
creator: tc.creator,
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
|
@ -386,7 +386,7 @@ func TestIAMCreateAzure(t *testing.T) {
|
||||||
|
|
||||||
iamCreator := &iamCreator{
|
iamCreator := &iamCreator{
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
creator: tc.creator,
|
creator: tc.creator,
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
|
@ -577,7 +577,7 @@ func TestIAMCreateGCP(t *testing.T) {
|
||||||
|
|
||||||
iamCreator := &iamCreator{
|
iamCreator := &iamCreator{
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
creator: tc.creator,
|
creator: tc.creator,
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
|
|
|
@ -10,10 +10,10 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/gcpshared"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/gcpshared"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -107,7 +107,7 @@ func TestIAMDestroy(t *testing.T) {
|
||||||
cmd.SetErr(&bytes.Buffer{})
|
cmd.SetErr(&bytes.Buffer{})
|
||||||
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
||||||
|
|
||||||
c := &destroyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), flags: iamDestroyFlags{
|
c := &destroyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), flags: iamDestroyFlags{
|
||||||
yes: tc.yesFlag,
|
yes: tc.yesFlag,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ func TestDeleteGCPServiceAccountKeyFile(t *testing.T) {
|
||||||
cmd.SetErr(&bytes.Buffer{})
|
cmd.SetErr(&bytes.Buffer{})
|
||||||
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
cmd.SetIn(bytes.NewBufferString(tc.stdin))
|
||||||
|
|
||||||
c := &destroyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))}
|
c := &destroyCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))}
|
||||||
|
|
||||||
proceed, err := c.deleteGCPServiceAccountKeyFile(cmd, tc.destroyer, tc.fsHandler)
|
proceed, err := c.deleteGCPServiceAccountKeyFile(cmd, tc.destroyer, tc.fsHandler)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/cli/internal/terraform"
|
"github.com/edgelesssys/constellation/v2/cli/internal/terraform"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
|
"github.com/edgelesssys/constellation/v2/internal/api/attestationconfigapi"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -21,6 +20,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -132,7 +132,7 @@ func TestIamUpgradeApply(t *testing.T) {
|
||||||
|
|
||||||
iamUpgradeApplyCmd := &iamUpgradeApplyCmd{
|
iamUpgradeApplyCmd := &iamUpgradeApplyCmd{
|
||||||
fileHandler: tc.fh,
|
fileHandler: tc.fh,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
configFetcher: tc.configFetcher,
|
configFetcher: tc.configFetcher,
|
||||||
flags: iamUpgradeApplyFlags{
|
flags: iamUpgradeApplyFlags{
|
||||||
yes: tc.yesFlag,
|
yes: tc.yesFlag,
|
||||||
|
|
|
@ -10,12 +10,11 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
||||||
"github.com/edgelesssys/constellation/v2/cli/internal/cmd/pathprefix"
|
"github.com/edgelesssys/constellation/v2/cli/internal/cmd/pathprefix"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
|
@ -28,6 +27,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/semver"
|
"github.com/edgelesssys/constellation/v2/internal/semver"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -39,7 +39,7 @@ func TestMAAPatch(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
c := &maaPatchCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), patcher: tc.patcher}
|
c := &maaPatchCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), patcher: tc.patcher}
|
||||||
err := c.patchMAA(&cobra.Command{}, tc.attestationURL)
|
err := c.patchMAA(&cobra.Command{}, tc.attestationURL)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
require.Error(err)
|
require.Error(err)
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/disk-mapper/recoverproto"
|
"github.com/edgelesssys/constellation/v2/disk-mapper/recoverproto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
|
@ -29,6 +28,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -165,7 +165,7 @@ func TestRecover(t *testing.T) {
|
||||||
|
|
||||||
newDialer := func(atls.Validator) *dialer.Dialer { return nil }
|
newDialer := func(atls.Validator) *dialer.Dialer { return nil }
|
||||||
r := &recoverCmd{
|
r := &recoverCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
configFetcher: stubAttestationFetcher{},
|
configFetcher: stubAttestationFetcher{},
|
||||||
flags: recoverFlags{
|
flags: recoverFlags{
|
||||||
rootFlags: rootFlags{force: true},
|
rootFlags: rootFlags{force: true},
|
||||||
|
@ -219,7 +219,7 @@ func TestDoRecovery(t *testing.T) {
|
||||||
go recoverServer.Serve(listener)
|
go recoverServer.Serve(listener)
|
||||||
defer recoverServer.GracefulStop()
|
defer recoverServer.GracefulStop()
|
||||||
|
|
||||||
r := &recoverCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))}
|
r := &recoverCmd{log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))}
|
||||||
recoverDoer := &recoverDoer{
|
recoverDoer := &recoverDoer{
|
||||||
dialer: dialer.New(nil, nil, netDialer),
|
dialer: dialer.New(nil, nil, netDialer),
|
||||||
endpoint: addr,
|
endpoint: addr,
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -140,7 +140,7 @@ func TestTerminate(t *testing.T) {
|
||||||
fileHandler := file.NewHandler(tc.setupFs(require, tc.stateFile))
|
fileHandler := file.NewHandler(tc.setupFs(require, tc.stateFile))
|
||||||
|
|
||||||
tCmd := &terminateCmd{
|
tCmd := &terminateCmd{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
flags: terminateFlags{
|
flags: terminateFlags{
|
||||||
yes: tc.yesFlag,
|
yes: tc.yesFlag,
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
|
@ -23,6 +22,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
"github.com/edgelesssys/constellation/v2/internal/constellation/state"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/semver"
|
"github.com/edgelesssys/constellation/v2/internal/semver"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
@ -252,7 +252,7 @@ func TestUpgradeApply(t *testing.T) {
|
||||||
upgrader := &applyCmd{
|
upgrader := &applyCmd{
|
||||||
fileHandler: fh,
|
fileHandler: fh,
|
||||||
flags: tc.flags,
|
flags: tc.flags,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
spinner: &nopSpinner{},
|
spinner: &nopSpinner{},
|
||||||
merger: &stubMerger{},
|
merger: &stubMerger{},
|
||||||
newInfraApplier: func(ctx context.Context) (cloudApplier, func(), error) {
|
newInfraApplier: func(ctx context.Context) (cloudApplier, func(), error) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -24,6 +23,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
consemver "github.com/edgelesssys/constellation/v2/internal/semver"
|
consemver "github.com/edgelesssys/constellation/v2/internal/semver"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -140,7 +140,7 @@ func TestGetCompatibleImageMeasurements(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
upgrades, err := getCompatibleImageMeasurements(context.Background(), &bytes.Buffer{}, client, &stubCosignVerifier{}, singleUUIDVerifier(), csp, attestationVariant, versionZero, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
upgrades, err := getCompatibleImageMeasurements(context.Background(), &bytes.Buffer{}, client, &stubCosignVerifier{}, singleUUIDVerifier(), csp, attestationVariant, versionZero, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
for _, measurement := range upgrades {
|
for _, measurement := range upgrades {
|
||||||
|
@ -216,7 +216,7 @@ func TestUpgradeCheck(t *testing.T) {
|
||||||
collect: &tc.collector,
|
collect: &tc.collector,
|
||||||
terraformChecker: tc.checker,
|
terraformChecker: tc.checker,
|
||||||
fileHandler: fileHandler,
|
fileHandler: fileHandler,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := newUpgradeCheckCmd()
|
cmd := newUpgradeCheckCmd()
|
||||||
|
|
|
@ -14,13 +14,12 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -31,6 +30,7 @@ import (
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/verify/verifyproto"
|
"github.com/edgelesssys/constellation/v2/verify/verifyproto"
|
||||||
tpmProto "github.com/google/go-tpm-tools/proto/tpm"
|
tpmProto "github.com/google/go-tpm-tools/proto/tpm"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer"
|
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer"
|
||||||
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -118,7 +118,7 @@ func TestDownloadDeployment(t *testing.T) {
|
||||||
defer grpcServ.GracefulStop()
|
defer grpcServ.GracefulStop()
|
||||||
|
|
||||||
download := &Download{
|
download := &Download{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
dialer: dialer,
|
dialer: dialer,
|
||||||
transfer: transfer,
|
transfer: transfer,
|
||||||
serviceManager: serviceMgr,
|
serviceManager: serviceMgr,
|
||||||
|
@ -190,7 +190,7 @@ func TestDownloadInfo(t *testing.T) {
|
||||||
defer grpcServer.GracefulStop()
|
defer grpcServer.GracefulStop()
|
||||||
|
|
||||||
download := &Download{
|
download := &Download{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
dialer: dialer,
|
dialer: dialer,
|
||||||
info: &tc.infoSetter,
|
info: &tc.infoSetter,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -103,7 +103,7 @@ func TestSystemdAction(t *testing.T) {
|
||||||
|
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
manager := ServiceManager{
|
manager := ServiceManager{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
dbus: &tc.dbus,
|
dbus: &tc.dbus,
|
||||||
fs: fs,
|
fs: fs,
|
||||||
systemdUnitFilewriteLock: sync.Mutex{},
|
systemdUnitFilewriteLock: sync.Mutex{},
|
||||||
|
@ -182,7 +182,7 @@ func TestWriteSystemdUnitFile(t *testing.T) {
|
||||||
fs = afero.NewReadOnlyFs(fs)
|
fs = afero.NewReadOnlyFs(fs)
|
||||||
}
|
}
|
||||||
manager := ServiceManager{
|
manager := ServiceManager{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
dbus: &tc.dbus,
|
dbus: &tc.dbus,
|
||||||
fs: fs,
|
fs: fs,
|
||||||
systemdUnitFilewriteLock: sync.Mutex{},
|
systemdUnitFilewriteLock: sync.Mutex{},
|
||||||
|
@ -295,7 +295,7 @@ func TestOverrideServiceUnitExecStart(t *testing.T) {
|
||||||
fs = afero.NewReadOnlyFs(fs)
|
fs = afero.NewReadOnlyFs(fs)
|
||||||
}
|
}
|
||||||
manager := ServiceManager{
|
manager := ServiceManager{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
dbus: &tc.dbus,
|
dbus: &tc.dbus,
|
||||||
fs: fs,
|
fs: fs,
|
||||||
systemdUnitFilewriteLock: sync.Mutex{},
|
systemdUnitFilewriteLock: sync.Mutex{},
|
||||||
|
|
|
@ -304,7 +304,7 @@ type cmdLogger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmdLogger) Write(p []byte) (n int, err error) {
|
func (c *cmdLogger) Write(p []byte) (n int, err error) {
|
||||||
c.logger.Info(fmt.Sprintf("%s", p))
|
c.logger.Info(fmt.Sprintf("%s", p))
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ package metadata
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"log/slog"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
|
@ -167,7 +167,7 @@ func Start(log *slog.Logger, wg *sync.WaitGroup, serv pb.DebugdServer) {
|
||||||
lis, err := net.Listen("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.DebugdPort)))
|
lis, err := net.Listen("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.DebugdPort)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Listening failed")
|
log.With(slog.Any("error", err)).Error("Listening failed")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
log.Info("gRPC server is waiting for connections")
|
log.Info("gRPC server is waiting for connections")
|
||||||
grpcServer.Serve(lis)
|
grpcServer.Serve(lis)
|
||||||
|
|
|
@ -10,18 +10,18 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/debugd/internal/debugd/deploy"
|
"github.com/edgelesssys/constellation/v2/debugd/internal/debugd/deploy"
|
||||||
"github.com/edgelesssys/constellation/v2/debugd/internal/debugd/info"
|
"github.com/edgelesssys/constellation/v2/debugd/internal/debugd/info"
|
||||||
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer"
|
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer"
|
||||||
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
|
|
|
@ -9,8 +9,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package filetransfer
|
package filetransfer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
|
@ -9,12 +9,12 @@ package filetransfer
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer/streamer"
|
"github.com/edgelesssys/constellation/v2/debugd/internal/filetransfer/streamer"
|
||||||
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
pb "github.com/edgelesssys/constellation/v2/debugd/service"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
|
|
|
@ -9,12 +9,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
||||||
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/recoveryserver"
|
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/recoveryserver"
|
||||||
|
@ -60,12 +60,12 @@ func main() {
|
||||||
attestVariant, err := variant.FromString(os.Getenv(constants.AttestationVariant))
|
attestVariant, err := variant.FromString(os.Getenv(constants.AttestationVariant))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
issuer, err := choose.Issuer(attestVariant, log)
|
issuer, err := choose.Issuer(attestVariant, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to select issuer")
|
log.With(slog.Any("error", err)).Error("Failed to select issuer")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up metadata API
|
// set up metadata API
|
||||||
|
@ -78,36 +78,36 @@ func main() {
|
||||||
diskPath, err = filepath.EvalSymlinks(awsStateDiskPath)
|
diskPath, err = filepath.EvalSymlinks(awsStateDiskPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Unable to resolve Azure state disk path")
|
log.With(slog.Any("error", err)).Error("Unable to resolve Azure state disk path")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
metadataClient, err = awscloud.New(context.Background())
|
metadataClient, err = awscloud.New(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to set up AWS metadata client")
|
log.With(slog.Any("error", err)).Error("Failed to set up AWS metadata client")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
case cloudprovider.Azure:
|
case cloudprovider.Azure:
|
||||||
diskPath, err = filepath.EvalSymlinks(azureStateDiskPath)
|
diskPath, err = filepath.EvalSymlinks(azureStateDiskPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Unable to resolve Azure state disk path")
|
log.With(slog.Any("error", err)).Error("Unable to resolve Azure state disk path")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
metadataClient, err = azurecloud.New(context.Background())
|
metadataClient, err = azurecloud.New(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to set up Azure metadata client")
|
log.With(slog.Any("error", err)).Error("Failed to set up Azure metadata client")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
case cloudprovider.GCP:
|
case cloudprovider.GCP:
|
||||||
diskPath, err = filepath.EvalSymlinks(gcpStateDiskPath)
|
diskPath, err = filepath.EvalSymlinks(gcpStateDiskPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Unable to resolve GCP state disk path")
|
log.With(slog.Any("error", err)).Error("Unable to resolve GCP state disk path")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
gcpMeta, err := gcpcloud.New(context.Background())
|
gcpMeta, err := gcpcloud.New(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error(("Failed to create GCP metadata client"))
|
log.With(slog.Any("error", err)).Error(("Failed to create GCP metadata client"))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer gcpMeta.Close()
|
defer gcpMeta.Close()
|
||||||
metadataClient = gcpMeta
|
metadataClient = gcpMeta
|
||||||
|
@ -117,7 +117,7 @@ func main() {
|
||||||
metadataClient, err = openstack.New(context.Background())
|
metadataClient, err = openstack.New(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error(("Failed to create OpenStack metadata client"))
|
log.With(slog.Any("error", err)).Error(("Failed to create OpenStack metadata client"))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
case cloudprovider.QEMU:
|
case cloudprovider.QEMU:
|
||||||
|
@ -126,7 +126,7 @@ func main() {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Error(fmt.Sprintf("CSP %s is not supported by Constellation", *csp))
|
log.Error(fmt.Sprintf("CSP %s is not supported by Constellation", *csp))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize device mapper
|
// initialize device mapper
|
||||||
|
@ -166,7 +166,7 @@ func main() {
|
||||||
self, err = metadataClient.Self(context.Background())
|
self, err = metadataClient.Self(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error(("Failed to get self metadata"))
|
log.With(slog.Any("error", err)).Error(("Failed to get self metadata"))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
rejoinClient := rejoinclient.New(
|
rejoinClient := rejoinclient.New(
|
||||||
dialer.New(issuer, nil, &net.Dialer{}),
|
dialer.New(issuer, nil, &net.Dialer{}),
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/disk-mapper/recoverproto"
|
"github.com/edgelesssys/constellation/v2/disk-mapper/recoverproto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/kms/kms"
|
"github.com/edgelesssys/constellation/v2/internal/kms/kms"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
|
@ -36,7 +36,7 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
func TestServe(t *testing.T) {
|
func TestServe(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
||||||
uuid := "uuid"
|
uuid := "uuid"
|
||||||
server := New(atls.NewFakeIssuer(variant.Dummy{}), newStubKMS(nil, nil), log)
|
server := New(atls.NewFakeIssuer(variant.Dummy{}), newStubKMS(nil, nil), log)
|
||||||
dialer := testdialer.NewBufconnDialer()
|
dialer := testdialer.NewBufconnDialer()
|
||||||
|
@ -107,7 +107,7 @@ func TestRecover(t *testing.T) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
serverUUID := "uuid"
|
serverUUID := "uuid"
|
||||||
server := New(atls.NewFakeIssuer(variant.Dummy{}), tc.factory, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
server := New(atls.NewFakeIssuer(variant.Dummy{}), tc.factory, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
netDialer := testdialer.NewBufconnDialer()
|
netDialer := testdialer.NewBufconnDialer()
|
||||||
listener := netDialer.GetListener("192.0.2.1:1234")
|
listener := netDialer.GetListener("192.0.2.1:1234")
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/atlscredentials"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/atlscredentials"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/dialer"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/role"
|
"github.com/edgelesssys/constellation/v2/internal/role"
|
||||||
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -57,7 +57,7 @@ func TestStartCancel(t *testing.T) {
|
||||||
dialer: dialer,
|
dialer: dialer,
|
||||||
nodeInfo: metadata.InstanceMetadata{Role: role.Worker},
|
nodeInfo: metadata.InstanceMetadata{Role: role.Worker},
|
||||||
metadataAPI: metaAPI,
|
metadataAPI: metaAPI,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
timeout: time.Second * 30,
|
timeout: time.Second * 30,
|
||||||
interval: time.Second,
|
interval: time.Second,
|
||||||
clock: clock,
|
clock: clock,
|
||||||
|
@ -217,7 +217,7 @@ func TestGetJoinEndpoints(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
client := New(nil, tc.nodeInfo, tc.meta, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
client := New(nil, tc.nodeInfo, tc.meta, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
|
|
||||||
endpoints, err := client.getJoinEndpoints()
|
endpoints, err := client.getJoinEndpoints()
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
@ -293,7 +293,7 @@ func TestStart(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
client := New(dialer, tc.nodeInfo, meta, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
client := New(dialer, tc.nodeInfo, meta, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
|
|
||||||
passphrase, secret := client.Start(context.Background(), "uuid")
|
passphrase, secret := client.Start(context.Background(), "uuid")
|
||||||
assert.Equal(diskKey, passphrase)
|
assert.Equal(diskKey, passphrase)
|
||||||
|
|
|
@ -17,10 +17,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/vtpm"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/vtpm"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/nodestate"
|
"github.com/edgelesssys/constellation/v2/internal/nodestate"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -137,7 +137,7 @@ func TestPrepareExistingDisk(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupManager := &Manager{
|
setupManager := &Manager{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
csp: "test",
|
csp: "test",
|
||||||
diskPath: "disk-path",
|
diskPath: "disk-path",
|
||||||
fs: fs,
|
fs: fs,
|
||||||
|
@ -215,7 +215,7 @@ func TestPrepareNewDisk(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
setupManager := &Manager{
|
setupManager := &Manager{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
csp: "test",
|
csp: "test",
|
||||||
diskPath: "disk-path",
|
diskPath: "disk-path",
|
||||||
fs: tc.fs,
|
fs: tc.fs,
|
||||||
|
@ -271,7 +271,7 @@ func TestReadMeasurementSalt(t *testing.T) {
|
||||||
require.NoError(handler.WriteJSON("test-state.json", state, file.OptMkdirAll))
|
require.NoError(handler.WriteJSON("test-state.json", state, file.OptMkdirAll))
|
||||||
}
|
}
|
||||||
|
|
||||||
setupManager := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "disk-path", fs, nil, nil, nil)
|
setupManager := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "disk-path", fs, nil, nil, nil)
|
||||||
|
|
||||||
measurementSalt, err := setupManager.readMeasurementSalt("test-state.json")
|
measurementSalt, err := setupManager.readMeasurementSalt("test-state.json")
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -10,9 +10,9 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"math"
|
"math"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
||||||
"github.com/martinjungblut/go-cryptsetup"
|
"github.com/martinjungblut/go-cryptsetup"
|
||||||
|
@ -38,7 +38,7 @@ func BenchmarkMapper(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
passphrase := "benchmark"
|
passphrase := "benchmark"
|
||||||
mapper, free, err := diskencryption.New(testPath, slog.New(slog.NewPlainTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})))
|
mapper, free, err := diskencryption.New(testPath, slog.New(slog.NewPlainTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal("Failed to create mapper:", err)
|
b.Fatal("Failed to create mapper:", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
func servicesVersion(t *testing.T) (semver.Semver, error) {
|
func servicesVersion(t *testing.T) (semver.Semver, error) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
||||||
settings := cli.New()
|
settings := cli.New()
|
||||||
settings.KubeConfig = "constellation-admin.conf"
|
settings.KubeConfig = "constellation-admin.conf"
|
||||||
actionConfig := &action.Configuration{}
|
actionConfig := &action.Configuration{}
|
||||||
|
|
|
@ -89,7 +89,7 @@ func main() {
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.With(slog.String("testcase", name)).Error("invalid result")
|
log.With(slog.String("testcase", name)).Error("invalid result")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
||||||
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/issues"
|
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/issues"
|
||||||
|
|
|
@ -9,9 +9,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/bazelbuild/buildtools/build"
|
"github.com/bazelbuild/buildtools/build"
|
||||||
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
||||||
|
|
|
@ -11,14 +11,14 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
s3manager "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
|
s3manager "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
|
|
|
@ -9,9 +9,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/bazelbuild/buildtools/build"
|
"github.com/bazelbuild/buildtools/build"
|
||||||
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
"github.com/edgelesssys/constellation/v2/hack/bazel-deps-mirror/internal/bazelfiles"
|
||||||
|
|
|
@ -20,54 +20,54 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
refFlag = flag.String("ref", "", "the reference name of the image")
|
refFlag = flag.String("ref", "", "the reference name of the image")
|
||||||
streamFlag = flag.String("stream", "", "the stream name of the image")
|
streamFlag = flag.String("stream", "", "the stream name of the image")
|
||||||
versionFlag = flag.String("version", "", "the version of the image")
|
versionFlag = flag.String("version", "", "the version of the image")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
|
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *refFlag == "" {
|
if *refFlag == "" {
|
||||||
log.Error("ref must be set")
|
log.Error("ref must be set")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if *streamFlag == "" {
|
if *streamFlag == "" {
|
||||||
log.Error("stream must be set")
|
log.Error("stream must be set")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if *versionFlag == "" {
|
if *versionFlag == "" {
|
||||||
log.Error("version must be set")
|
log.Error("version must be set")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
cliInfo := versionsapi.CLIInfo{
|
cliInfo := versionsapi.CLIInfo{
|
||||||
Ref: *refFlag,
|
Ref: *refFlag,
|
||||||
Stream: *streamFlag,
|
Stream: *streamFlag,
|
||||||
Version: *versionFlag,
|
Version: *versionFlag,
|
||||||
Kubernetes: []string{},
|
Kubernetes: []string{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range versions.VersionConfigs {
|
for _, v := range versions.VersionConfigs {
|
||||||
cliInfo.Kubernetes = append(cliInfo.Kubernetes, v.ClusterVersion)
|
cliInfo.Kubernetes = append(cliInfo.Kubernetes, v.ClusterVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
c, cclose, err := versionsapi.NewClient(ctx, "eu-central-1", "cdn-constellation-backend", constants.CDNDefaultDistributionID, false, log)
|
c, cclose, err := versionsapi.NewClient(ctx, "eu-central-1", "cdn-constellation-backend", constants.CDNDefaultDistributionID, false, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("creating s3 client: %s", err))
|
log.Error(fmt.Sprintf("creating s3 client: %s", err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := cclose(ctx); err != nil {
|
if err := cclose(ctx); err != nil {
|
||||||
log.Error(fmt.Sprintf("invalidating cache: %s", err))
|
log.Error(fmt.Sprintf("invalidating cache: %s", err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := c.UpdateCLIInfo(ctx, cliInfo); err != nil {
|
if err := c.UpdateCLIInfo(ctx, cliInfo); err != nil {
|
||||||
log.Error(fmt.Sprintf("updating cli info: %s", err))
|
log.Error(fmt.Sprintf("updating cli info: %s", err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func runCodegen(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("rendering Go code: %w", err)
|
return fmt.Errorf("rendering Go code: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(fmt.Sprintf("Go code created at %q 🤖", flags.output))
|
log.Debug(fmt.Sprintf("Go code created at %q 🤖", flags.output))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,34 +9,34 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/server"
|
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/server"
|
||||||
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/virtwrapper"
|
"github.com/edgelesssys/constellation/v2/hack/qemu-metadata-api/virtwrapper"
|
||||||
"libvirt.org/go/libvirt"
|
"libvirt.org/go/libvirt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
bindPort := flag.String("port", "8080", "Port to bind to")
|
bindPort := flag.String("port", "8080", "Port to bind to")
|
||||||
targetNetwork := flag.String("network", "constellation-network", "Name of the network in QEMU to use")
|
targetNetwork := flag.String("network", "constellation-network", "Name of the network in QEMU to use")
|
||||||
libvirtURI := flag.String("libvirt-uri", "qemu:///system", "URI of the libvirt connection")
|
libvirtURI := flag.String("libvirt-uri", "qemu:///system", "URI of the libvirt connection")
|
||||||
initSecretHash := flag.String("initsecrethash", "", "brcypt hash of the init secret")
|
initSecretHash := flag.String("initsecrethash", "", "brcypt hash of the init secret")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
|
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
|
||||||
|
|
||||||
conn, err := libvirt.NewConnect(*libvirtURI)
|
conn, err := libvirt.NewConnect(*libvirtURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to connect to libvirt")
|
log.With(slog.Any("error", err)).Error("Failed to connect to libvirt")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
serv := server.New(log, *targetNetwork, *initSecretHash, &virtwrapper.Connect{Conn: conn})
|
serv := server.New(log, *targetNetwork, *initSecretHash, &virtwrapper.Connect{Conn: conn})
|
||||||
if err := serv.ListenAndServe(*bindPort); err != nil {
|
if err := serv.ListenAndServe(*bindPort); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to serve")
|
log.With(slog.Any("error", err)).Error("Failed to serve")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ func TestListAll(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
||||||
|
|
||||||
res, err := server.listAll()
|
res, err := server.listAll()
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ func TestListSelf(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://192.0.0.1/self", nil)
|
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://192.0.0.1/self", nil)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
@ -199,7 +199,7 @@ func TestListPeers(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", "initSecretHash", tc.connect)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://192.0.0.1/peers", nil)
|
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "http://192.0.0.1/peers", nil)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
@ -254,7 +254,7 @@ func TestInitSecretHash(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", tc.wantHash, defaultConnect)
|
server := New(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), "test", tc.wantHash, defaultConnect)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(context.Background(), tc.method, "http://192.0.0.1/initsecrethash", nil)
|
req, err := http.NewRequestWithContext(context.Background(), tc.method, "http://192.0.0.1/initsecrethash", nil)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
|
@ -272,9 +272,9 @@ func parseUplosiFlags(cmd *cobra.Command) (uplosiFlags, error) {
|
||||||
return uplosiFlags{}, err
|
return uplosiFlags{}, err
|
||||||
}
|
}
|
||||||
logLevel := slog.LevelInfo
|
logLevel := slog.LevelInfo
|
||||||
if verbose {
|
if verbose {
|
||||||
logLevel = slog.LevelDebug
|
logLevel = slog.LevelDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
return uplosiFlags{
|
return uplosiFlags{
|
||||||
rawImage: rawImage,
|
rawImage: rawImage,
|
||||||
|
|
|
@ -50,7 +50,7 @@ func runInfo(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
||||||
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
||||||
info, err := readInfoArgs(args)
|
info, err := readInfoArgs(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -58,8 +58,8 @@ func runUplosi(cmd *cobra.Command, _ []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
||||||
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
||||||
|
|
||||||
archiveC, archiveCClose, err := archive.New(cmd.Context(), flags.region, flags.bucket, flags.distributionID, log)
|
archiveC, archiveCClose, err := archive.New(cmd.Context(), flags.region, flags.bucket, flags.distributionID, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
|
@ -43,7 +43,7 @@ func runList(cmd *cobra.Command, _ []string) (retErr error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
log := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: flags.logLevel}))
|
||||||
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
log.Debug(fmt.Sprintf("Parsed flags: %+v", flags))
|
||||||
|
|
||||||
log.Debug("Validating flags")
|
log.Debug("Validating flags")
|
||||||
|
|
|
@ -162,7 +162,7 @@ func TestValidateSNPReport(t *testing.T) {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
v := awsValidator{httpsGetter: newStubHTTPSGetter(&urlResponseMatcher{}, nil), verifier: tc.verifier, validator: tc.validator}
|
v := awsValidator{httpsGetter: newStubHTTPSGetter(&urlResponseMatcher{}, nil), verifier: tc.verifier, validator: tc.validator}
|
||||||
err = v.validate(vtpm.AttestationDocument{InstanceInfo: infoMarshalled}, ask, ark, [64]byte(hash), config.DefaultForAWSSEVSNP(), slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
err = v.validate(vtpm.AttestationDocument{InstanceInfo: infoMarshalled}, ask, ark, [64]byte(hash), config.DefaultForAWSSEVSNP(), slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,10 +14,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest"
|
||||||
|
|
|
@ -190,7 +190,7 @@ func TestGetAttestationCert(t *testing.T) {
|
||||||
))
|
))
|
||||||
require.NoError(tpm2.NVWrite(tpm, tpm2.HandleOwner, tpmAkCertIdx, "", akCert, 0))
|
require.NoError(tpm2.NVWrite(tpm, tpm2.HandleOwner, tpmAkCertIdx, "", akCert, 0))
|
||||||
|
|
||||||
issuer := NewIssuer(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
issuer := NewIssuer(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
issuer.hClient = newTestClient(tc.crlServer)
|
issuer.hClient = newTestClient(tc.crlServer)
|
||||||
|
|
||||||
certs, err := issuer.getAttestationCert(context.Background(), tpm, nil)
|
certs, err := issuer.getAttestationCert(context.Background(), tpm, nil)
|
||||||
|
|
|
@ -10,10 +10,10 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/snp/testdata"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/snp/testdata"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||||
|
|
|
@ -13,9 +13,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
tpmclient "github.com/google/go-tpm-tools/client"
|
tpmclient "github.com/google/go-tpm-tools/client"
|
||||||
"github.com/google/go-tpm-tools/proto/attest"
|
"github.com/google/go-tpm-tools/proto/attest"
|
||||||
|
|
|
@ -8,8 +8,8 @@ package constellation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
|
|
|
@ -241,7 +241,7 @@ func TestAppendNewAction(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
actions := []applyAction{}
|
actions := []applyAction{}
|
||||||
actionFactory := newActionFactory(nil, tc.lister, &action.Configuration{}, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
actionFactory := newActionFactory(nil, tc.lister, &action.Configuration{}, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
|
|
||||||
err := actionFactory.appendNewAction(tc.release, tc.configTargetVersion, tc.force, tc.allowDestructive, time.Second, &actions)
|
err := actionFactory.appendNewAction(tc.release, tc.configTargetVersion, tc.force, tc.allowDestructive, time.Second, &actions)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -174,7 +174,7 @@ func TestHelmApply(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
||||||
options := Options{
|
options := Options{
|
||||||
DeployCSIDriver: true,
|
DeployCSIDriver: true,
|
||||||
Conformance: false,
|
Conformance: false,
|
||||||
|
|
|
@ -65,7 +65,7 @@ func TestRetryApply(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
err := retryApply(context.Background(), tc.applier, time.Millisecond, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
err := retryApply(context.Background(), tc.applier, time.Millisecond, slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)))
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,9 +11,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/compatibility"
|
"github.com/edgelesssys/constellation/v2/internal/compatibility"
|
||||||
|
|
|
@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package logger
|
package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdLineVerbosityDescription explains numeric log levels.
|
// CmdLineVerbosityDescription explains numeric log levels.
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
func replaceGRPCLogger(log *slog.Logger) {
|
func replaceGRPCLogger(log *slog.Logger) {
|
||||||
gl := &grpcLogger{
|
gl := &grpcLogger{
|
||||||
logger: log.With(slog.String("system", "grpc"), slog.Bool("grpc_log", true)),
|
logger: log.With(slog.String("system", "grpc"), slog.Bool("grpc_log", true)),
|
||||||
verbosity: 0,
|
verbosity: 0,
|
||||||
}
|
}
|
||||||
grpclog.SetLoggerV2(gl)
|
grpclog.SetLoggerV2(gl)
|
||||||
|
@ -31,90 +31,90 @@ type grpcLogger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Info(args ...interface{}) {
|
func (l *grpcLogger) Info(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Infoln(args ...interface{}) {
|
func (l *grpcLogger) Infoln(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Infof(format string, args ...interface{}) {
|
func (l *grpcLogger) Infof(format string, args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprintf(format, args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprintf(format, args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Warning(args ...interface{}) {
|
func (l *grpcLogger) Warning(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Warningln(args ...interface{}) {
|
func (l *grpcLogger) Warningln(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Warningf(format string, args ...interface{}) {
|
func (l *grpcLogger) Warningf(format string, args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprintf(format, args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprintf(format, args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Error(args ...interface{}) {
|
func (l *grpcLogger) Error(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Errorln(args ...interface{}) {
|
func (l *grpcLogger) Errorln(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Errorf(format string, args ...interface{}) {
|
func (l *grpcLogger) Errorf(format string, args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(format, args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(format, args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Fatal(args ...interface{}) {
|
func (l *grpcLogger) Fatal(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Fatalln(args ...interface{}) {
|
func (l *grpcLogger) Fatalln(args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprint(args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) Fatalf(format string, args ...interface{}) {
|
func (l *grpcLogger) Fatalf(format string, args ...interface{}) {
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:])
|
runtime.Callers(2, pcs[:])
|
||||||
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(format, args...), pcs[0])
|
r := slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(format, args...), pcs[0])
|
||||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *grpcLogger) V(level int) bool {
|
func (l *grpcLogger) V(level int) bool {
|
||||||
|
|
|
@ -87,23 +87,23 @@ func middlewareLogger(l *slog.Logger) logging.Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pcs [1]uintptr
|
var pcs [1]uintptr
|
||||||
runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc]
|
runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc]
|
||||||
r := slog.Record{}
|
r := slog.Record{}
|
||||||
|
|
||||||
switch lvl {
|
switch lvl {
|
||||||
case logging.LevelDebug:
|
case logging.LevelDebug:
|
||||||
r = slog.NewRecord(time.Now(), slog.LevelDebug, fmt.Sprintf(msg, fields...), pcs[0])
|
r = slog.NewRecord(time.Now(), slog.LevelDebug, fmt.Sprintf(msg, fields...), pcs[0])
|
||||||
case logging.LevelInfo:
|
case logging.LevelInfo:
|
||||||
r = slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprintf(msg, fields...), pcs[0])
|
r = slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprintf(msg, fields...), pcs[0])
|
||||||
case logging.LevelWarn:
|
case logging.LevelWarn:
|
||||||
r = slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprintf(msg, fields...), pcs[0])
|
r = slog.NewRecord(time.Now(), slog.LevelWarn, fmt.Sprintf(msg, fields...), pcs[0])
|
||||||
case logging.LevelError:
|
case logging.LevelError:
|
||||||
r = slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(msg, fields...), pcs[0])
|
r = slog.NewRecord(time.Now(), slog.LevelError, fmt.Sprintf(msg, fields...), pcs[0])
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("unknown level %v", lvl))
|
panic(fmt.Sprintf("unknown level %v", lvl))
|
||||||
}
|
}
|
||||||
_ = l.Handler().Handle(context.Background(), r)
|
_ = l.Handler().Handle(context.Background(), r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,11 +154,11 @@ func (h *LevelHandler) Handler() slog.Handler {
|
||||||
|
|
||||||
// TestWriter is a writer to a testing.T used in tests for logging with slog.
|
// TestWriter is a writer to a testing.T used in tests for logging with slog.
|
||||||
type TestWriter struct {
|
type TestWriter struct {
|
||||||
T *testing.T
|
T *testing.T
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TestWriter) Write(p []byte) (int, error) {
|
func (t TestWriter) Write(p []byte) (int, error) {
|
||||||
t.T.Helper()
|
t.T.Helper()
|
||||||
t.T.Log(string(p))
|
t.T.Log(string(p))
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package archive
|
package archive
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
|
@ -9,8 +9,8 @@ package nop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
"github.com/edgelesssys/constellation/v2/internal/api/versionsapi"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/osimage"
|
"github.com/edgelesssys/constellation/v2/internal/osimage"
|
||||||
|
|
|
@ -107,7 +107,7 @@ func TestUpload(t *testing.T) {
|
||||||
distributionID: "test-distribution-id",
|
distributionID: "test-distribution-id",
|
||||||
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
||||||
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
||||||
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
_, err := client.Upload(context.Background(), tc.in)
|
_, err := client.Upload(context.Background(), tc.in)
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ func TestDeleteObject(t *testing.T) {
|
||||||
distributionID: "test-distribution-id",
|
distributionID: "test-distribution-id",
|
||||||
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
||||||
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
||||||
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
_, err := client.DeleteObject(context.Background(), newObjectInput(tc.nilInput, tc.nilKey))
|
_, err := client.DeleteObject(context.Background(), newObjectInput(tc.nilInput, tc.nilKey))
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ func TestDeleteObject(t *testing.T) {
|
||||||
distributionID: "test-distribution-id",
|
distributionID: "test-distribution-id",
|
||||||
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
cacheInvalidationStrategy: tc.cacheInvalidationStrategy,
|
||||||
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
||||||
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
_, err := client.DeleteObjects(context.Background(), newObjectsInput(tc.nilInput, tc.nilKey))
|
_, err := client.DeleteObjects(context.Background(), newObjectsInput(tc.nilInput, tc.nilKey))
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ func TestFlush(t *testing.T) {
|
||||||
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
cacheInvalidationWaitTimeout: tc.cacheInvalidationWaitTimeout,
|
||||||
dirtyKeys: tc.dirtyKeys,
|
dirtyKeys: tc.dirtyKeys,
|
||||||
invalidationIDs: tc.invalidationIDs,
|
invalidationIDs: tc.invalidationIDs,
|
||||||
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
err := client.Flush(context.Background())
|
err := client.Flush(context.Background())
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ func TestConcurrency(t *testing.T) {
|
||||||
uploadClient: uploadClient,
|
uploadClient: uploadClient,
|
||||||
distributionID: "test-distribution-id",
|
distributionID: "test-distribution-id",
|
||||||
cacheInvalidationWaitTimeout: 50 * time.Millisecond,
|
cacheInvalidationWaitTimeout: 50 * time.Millisecond,
|
||||||
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
logger: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
|
@ -6,9 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package verify
|
package verify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/snp/testdata"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/snp/testdata"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
|
|
|
@ -10,13 +10,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
|
@ -51,7 +51,7 @@ func main() {
|
||||||
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)}))
|
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)}))
|
||||||
log.With(
|
log.With(
|
||||||
slog.String("version", constants.BinaryVersion().String()),
|
slog.String("version", constants.BinaryVersion().String()),
|
||||||
slog.String("cloudProvider", *provider),
|
slog.String("cloudProvider", *provider),
|
||||||
|
@ -63,27 +63,27 @@ func main() {
|
||||||
kubeClient, err := kubernetes.New()
|
kubeClient, err := kubernetes.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create Kubernetes client")
|
log.With(slog.Any("error", err)).Error("Failed to create Kubernetes client")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
attVariant, err := variant.FromString(*attestationVariant)
|
attVariant, err := variant.FromString(*attestationVariant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
certCacheClient := certcache.NewClient(log.WithGroup("certcache"), kubeClient, attVariant)
|
certCacheClient := certcache.NewClient(log.WithGroup("certcache"), kubeClient, attVariant)
|
||||||
cachedCerts, err := certCacheClient.CreateCertChainCache(context.Background())
|
cachedCerts, err := certCacheClient.CreateCertChainCache(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create certificate chain cache")
|
log.With(slog.Any("error", err)).Error("Failed to create certificate chain cache")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
validator, err := watcher.NewValidator(log.WithGroup("validator"), attVariant, handler, cachedCerts)
|
validator, err := watcher.NewValidator(log.WithGroup("validator"), attVariant, handler, cachedCerts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create validator")
|
log.With(slog.Any("error", err)).Error("Failed to create validator")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
creds := atlscredentials.New(nil, []atls.Validator{validator})
|
creds := atlscredentials.New(nil, []atls.Validator{validator})
|
||||||
|
@ -94,7 +94,7 @@ func main() {
|
||||||
vpcIP, err := getVPCIP(vpcCtx, *provider)
|
vpcIP, err := getVPCIP(vpcCtx, *provider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to get IP in VPC")
|
log.With(slog.Any("error", err)).Error("Failed to get IP in VPC")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
apiServerEndpoint := net.JoinHostPort(vpcIP, strconv.Itoa(constants.KubernetesPort))
|
apiServerEndpoint := net.JoinHostPort(vpcIP, strconv.Itoa(constants.KubernetesPort))
|
||||||
kubeadm, err := kubeadm.New(apiServerEndpoint, log.WithGroup("kubeadm"))
|
kubeadm, err := kubeadm.New(apiServerEndpoint, log.WithGroup("kubeadm"))
|
||||||
|
@ -106,7 +106,7 @@ func main() {
|
||||||
measurementSalt, err := handler.Read(filepath.Join(constants.ServiceBasePath, constants.MeasurementSaltFilename))
|
measurementSalt, err := handler.Read(filepath.Join(constants.ServiceBasePath, constants.MeasurementSaltFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to read measurement salt")
|
log.With(slog.Any("error", err)).Error("Failed to read measurement salt")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
server, err := server.New(
|
server, err := server.New(
|
||||||
|
@ -119,13 +119,13 @@ func main() {
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create server")
|
log.With(slog.Any("error", err)).Error("Failed to create server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher, err := watcher.New(log.WithGroup("fileWatcher"), validator)
|
watcher, err := watcher.New(log.WithGroup("fileWatcher"), validator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create watcher for measurements updates")
|
log.With(slog.Any("error", err)).Error("Failed to create watcher for measurements updates")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer watcher.Close()
|
defer watcher.Close()
|
||||||
|
|
||||||
|
@ -133,13 +133,13 @@ func main() {
|
||||||
log.Info(fmt.Sprintf("starting file watcher for measurements file %s", filepath.Join(constants.ServiceBasePath, constants.AttestationConfigFilename)))
|
log.Info(fmt.Sprintf("starting file watcher for measurements file %s", filepath.Join(constants.ServiceBasePath, constants.AttestationConfigFilename)))
|
||||||
if err := watcher.Watch(filepath.Join(constants.ServiceBasePath, constants.AttestationConfigFilename)); err != nil {
|
if err := watcher.Watch(filepath.Join(constants.ServiceBasePath, constants.AttestationConfigFilename)); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to watch measurements file")
|
log.With(slog.Any("error", err)).Error("Failed to watch measurements file")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := server.Run(creds, strconv.Itoa(constants.JoinServicePort)); err != nil {
|
if err := server.Run(creds, strconv.Itoa(constants.JoinServicePort)); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to run server")
|
log.With(slog.Any("error", err)).Error("Failed to run server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package amdkds
|
package amdkds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"testing"
|
"testing"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/joinservice/internal/certcache/amdkds/testdata"
|
"github.com/edgelesssys/constellation/v2/joinservice/internal/certcache/amdkds/testdata"
|
||||||
|
|
|
@ -121,7 +121,7 @@ func TestCreateCertChainCache(t *testing.T) {
|
||||||
|
|
||||||
c := &Client{
|
c := &Client{
|
||||||
attVariant: variant.Dummy{},
|
attVariant: variant.Dummy{},
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
kubeClient: tc.kubeClient,
|
kubeClient: tc.kubeClient,
|
||||||
kdsClient: tc.kdsClient,
|
kdsClient: tc.kdsClient,
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ func TestGetCertChainCache(t *testing.T) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
c := NewClient(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), tc.kubeClient, variant.Dummy{})
|
c := NewClient(slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)), tc.kubeClient, variant.Dummy{})
|
||||||
|
|
||||||
ask, ark, err := c.getCertChainCache(ctx)
|
ask, ark, err := c.getCertChainCache(ctx)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
|
|
|
@ -55,7 +55,7 @@ func TestGetDataKey(t *testing.T) {
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
|
|
||||||
client := New(
|
client := New(
|
||||||
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
listener.Addr().String(),
|
listener.Addr().String(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ kind: Config`,
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
client := &Kubeadm{
|
client := &Kubeadm{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
file: file.NewHandler(afero.NewMemMapFs()),
|
file: file.NewHandler(afero.NewMemMapFs()),
|
||||||
client: fake.NewSimpleClientset(),
|
client: fake.NewSimpleClientset(),
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ func TestGetControlPlaneCertificatesAndKeys(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
client := &Kubeadm{
|
client := &Kubeadm{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
file: file.NewHandler(afero.NewMemMapFs()),
|
file: file.NewHandler(afero.NewMemMapFs()),
|
||||||
client: fake.NewSimpleClientset(),
|
client: fake.NewSimpleClientset(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ Q29uc3RlbGxhdGlvbg==
|
||||||
}
|
}
|
||||||
|
|
||||||
ca := New(
|
ca := New(
|
||||||
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
fileHandler,
|
fileHandler,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
||||||
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
"github.com/edgelesssys/constellation/v2/joinservice/joinproto"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -163,7 +163,7 @@ func TestIssueJoinTicket(t *testing.T) {
|
||||||
joinTokenGetter: tc.kubeadm,
|
joinTokenGetter: tc.kubeadm,
|
||||||
dataKeyGetter: tc.kms,
|
dataKeyGetter: tc.kms,
|
||||||
kubeClient: &tc.kubeClient,
|
kubeClient: &tc.kubeClient,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &joinproto.IssueJoinTicketRequest{
|
req := &joinproto.IssueJoinTicketRequest{
|
||||||
|
@ -228,7 +228,7 @@ func TestIssueRejoinTicker(t *testing.T) {
|
||||||
ca: stubCA{},
|
ca: stubCA{},
|
||||||
joinTokenGetter: stubTokenGetter{},
|
joinTokenGetter: stubTokenGetter{},
|
||||||
dataKeyGetter: tc.keyGetter,
|
dataKeyGetter: tc.keyGetter,
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
}
|
}
|
||||||
|
|
||||||
req := &joinproto.IssueRejoinTicketRequest{
|
req := &joinproto.IssueRejoinTicketRequest{
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"log/slog"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
|
||||||
|
|
|
@ -88,7 +88,7 @@ func TestNewUpdateableValidator(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := NewValidator(
|
_, err := NewValidator(
|
||||||
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
tc.variant,
|
tc.variant,
|
||||||
handler,
|
handler,
|
||||||
tc.snpCerts,
|
tc.snpCerts,
|
||||||
|
@ -119,7 +119,7 @@ func TestUpdate(t *testing.T) {
|
||||||
|
|
||||||
// create server
|
// create server
|
||||||
validator := &Updatable{
|
validator := &Updatable{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
variant: variant.Dummy{},
|
variant: variant.Dummy{},
|
||||||
fileHandler: handler,
|
fileHandler: handler,
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ func TestOIDConcurrency(t *testing.T) {
|
||||||
|
|
||||||
// create server
|
// create server
|
||||||
validator := &Updatable{
|
validator := &Updatable{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
variant: variant.Dummy{},
|
variant: variant.Dummy{},
|
||||||
fileHandler: handler,
|
fileHandler: handler,
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ func TestUpdateConcurrency(t *testing.T) {
|
||||||
|
|
||||||
handler := file.NewHandler(afero.NewMemMapFs())
|
handler := file.NewHandler(afero.NewMemMapFs())
|
||||||
validator := &Updatable{
|
validator := &Updatable{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
fileHandler: handler,
|
fileHandler: handler,
|
||||||
variant: variant.Dummy{},
|
variant: variant.Dummy{},
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ func TestWatcher(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
watcher := &FileWatcher{
|
watcher := &FileWatcher{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
updater: tc.updater,
|
updater: tc.updater,
|
||||||
watcher: tc.watcher,
|
watcher: tc.watcher,
|
||||||
done: make(chan struct{}, 1),
|
done: make(chan struct{}, 1),
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
"github.com/edgelesssys/constellation/v2/internal/crypto"
|
||||||
|
@ -44,20 +44,20 @@ func main() {
|
||||||
masterKey, err := file.Read(*masterSecretPath)
|
masterKey, err := file.Read(*masterSecretPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to read master secret")
|
log.With(slog.Any("error", err)).Error("Failed to read master secret")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(masterKey) < crypto.MasterSecretLengthMin {
|
if len(masterKey) < crypto.MasterSecretLengthMin {
|
||||||
log.With(slog.Any("error", errors.New("invalid key length"))).Error(fmt.Sprintf("Provided master secret is smaller than the required minimum of %d bytes", crypto.MasterSecretLengthMin))
|
log.With(slog.Any("error", errors.New("invalid key length"))).Error(fmt.Sprintf("Provided master secret is smaller than the required minimum of %d bytes", crypto.MasterSecretLengthMin))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
salt, err := file.Read(*saltPath)
|
salt, err := file.Read(*saltPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to read salt")
|
log.With(slog.Any("error", err)).Error("Failed to read salt")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(salt) < crypto.RNGLengthDefault {
|
if len(salt) < crypto.RNGLengthDefault {
|
||||||
log.With(slog.Any("error", errors.New("invalid salt length"))).Error(fmt.Sprintf("Expected salt to be %d bytes, but got %d", crypto.RNGLengthDefault, len(salt)))
|
log.With(slog.Any("error", errors.New("invalid salt length"))).Error(fmt.Sprintf("Expected salt to be %d bytes, but got %d", crypto.RNGLengthDefault, len(salt)))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
masterSecret := uri.MasterSecret{Key: masterKey, Salt: salt}
|
masterSecret := uri.MasterSecret{Key: masterKey, Salt: salt}
|
||||||
|
|
||||||
|
@ -67,12 +67,12 @@ func main() {
|
||||||
conKMS, err := setup.KMS(ctx, uri.NoStoreURI, masterSecret.EncodeToURI())
|
conKMS, err := setup.KMS(ctx, uri.NoStoreURI, masterSecret.EncodeToURI())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to setup KMS")
|
log.With(slog.Any("error", err)).Error("Failed to setup KMS")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer conKMS.Close()
|
defer conKMS.Close()
|
||||||
|
|
||||||
if err := server.New(log.WithGroup("keyService"), conKMS).Run(*port); err != nil {
|
if err := server.New(log.WithGroup("keyService"), conKMS).Run(*port); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to run key-service server")
|
log.With(slog.Any("error", err)).Error("Failed to run key-service server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestGetDataKey(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
log := slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil))
|
||||||
|
|
||||||
kms := &stubKMS{derivedKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x5}}
|
kms := &stubKMS{derivedKey: []byte{0x0, 0x1, 0x2, 0x3, 0x4, 0x5}}
|
||||||
api := New(log, kms)
|
api := New(log, kms)
|
||||||
|
|
|
@ -24,7 +24,7 @@ func main() {
|
||||||
attestationVariant, err := variant.FromString(variantString)
|
attestationVariant, err := variant.FromString(variantString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var m []sorted.Measurement
|
var m []sorted.Measurement
|
||||||
|
@ -33,17 +33,17 @@ func main() {
|
||||||
m, err = tpm.Measurements()
|
m, err = tpm.Measurements()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to read TPM measurements")
|
log.With(slog.Any("error", err)).Error("Failed to read TPM measurements")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
case variant.QEMUTDX{}:
|
case variant.QEMUTDX{}:
|
||||||
m, err = tdx.Measurements()
|
m, err = tdx.Measurements()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to read Intel TDX measurements")
|
log.With(slog.Any("error", err)).Error("Failed to read Intel TDX measurements")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.With(slog.String("attestationVariant", variantString)).Error("Unsupported attestation variant")
|
log.With(slog.String("attestationVariant", variantString)).Error("Unsupported attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Measurements:")
|
fmt.Println("Measurements:")
|
||||||
|
|
|
@ -55,7 +55,7 @@ func TestGetDataKey(t *testing.T) {
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
|
|
||||||
client := New(
|
client := New(
|
||||||
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
listener.Addr().String(),
|
listener.Addr().String(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,12 @@ func main() {
|
||||||
server, err := server.New(log, handler)
|
server, err := server.New(log, handler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create update server")
|
log.With(slog.Any("error", err)).Error("Failed to create update server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = server.Run(protocol, constants.UpgradeAgentSocketPath)
|
err = server.Run(protocol, constants.UpgradeAgentSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to start update server")
|
log.With(slog.Any("error", err)).Error("Failed to start update server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,56 +7,56 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/verify/server"
|
"github.com/edgelesssys/constellation/v2/verify/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
attestationVariant := flag.String("attestation-variant", "", "attestation variant to use for aTLS connections")
|
attestationVariant := flag.String("attestation-variant", "", "attestation variant to use for aTLS connections")
|
||||||
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)}))
|
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: logger.VerbosityFromInt(*verbosity)}))
|
||||||
|
|
||||||
log.With(slog.String("version", constants.BinaryVersion().String()), slog.String("attestationVariant", *attestationVariant)).
|
log.With(slog.String("version", constants.BinaryVersion().String()), slog.String("attestationVariant", *attestationVariant)).
|
||||||
Info("Constellation Verification Service")
|
Info("Constellation Verification Service")
|
||||||
|
|
||||||
variant, err := variant.FromString(*attestationVariant)
|
variant, err := variant.FromString(*attestationVariant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
issuer, err := choose.Issuer(variant, log.WithGroup("issuer"))
|
issuer, err := choose.Issuer(variant, log.WithGroup("issuer"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to create issuer")
|
log.With(slog.Any("error", err)).Error("Failed to create issuer")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
server := server.New(log.WithGroup("server"), issuer)
|
server := server.New(log.WithGroup("server"), issuer)
|
||||||
httpListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortHTTP)))
|
httpListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortHTTP)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortHTTP)).
|
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortHTTP)).
|
||||||
Error("Failed to listen")
|
Error("Failed to listen")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
grpcListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortGRPC)))
|
grpcListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortGRPC)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortGRPC)).
|
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortGRPC)).
|
||||||
Error("Failed to listen")
|
Error("Failed to listen")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := server.Run(httpListener, grpcListener); err != nil {
|
if err := server.Run(httpListener, grpcListener); err != nil {
|
||||||
log.With(slog.Any("error", err)).Error("Failed to run server")
|
log.With(slog.Any("error", err)).Error("Failed to run server")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
"github.com/edgelesssys/constellation/v2/internal/grpc/testdialer"
|
||||||
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"github.com/edgelesssys/constellation/v2/verify/verifyproto"
|
"github.com/edgelesssys/constellation/v2/verify/verifyproto"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
|
@ -38,7 +38,7 @@ func TestRun(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
s := &Server{
|
s := &Server{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
issuer: stubIssuer{attestation: []byte("quote")},
|
issuer: stubIssuer{attestation: []byte("quote")},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ func TestGetAttestationGRPC(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
server := &Server{
|
server := &Server{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
issuer: tc.issuer,
|
issuer: tc.issuer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func TestGetAttestationHTTP(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
server := &Server{
|
server := &Server{
|
||||||
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
log: slog.New(slog.NewTextHandler(logger.TestWriter{T: t}, nil)),
|
||||||
issuer: tc.issuer,
|
issuer: tc.issuer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue