mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-11 23:49:30 -05:00
deps: replace multierr with native errors.Join
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
955316c661
commit
12c866bcb9
@ -8,10 +8,9 @@ package cloudcmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// rollbacker does a rollback.
|
// rollbacker does a rollback.
|
||||||
@ -28,7 +27,7 @@ func rollbackOnError(ctx context.Context, w io.Writer, onErr *error, roll rollba
|
|||||||
fmt.Fprintf(w, "An error occurred: %s\n", *onErr)
|
fmt.Fprintf(w, "An error occurred: %s\n", *onErr)
|
||||||
fmt.Fprintln(w, "Attempting to roll back.")
|
fmt.Fprintln(w, "Attempting to roll back.")
|
||||||
if err := roll.rollback(ctx); err != nil {
|
if err := roll.rollback(ctx); err != nil {
|
||||||
*onErr = multierr.Append(*onErr, fmt.Errorf("on rollback: %w", err)) // TODO: print the error, or return it?
|
*onErr = errors.Join(*onErr, fmt.Errorf("on rollback: %w", err)) // TODO: print the error, or return it?
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, "Rollback succeeded.")
|
fmt.Fprintln(w, "Rollback succeeded.")
|
||||||
@ -40,9 +39,9 @@ type rollbackerTerraform struct {
|
|||||||
|
|
||||||
func (r *rollbackerTerraform) rollback(ctx context.Context) error {
|
func (r *rollbackerTerraform) rollback(ctx context.Context) error {
|
||||||
var err error
|
var err error
|
||||||
err = multierr.Append(err, r.client.Destroy(ctx))
|
err = errors.Join(err, r.client.Destroy(ctx))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = multierr.Append(err, r.client.CleanUpWorkspace())
|
err = errors.Join(err, r.client.CleanUpWorkspace())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -56,9 +55,9 @@ type rollbackerQEMU struct {
|
|||||||
func (r *rollbackerQEMU) rollback(ctx context.Context) error {
|
func (r *rollbackerQEMU) rollback(ctx context.Context) error {
|
||||||
var err error
|
var err error
|
||||||
if r.createdWorkspace {
|
if r.createdWorkspace {
|
||||||
err = multierr.Append(err, r.client.Destroy(ctx))
|
err = errors.Join(err, r.client.Destroy(ctx))
|
||||||
}
|
}
|
||||||
err = multierr.Append(err, r.libvirt.Stop(ctx))
|
err = errors.Join(err, r.libvirt.Stop(ctx))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = r.client.CleanUpWorkspace()
|
err = r.client.CleanUpWorkspace()
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"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/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Validator validates Platform Configuration Registers (PCRs).
|
// Validator validates Platform Configuration Registers (PCRs).
|
||||||
@ -84,10 +83,7 @@ func (v *Validator) updatePCR(pcrIndex uint32, encoded string) error {
|
|||||||
hexErr := err
|
hexErr := err
|
||||||
decoded, err = base64.StdEncoding.DecodeString(encoded)
|
decoded, err = base64.StdEncoding.DecodeString(encoded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return multierr.Append(
|
return fmt.Errorf("input [%s] could neither be hex decoded (%w) nor base64 decoded (%w)", encoded, hexErr, err)
|
||||||
fmt.Errorf("input [%s] is not hex encoded: %w", encoded, hexErr),
|
|
||||||
fmt.Errorf("input [%s] is not base64 encoded: %w", encoded, err),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// new_pcr_value := hash(old_pcr_value || data_to_extend)
|
// new_pcr_value := hash(old_pcr_value || data_to_extend)
|
||||||
|
@ -8,6 +8,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -80,8 +81,12 @@ func (cfm *configFetchMeasurementsCmd) configFetchMeasurements(
|
|||||||
|
|
||||||
cfm.log.Debugf("Loading configuration file from %q", flags.configPath)
|
cfm.log.Debugf("Loading configuration file from %q", flags.configPath)
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !conf.IsReleaseImage() {
|
if !conf.IsReleaseImage() {
|
||||||
|
@ -73,8 +73,12 @@ func (c *createCmd) create(cmd *cobra.Command, creator cloudCreator, fileHandler
|
|||||||
|
|
||||||
c.log.Debugf("Loading configuration file from %q", flags.configPath)
|
c.log.Debugf("Loading configuration file from %q", flags.configPath)
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.log.Debugf("Checking configuration for warnings")
|
c.log.Debugf("Checking configuration for warnings")
|
||||||
|
@ -104,8 +104,12 @@ func (i *initCmd) initialize(cmd *cobra.Command, newDialer func(validator *cloud
|
|||||||
i.log.Debugf("Using flags: %+v", flags)
|
i.log.Debugf("Using flags: %+v", flags)
|
||||||
i.log.Debugf("Loading configuration file from %q", flags.configPath)
|
i.log.Debugf("Loading configuration file from %q", flags.configPath)
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
i.log.Debugf("Checking cluster ID file")
|
i.log.Debugf("Checking cluster ID file")
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func newMiniDownCmd() *cobra.Command {
|
func newMiniDownCmd() *cobra.Command {
|
||||||
@ -39,7 +38,7 @@ func runDown(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
err := runTerminate(cmd, args)
|
err := runTerminate(cmd, args)
|
||||||
if removeErr := os.Remove(constants.MasterSecretFilename); removeErr != nil && !os.IsNotExist(removeErr) {
|
if removeErr := os.Remove(constants.MasterSecretFilename); removeErr != nil && !os.IsNotExist(removeErr) {
|
||||||
err = multierr.Append(err, removeErr)
|
err = errors.Join(err, removeErr)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,12 @@ func (m *miniUpCmd) prepareConfig(cmd *cobra.Command, fileHandler file.Handler)
|
|||||||
// check for existing config
|
// check for existing config
|
||||||
if configPath != "" {
|
if configPath != "" {
|
||||||
conf, err := config.New(fileHandler, configPath, force)
|
conf, err := config.New(fileHandler, configPath, force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return nil, err
|
||||||
}
|
}
|
||||||
if conf.GetProvider() != cloudprovider.QEMU {
|
if conf.GetProvider() != cloudprovider.QEMU {
|
||||||
return nil, errors.New("invalid provider for MiniConstellation cluster")
|
return nil, errors.New("invalid provider for MiniConstellation cluster")
|
||||||
|
@ -8,6 +8,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -80,9 +81,14 @@ func (r *recoverCmd) recover(
|
|||||||
|
|
||||||
r.log.Debugf("Loading configuration file from %q", flags.configPath)
|
r.log.Debugf("Loading configuration file from %q", flags.configPath)
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
if err != nil {
|
var configValidationErr *config.ValidationError
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
provider := conf.GetProvider()
|
provider := conf.GetProvider()
|
||||||
r.log.Debugf("Got provider %s", provider.String())
|
r.log.Debugf("Got provider %s", provider.String())
|
||||||
if provider == cloudprovider.Azure {
|
if provider == cloudprovider.Azure {
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/multierr"
|
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
@ -79,11 +78,11 @@ func terminate(cmd *cobra.Command, terminator cloudTerminator, fileHandler file.
|
|||||||
|
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := fileHandler.Remove(constants.AdminConfFilename); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
if err := fileHandler.Remove(constants.AdminConfFilename); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||||
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.AdminConfFilename))
|
retErr = errors.Join(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.AdminConfFilename))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := fileHandler.Remove(constants.ClusterIDsFileName); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
if err := fileHandler.Remove(constants.ClusterIDsFileName); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||||
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.ClusterIDsFileName))
|
retErr = errors.Join(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.ClusterIDsFileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
|
@ -74,8 +74,12 @@ func (u *upgradeApplyCmd) upgradeApply(cmd *cobra.Command, imageFetcher imageFet
|
|||||||
return fmt.Errorf("parsing flags: %w", err)
|
return fmt.Errorf("parsing flags: %w", err)
|
||||||
}
|
}
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := u.handleServiceUpgrade(cmd, conf, flags); err != nil {
|
if err := u.handleServiceUpgrade(cmd, conf, flags); err != nil {
|
||||||
|
@ -127,8 +127,12 @@ type upgradeCheckCmd struct {
|
|||||||
// upgradePlan plans an upgrade of a Constellation cluster.
|
// upgradePlan plans an upgrade of a Constellation cluster.
|
||||||
func (u *upgradeCheckCmd) upgradeCheck(cmd *cobra.Command, fileHandler file.Handler, flags upgradeCheckFlags) error {
|
func (u *upgradeCheckCmd) upgradeCheck(cmd *cobra.Command, fileHandler file.Handler, flags upgradeCheckFlags) error {
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
u.log.Debugf("Read configuration from %q", flags.configPath)
|
u.log.Debugf("Read configuration from %q", flags.configPath)
|
||||||
// get current image version of the cluster
|
// get current image version of the cluster
|
||||||
|
@ -76,8 +76,12 @@ func (v *verifyCmd) verify(cmd *cobra.Command, fileHandler file.Handler, verifyC
|
|||||||
|
|
||||||
v.log.Debugf("Loading configuration file from %q", flags.configPath)
|
v.log.Debugf("Loading configuration file from %q", flags.configPath)
|
||||||
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
conf, err := config.New(fileHandler, flags.configPath, flags.force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
provider := conf.GetProvider()
|
provider := conf.GetProvider()
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"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"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPrepareCluster(t *testing.T) {
|
func TestPrepareCluster(t *testing.T) {
|
||||||
@ -682,10 +681,13 @@ func TestCleanupWorkspace(t *testing.T) {
|
|||||||
"files are cleaned up": {
|
"files are cleaned up": {
|
||||||
provider: cloudprovider.QEMU,
|
provider: cloudprovider.QEMU,
|
||||||
prepareFS: func(f file.Handler) error {
|
prepareFS: func(f file.Handler) error {
|
||||||
var err error
|
if err := f.Write("terraform.tfvars", someContent); err != nil {
|
||||||
err = multierr.Append(err, f.Write("terraform.tfvars", someContent))
|
return err
|
||||||
err = multierr.Append(err, f.Write("terraform.tfstate", someContent))
|
}
|
||||||
return multierr.Append(err, f.Write("terraform.tfstate.backup", someContent))
|
if err := f.Write("terraform.tfstate", someContent); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return f.Write("terraform.tfstate.backup", someContent)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"no error if files do not exist": {
|
"no error if files do not exist": {
|
||||||
|
@ -8,6 +8,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -68,8 +69,12 @@ func runDeploy(cmd *cobra.Command, args []string) error {
|
|||||||
streamer := streamer.New(fs)
|
streamer := streamer.New(fs)
|
||||||
transfer := filetransfer.New(log, streamer, filetransfer.ShowProgress)
|
transfer := filetransfer.New(log, streamer, filetransfer.ShowProgress)
|
||||||
constellationConfig, err := config.New(fileHandler, configName, force)
|
constellationConfig, err := config.New(fileHandler, configName, force)
|
||||||
|
var configValidationErr *config.ValidationError
|
||||||
|
if errors.As(err, &configValidationErr) {
|
||||||
|
cmd.PrintErrln(configValidationErr.LongMessage())
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config.DisplayValidationErrors(cmd.ErrOrStderr(), err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return deploy(cmd, fileHandler, constellationConfig, transfer, log)
|
return deploy(cmd, fileHandler, constellationConfig, transfer, log)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
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/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
@ -116,14 +115,9 @@ func (s *debugdServer) UploadFiles(stream pb.Debugd_UploadFilesServer) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// continue on error to allow other units to be overridden
|
// continue on error to allow other units to be overridden
|
||||||
// TODO: switch to native go multierror once 1.20 is released
|
|
||||||
// err = s.serviceManager.OverrideServiceUnitExecStart(stream.Context(), file.OverrideServiceUnit, file.TargetPath)
|
|
||||||
// if err != nil {
|
|
||||||
// overrideUnitErr = errors.Join(overrideUnitErr, err)
|
|
||||||
// }
|
|
||||||
err = s.serviceManager.OverrideServiceUnitExecStart(stream.Context(), file.OverrideServiceUnit, file.TargetPath)
|
err = s.serviceManager.OverrideServiceUnitExecStart(stream.Context(), file.OverrideServiceUnit, file.TargetPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
overrideUnitErr = multierr.Append(overrideUnitErr, err)
|
overrideUnitErr = errors.Join(overrideUnitErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -91,7 +91,6 @@ require (
|
|||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.6.1
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
go.uber.org/goleak v1.2.1
|
go.uber.org/goleak v1.2.1
|
||||||
go.uber.org/multierr v1.9.0
|
|
||||||
go.uber.org/zap v1.24.0
|
go.uber.org/zap v1.24.0
|
||||||
golang.org/x/crypto v0.6.0
|
golang.org/x/crypto v0.6.0
|
||||||
golang.org/x/mod v0.8.0
|
golang.org/x/mod v0.8.0
|
||||||
@ -298,6 +297,7 @@ require (
|
|||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.starlark.net v0.0.0-20220223235035-243c74974e97 // indirect
|
go.starlark.net v0.0.0-20220223235035-243c74974e97 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
||||||
golang.org/x/net v0.6.0 // indirect
|
golang.org/x/net v0.6.0 // indirect
|
||||||
golang.org/x/oauth2 v0.4.0 // indirect
|
golang.org/x/oauth2 v0.4.0 // indirect
|
||||||
|
@ -44,7 +44,6 @@ require (
|
|||||||
github.com/spf13/cobra v1.6.1
|
github.com/spf13/cobra v1.6.1
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
go.uber.org/goleak v1.2.1
|
go.uber.org/goleak v1.2.1
|
||||||
go.uber.org/multierr v1.9.0
|
|
||||||
go.uber.org/zap v1.24.0
|
go.uber.org/zap v1.24.0
|
||||||
golang.org/x/mod v0.8.0
|
golang.org/x/mod v0.8.0
|
||||||
google.golang.org/grpc v1.51.0
|
google.golang.org/grpc v1.51.0
|
||||||
@ -268,6 +267,7 @@ require (
|
|||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.starlark.net v0.0.0-20220223235035-243c74974e97 // indirect
|
go.starlark.net v0.0.0-20220223235035-243c74974e97 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
golang.org/x/crypto v0.6.0 // indirect
|
golang.org/x/crypto v0.6.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
||||||
golang.org/x/net v0.6.0 // indirect
|
golang.org/x/net v0.6.0 // indirect
|
||||||
|
@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -18,7 +19,6 @@ import (
|
|||||||
"github.com/edgelesssys/constellation/v2/hack/image-measurement/server"
|
"github.com/edgelesssys/constellation/v2/hack/image-measurement/server"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -46,7 +46,7 @@ func (l *libvirtInstance) uploadBaseImage(baseVolume *libvirt.StorageVol) (err e
|
|||||||
return fmt.Errorf("error while opening %s: %s", l.imagePath, err)
|
return fmt.Errorf("error while opening %s: %s", l.imagePath, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err = multierr.Append(err, file.Close())
|
err = errors.Join(err, file.Close())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
fi, err := file.Stat()
|
fi, err := file.Stat()
|
||||||
@ -276,9 +276,9 @@ func (l *libvirtInstance) deletePool() error {
|
|||||||
|
|
||||||
func (l *libvirtInstance) deleteLibvirtInstance() error {
|
func (l *libvirtInstance) deleteLibvirtInstance() error {
|
||||||
var err error
|
var err error
|
||||||
err = multierr.Append(err, l.deleteNetwork())
|
err = errors.Join(err, l.deleteNetwork())
|
||||||
err = multierr.Append(err, l.deleteDomain())
|
err = errors.Join(err, l.deleteDomain())
|
||||||
err = multierr.Append(err, l.deletePool())
|
err = errors.Join(err, l.deletePool())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ func (l *libvirtInstance) obtainMeasurements() (measurements measurements.M, err
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer func() {
|
defer func() {
|
||||||
err = multierr.Append(err, l.deleteLibvirtInstance())
|
err = errors.Join(err, l.deleteLibvirtInstance())
|
||||||
}()
|
}()
|
||||||
if err := l.createLibvirtInstance(); err != nil {
|
if err := l.createLibvirtInstance(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -9,10 +9,10 @@ package idkeydigest
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// IDKeyDigests is a list of trusted digest values for the ID key.
|
// IDKeyDigests is a list of trusted digest values for the ID key.
|
||||||
@ -60,7 +60,7 @@ func (d *IDKeyDigests) UnmarshalYAML(unmarshal func(any) error) error {
|
|||||||
// Unmarshalling failed, IDKeyDigests might be a simple string instead of IDKeyDigests struct.
|
// Unmarshalling failed, IDKeyDigests might be a simple string instead of IDKeyDigests struct.
|
||||||
var unmarshalledString string
|
var unmarshalledString string
|
||||||
if legacyErr := unmarshal(&unmarshalledString); legacyErr != nil {
|
if legacyErr := unmarshal(&unmarshalledString); legacyErr != nil {
|
||||||
return multierr.Append(
|
return errors.Join(
|
||||||
err,
|
err,
|
||||||
fmt.Errorf("trying legacy format: %w", legacyErr),
|
fmt.Errorf("trying legacy format: %w", legacyErr),
|
||||||
)
|
)
|
||||||
@ -89,7 +89,7 @@ func (d *IDKeyDigests) UnmarshalJSON(b []byte) error {
|
|||||||
// Unmarshalling failed, IDKeyDigests might be a simple string instead of IDKeyDigests struct.
|
// Unmarshalling failed, IDKeyDigests might be a simple string instead of IDKeyDigests struct.
|
||||||
var unmarshalledString string
|
var unmarshalledString string
|
||||||
if legacyErr := json.Unmarshal(b, &unmarshalledString); legacyErr != nil {
|
if legacyErr := json.Unmarshal(b, &unmarshalledString); legacyErr != nil {
|
||||||
return multierr.Append(
|
return errors.Join(
|
||||||
err,
|
err,
|
||||||
fmt.Errorf("trying legacy format: %w", legacyErr),
|
fmt.Errorf("trying legacy format: %w", legacyErr),
|
||||||
)
|
)
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -31,7 +32,6 @@ import (
|
|||||||
"github.com/edgelesssys/constellation/v2/internal/sigstore"
|
"github.com/edgelesssys/constellation/v2/internal/sigstore"
|
||||||
"github.com/google/go-tpm/tpmutil"
|
"github.com/google/go-tpm/tpmutil"
|
||||||
"github.com/siderolabs/talos/pkg/machinery/config/encoder"
|
"github.com/siderolabs/talos/pkg/machinery/config/encoder"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ func (m *M) FetchAndVerify(
|
|||||||
var mWithMetadata WithMetadata
|
var mWithMetadata WithMetadata
|
||||||
if err := json.Unmarshal(measurements, &mWithMetadata); err != nil {
|
if err := json.Unmarshal(measurements, &mWithMetadata); err != nil {
|
||||||
if yamlErr := yaml.Unmarshal(measurements, &mWithMetadata); yamlErr != nil {
|
if yamlErr := yaml.Unmarshal(measurements, &mWithMetadata); yamlErr != nil {
|
||||||
return "", multierr.Append(
|
return "", errors.Join(
|
||||||
err,
|
err,
|
||||||
fmt.Errorf("trying yaml format: %w", yamlErr),
|
fmt.Errorf("trying yaml format: %w", yamlErr),
|
||||||
)
|
)
|
||||||
@ -193,7 +193,7 @@ func (m *Measurement) UnmarshalJSON(b []byte) error {
|
|||||||
// Unmarshalling failed, Measurement might be a simple string instead of Measurement struct.
|
// Unmarshalling failed, Measurement might be a simple string instead of Measurement struct.
|
||||||
// These values will always be enforced.
|
// These values will always be enforced.
|
||||||
if legacyErr := json.Unmarshal(b, &eM.Expected); legacyErr != nil {
|
if legacyErr := json.Unmarshal(b, &eM.Expected); legacyErr != nil {
|
||||||
return multierr.Append(
|
return errors.Join(
|
||||||
err,
|
err,
|
||||||
fmt.Errorf("trying legacy format: %w", legacyErr),
|
fmt.Errorf("trying legacy format: %w", legacyErr),
|
||||||
)
|
)
|
||||||
@ -222,7 +222,7 @@ func (m *Measurement) UnmarshalYAML(unmarshal func(any) error) error {
|
|||||||
// Unmarshalling failed, Measurement might be a simple string instead of Measurement struct.
|
// Unmarshalling failed, Measurement might be a simple string instead of Measurement struct.
|
||||||
// These values will always be enforced.
|
// These values will always be enforced.
|
||||||
if legacyErr := unmarshal(&eM.Expected); legacyErr != nil {
|
if legacyErr := unmarshal(&eM.Expected); legacyErr != nil {
|
||||||
return multierr.Append(
|
return errors.Join(
|
||||||
err,
|
err,
|
||||||
fmt.Errorf("trying legacy format: %w", legacyErr),
|
fmt.Errorf("trying legacy format: %w", legacyErr),
|
||||||
)
|
)
|
||||||
@ -252,7 +252,7 @@ func (m *Measurement) unmarshal(eM encodedMeasurement) error {
|
|||||||
hexErr := err
|
hexErr := err
|
||||||
expected, err = base64.StdEncoding.DecodeString(eM.Expected)
|
expected, err = base64.StdEncoding.DecodeString(eM.Expected)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return multierr.Append(
|
return errors.Join(
|
||||||
fmt.Errorf("invalid measurement: not a hex string %w", hexErr),
|
fmt.Errorf("invalid measurement: not a hex string %w", hexErr),
|
||||||
fmt.Errorf("not a base64 string: %w", err),
|
fmt.Errorf("not a base64 string: %w", err),
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
ut "github.com/go-playground/universal-translator"
|
ut "github.com/go-playground/universal-translator"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
en_translations "github.com/go-playground/validator/v10/translations/en"
|
en_translations "github.com/go-playground/validator/v10/translations/en"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Measurements is a required alias since docgen is not able to work with
|
// Measurements is a required alias since docgen is not able to work with
|
||||||
@ -586,12 +585,10 @@ func (c *Config) Validate(force bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var validationErrors error
|
var validationErrMsgs []string
|
||||||
for _, e := range errs {
|
for _, e := range errs {
|
||||||
validationErrors = multierr.Append(
|
validationErrMsgs = append(validationErrMsgs, e.Translate(trans))
|
||||||
validationErrors,
|
|
||||||
errors.New(e.Translate(trans)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return validationErrors
|
|
||||||
|
return &ValidationError{validationErrMsgs: validationErrMsgs}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"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"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
@ -185,19 +184,13 @@ func TestNewWithDefaultOptions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
const defaultErrCount = 21 // expect this number of error messages by default because user-specific values are not set and multiple providers are defined by default
|
|
||||||
const azErrCount = 9
|
|
||||||
const gcpErrCount = 6
|
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
cnf *Config
|
cnf *Config
|
||||||
wantErr bool
|
wantErr bool
|
||||||
wantErrCount int
|
|
||||||
}{
|
}{
|
||||||
"default config is not valid": {
|
"default config is not valid": {
|
||||||
cnf: Default(),
|
cnf: Default(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: defaultErrCount,
|
|
||||||
},
|
},
|
||||||
"v0 is one error": {
|
"v0 is one error": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -206,7 +199,6 @@ func TestValidate(t *testing.T) {
|
|||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: defaultErrCount + 1,
|
|
||||||
},
|
},
|
||||||
"v0 and negative state disk are two errors": {
|
"v0 and negative state disk are two errors": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -216,7 +208,6 @@ func TestValidate(t *testing.T) {
|
|||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: defaultErrCount + 2,
|
|
||||||
},
|
},
|
||||||
"default Azure config is not valid": {
|
"default Azure config is not valid": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -227,7 +218,6 @@ func TestValidate(t *testing.T) {
|
|||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: azErrCount,
|
|
||||||
},
|
},
|
||||||
"Azure config with all required fields is valid": {
|
"Azure config with all required fields is valid": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -256,7 +246,6 @@ func TestValidate(t *testing.T) {
|
|||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: gcpErrCount,
|
|
||||||
},
|
},
|
||||||
"GCP config with all required fields is valid": {
|
"GCP config with all required fields is valid": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -302,7 +291,6 @@ func TestValidate(t *testing.T) {
|
|||||||
err := tc.cnf.Validate(false)
|
err := tc.cnf.Validate(false)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Len(multierr.Errors(err), tc.wantErrCount)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -25,22 +24,27 @@ import (
|
|||||||
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||||
ut "github.com/go-playground/universal-translator"
|
ut "github.com/go-playground/universal-translator"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DisplayValidationErrors shows all validation errors inside configError as one formatted string.
|
// ValidationError occurs when the validation of a config fails.
|
||||||
func DisplayValidationErrors(errWriter io.Writer, configError error) error {
|
// It contains a list of errors that occurred during validation.
|
||||||
errs := multierr.Errors(configError)
|
type ValidationError struct {
|
||||||
if errs != nil {
|
validationErrMsgs []string
|
||||||
fmt.Fprintln(errWriter, "Problems validating config file:")
|
}
|
||||||
for _, err := range errs {
|
|
||||||
fmt.Fprintln(errWriter, "\t"+err.Error())
|
func (e *ValidationError) Error() string {
|
||||||
|
return "invalid configuration"
|
||||||
|
}
|
||||||
|
|
||||||
|
// LongMessage prints the errors that occurred during validation in a verbose and user friendly way.
|
||||||
|
func (e *ValidationError) LongMessage() string {
|
||||||
|
msg := "Problems validating config file:\n"
|
||||||
|
for _, ve := range e.validationErrMsgs {
|
||||||
|
msg += fmt.Sprintf("\t%s\n", ve)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(errWriter, "Fix the invalid entries or generate a new configuration using `constellation config generate`")
|
msg += "Fix the invalid entries or generate a new configuration using `constellation config generate`"
|
||||||
return errors.New("invalid configuration")
|
return msg
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerInvalidK8sVersionError(ut ut.Translator) error {
|
func registerInvalidK8sVersionError(ut ut.Translator) error {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net"
|
"net"
|
||||||
@ -26,7 +27,6 @@ import (
|
|||||||
"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"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"google.golang.org/grpc/test/bufconn"
|
"google.golang.org/grpc/test/bufconn"
|
||||||
testclock "k8s.io/utils/clock/testing"
|
testclock "k8s.io/utils/clock/testing"
|
||||||
)
|
)
|
||||||
@ -737,10 +737,10 @@ func (w *tarGzWriter) Bytes() []byte {
|
|||||||
|
|
||||||
func (w *tarGzWriter) Close() (result error) {
|
func (w *tarGzWriter) Close() (result error) {
|
||||||
if err := w.tarWriter.Close(); err != nil {
|
if err := w.tarWriter.Close(); err != nil {
|
||||||
result = multierr.Append(result, err)
|
result = errors.Join(result, err)
|
||||||
}
|
}
|
||||||
if err := w.gzWriter.Close(); err != nil {
|
if err := w.gzWriter.Close(); err != nil {
|
||||||
result = multierr.Append(result, err)
|
result = errors.Join(result, err)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
verclient "github.com/edgelesssys/constellation/v2/internal/versionsapi/client"
|
verclient "github.com/edgelesssys/constellation/v2/internal/versionsapi/client"
|
||||||
gaxv2 "github.com/googleapis/gax-go/v2"
|
gaxv2 "github.com/googleapis/gax-go/v2"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -141,12 +140,12 @@ func deleteSingleVersion(ctx context.Context, clients rmImageClients, ver versio
|
|||||||
|
|
||||||
log.Debugf("Deleting images for %s", ver.Version)
|
log.Debugf("Deleting images for %s", ver.Version)
|
||||||
if err := deleteImage(ctx, clients, ver, dryrun, log); err != nil {
|
if err := deleteImage(ctx, clients, ver, dryrun, log); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting images: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting images: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Deleting version %s from versions API", ver.Version)
|
log.Debugf("Deleting version %s from versions API", ver.Version)
|
||||||
if err := clients.version.DeleteVersion(ctx, ver); err != nil {
|
if err := clients.version.DeleteVersion(ctx, ver); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting version from versions API: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting version from versions API: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
@ -182,13 +181,13 @@ func deleteRef(ctx context.Context, clients rmImageClients, ref string, dryrun b
|
|||||||
|
|
||||||
for _, ver := range vers {
|
for _, ver := range vers {
|
||||||
if err := deleteImage(ctx, clients, ver, dryrun, log); err != nil {
|
if err := deleteImage(ctx, clients, ver, dryrun, log); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting images for version %s: %w", ver.Version, err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting images for version %s: %w", ver.Version, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Deleting ref %s from versions API", ref)
|
log.Infof("Deleting ref %s from versions API", ref)
|
||||||
if err := clients.version.DeleteRef(ctx, ref); err != nil {
|
if err := clients.version.DeleteRef(ctx, ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting ref from versions API: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting ref from versions API: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
@ -215,21 +214,21 @@ func deleteImage(ctx context.Context, clients rmImageClients, ver versionsapi.Ve
|
|||||||
log.Infof("Deleting AWS images from %s", imageInfo.JSONPath())
|
log.Infof("Deleting AWS images from %s", imageInfo.JSONPath())
|
||||||
for awsRegion, awsImage := range imageInfo.AWS {
|
for awsRegion, awsImage := range imageInfo.AWS {
|
||||||
if err := clients.aws.deleteImage(ctx, awsImage, awsRegion, dryrun, log); err != nil {
|
if err := clients.aws.deleteImage(ctx, awsImage, awsRegion, dryrun, log); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting AWS image %s: %w", awsImage, err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting AWS image %s: %w", awsImage, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Deleting GCP images from %s", imageInfo.JSONPath())
|
log.Infof("Deleting GCP images from %s", imageInfo.JSONPath())
|
||||||
for _, gcpImage := range imageInfo.GCP {
|
for _, gcpImage := range imageInfo.GCP {
|
||||||
if err := clients.gcp.deleteImage(ctx, gcpImage, dryrun, log); err != nil {
|
if err := clients.gcp.deleteImage(ctx, gcpImage, dryrun, log); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting GCP image %s: %w", gcpImage, err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting GCP image %s: %w", gcpImage, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Deleting Azure images from %s", imageInfo.JSONPath())
|
log.Infof("Deleting Azure images from %s", imageInfo.JSONPath())
|
||||||
for _, azImage := range imageInfo.Azure {
|
for _, azImage := range imageInfo.Azure {
|
||||||
if err := clients.az.deleteImage(ctx, azImage, dryrun, log); err != nil {
|
if err := clients.az.deleteImage(ctx, azImage, dryrun, log); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting Azure image %s: %w", azImage, err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting Azure image %s: %w", azImage, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ import (
|
|||||||
"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/internal/versionsapi"
|
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -167,17 +166,17 @@ func (c *Client) DeleteVersion(ctx context.Context, ver versionsapi.Version) err
|
|||||||
c.log.Debugf("Deleting version %s from minor version list", ver.Version)
|
c.log.Debugf("Deleting version %s from minor version list", ver.Version)
|
||||||
possibleNewLatest, err := c.deleteVersionFromMinorVersionList(ctx, ver)
|
possibleNewLatest, err := c.deleteVersionFromMinorVersionList(ctx, ver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("removing from minor version list: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("removing from minor version list: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.log.Debugf("Checking latest version for %s", ver.Version)
|
c.log.Debugf("Checking latest version for %s", ver.Version)
|
||||||
if err := c.deleteVersionFromLatest(ctx, ver, possibleNewLatest); err != nil {
|
if err := c.deleteVersionFromLatest(ctx, ver, possibleNewLatest); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("updating latest version: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("updating latest version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.log.Debugf("Deleting artifact path %s for %s", ver.ArtifactPath(), ver.Version)
|
c.log.Debugf("Deleting artifact path %s for %s", ver.ArtifactPath(), ver.Version)
|
||||||
if err := c.deletePath(ctx, ver.ArtifactPath()); err != nil {
|
if err := c.deletePath(ctx, ver.ArtifactPath()); err != nil {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("deleting artifact path: %w", err))
|
retErr = errors.Join(retErr, fmt.Errorf("deleting artifact path: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,25 +61,25 @@ func (i ImageInfo) URL() (string, error) {
|
|||||||
func (i ImageInfo) ValidateRequest() error {
|
func (i ImageInfo) ValidateRequest() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(i.Ref); err != nil {
|
if err := ValidateRef(i.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(i.Ref, i.Stream); err != nil {
|
if err := ValidateStream(i.Ref, i.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if !semver.IsValid(i.Version) {
|
if !semver.IsValid(i.Version) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a valid semver", i.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a valid semver", i.Version))
|
||||||
}
|
}
|
||||||
if len(i.AWS) != 0 {
|
if len(i.AWS) != 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("AWS map must be empty for request"))
|
retErr = errors.Join(retErr, errors.New("AWS map must be empty for request"))
|
||||||
}
|
}
|
||||||
if len(i.Azure) != 0 {
|
if len(i.Azure) != 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("Azure map must be empty for request"))
|
retErr = errors.Join(retErr, errors.New("Azure map must be empty for request"))
|
||||||
}
|
}
|
||||||
if len(i.GCP) != 0 {
|
if len(i.GCP) != 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("GCP map must be empty for request"))
|
retErr = errors.Join(retErr, errors.New("GCP map must be empty for request"))
|
||||||
}
|
}
|
||||||
if len(i.QEMU) != 0 {
|
if len(i.QEMU) != 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("QEMU map must be empty for request"))
|
retErr = errors.Join(retErr, errors.New("QEMU map must be empty for request"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
@ -90,25 +89,25 @@ func (i ImageInfo) ValidateRequest() error {
|
|||||||
func (i ImageInfo) Validate() error {
|
func (i ImageInfo) Validate() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(i.Ref); err != nil {
|
if err := ValidateRef(i.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(i.Ref, i.Stream); err != nil {
|
if err := ValidateStream(i.Ref, i.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if !semver.IsValid(i.Version) {
|
if !semver.IsValid(i.Version) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a valid semver", i.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a valid semver", i.Version))
|
||||||
}
|
}
|
||||||
if len(i.AWS) == 0 {
|
if len(i.AWS) == 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("AWS map must not be empty"))
|
retErr = errors.Join(retErr, errors.New("AWS map must not be empty"))
|
||||||
}
|
}
|
||||||
if len(i.Azure) == 0 {
|
if len(i.Azure) == 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("Azure map must not be empty"))
|
retErr = errors.Join(retErr, errors.New("Azure map must not be empty"))
|
||||||
}
|
}
|
||||||
if len(i.GCP) == 0 {
|
if len(i.GCP) == 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("GCP map must not be empty"))
|
retErr = errors.Join(retErr, errors.New("GCP map must not be empty"))
|
||||||
}
|
}
|
||||||
if len(i.QEMU) == 0 {
|
if len(i.QEMU) == 0 {
|
||||||
retErr = multierr.Append(retErr, errors.New("QEMU map must not be empty"))
|
retErr = errors.Join(retErr, errors.New("QEMU map must not be empty"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
|
@ -7,12 +7,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
package versionsapi
|
package versionsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,16 +54,16 @@ func (l Latest) URL() (string, error) {
|
|||||||
func (l Latest) Validate() error {
|
func (l Latest) Validate() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(l.Ref); err != nil {
|
if err := ValidateRef(l.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if l.Kind == VersionKindUnknown {
|
if l.Kind == VersionKindUnknown {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version of kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("version of kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if !semver.IsValid(l.Version) {
|
if !semver.IsValid(l.Version) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a valid semver", l.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a valid semver", l.Version))
|
||||||
}
|
}
|
||||||
|
|
||||||
return retErr
|
return retErr
|
||||||
@ -73,16 +73,16 @@ func (l Latest) Validate() error {
|
|||||||
func (l Latest) ValidateRequest() error {
|
func (l Latest) ValidateRequest() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(l.Ref); err != nil {
|
if err := ValidateRef(l.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if l.Kind == VersionKindUnknown {
|
if l.Kind == VersionKindUnknown {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version of kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("version of kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if l.Version != "" {
|
if l.Version != "" {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q must be empty for request", l.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q must be empty for request", l.Version))
|
||||||
}
|
}
|
||||||
return retErr
|
return retErr
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
package versionsapi
|
package versionsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,19 +66,19 @@ func (l List) URL() (string, error) {
|
|||||||
func (l List) ValidateRequest() error {
|
func (l List) ValidateRequest() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(l.Ref); err != nil {
|
if err := ValidateRef(l.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
||||||
}
|
}
|
||||||
if l.Kind != VersionKindImage {
|
if l.Kind != VersionKindImage {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if !semver.IsValid(l.Base) {
|
if !semver.IsValid(l.Base) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("base version %q is not a valid semantic version", l.Base))
|
retErr = errors.Join(retErr, fmt.Errorf("base version %q is not a valid semantic version", l.Base))
|
||||||
}
|
}
|
||||||
var normalizeFunc func(string) string
|
var normalizeFunc func(string) string
|
||||||
switch l.Granularity {
|
switch l.Granularity {
|
||||||
@ -90,10 +90,10 @@ func (l List) ValidateRequest() error {
|
|||||||
normalizeFunc = func(s string) string { return s }
|
normalizeFunc = func(s string) string { return s }
|
||||||
}
|
}
|
||||||
if normalizeFunc(l.Base) != l.Base {
|
if normalizeFunc(l.Base) != l.Base {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("base version %q does not match granularity %q", l.Base, l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("base version %q does not match granularity %q", l.Base, l.Granularity))
|
||||||
}
|
}
|
||||||
if len(l.Versions) != 0 {
|
if len(l.Versions) != 0 {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("versions must be empty for request"))
|
retErr = errors.Join(retErr, fmt.Errorf("versions must be empty for request"))
|
||||||
}
|
}
|
||||||
return retErr
|
return retErr
|
||||||
}
|
}
|
||||||
@ -109,19 +109,19 @@ func (l List) ValidateRequest() error {
|
|||||||
func (l List) Validate() error {
|
func (l List) Validate() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(l.Ref); err != nil {
|
if err := ValidateRef(l.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
if err := ValidateStream(l.Ref, l.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
if l.Granularity != GranularityMajor && l.Granularity != GranularityMinor {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("granularity %q is not supported", l.Granularity))
|
||||||
}
|
}
|
||||||
if l.Kind != VersionKindImage {
|
if l.Kind != VersionKindImage {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
retErr = errors.Join(retErr, fmt.Errorf("kind %q is not supported", l.Kind))
|
||||||
}
|
}
|
||||||
if !semver.IsValid(l.Base) {
|
if !semver.IsValid(l.Base) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("base version %q is not a valid semantic version", l.Base))
|
retErr = errors.Join(retErr, fmt.Errorf("base version %q is not a valid semantic version", l.Base))
|
||||||
}
|
}
|
||||||
var normalizeFunc func(string) string
|
var normalizeFunc func(string) string
|
||||||
switch l.Granularity {
|
switch l.Granularity {
|
||||||
@ -133,14 +133,14 @@ func (l List) Validate() error {
|
|||||||
normalizeFunc = func(s string) string { return s }
|
normalizeFunc = func(s string) string { return s }
|
||||||
}
|
}
|
||||||
if normalizeFunc(l.Base) != l.Base {
|
if normalizeFunc(l.Base) != l.Base {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("base version %q does not match granularity %q", l.Base, l.Granularity))
|
retErr = errors.Join(retErr, fmt.Errorf("base version %q does not match granularity %q", l.Base, l.Granularity))
|
||||||
}
|
}
|
||||||
for _, ver := range l.Versions {
|
for _, ver := range l.Versions {
|
||||||
if !semver.IsValid(ver) {
|
if !semver.IsValid(ver) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a valid semantic version", ver))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a valid semantic version", ver))
|
||||||
}
|
}
|
||||||
if normalizeFunc(ver) != l.Base || normalizeFunc(ver) == ver {
|
if normalizeFunc(ver) != l.Base || normalizeFunc(ver) == ver {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not finer-grained than base version %q", ver, l.Base))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not finer-grained than base version %q", ver, l.Base))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -64,19 +63,19 @@ func (v Version) ShortPath() string {
|
|||||||
func (v Version) Validate() error {
|
func (v Version) Validate() error {
|
||||||
var retErr error
|
var retErr error
|
||||||
if err := ValidateRef(v.Ref); err != nil {
|
if err := ValidateRef(v.Ref); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if err := ValidateStream(v.Ref, v.Stream); err != nil {
|
if err := ValidateStream(v.Ref, v.Stream); err != nil {
|
||||||
retErr = multierr.Append(retErr, err)
|
retErr = errors.Join(retErr, err)
|
||||||
}
|
}
|
||||||
if !semver.IsValid(v.Version) {
|
if !semver.IsValid(v.Version) {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a valid semantic version", v.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a valid semantic version", v.Version))
|
||||||
}
|
}
|
||||||
if semver.Canonical(v.Version) != v.Version {
|
if semver.Canonical(v.Version) != v.Version {
|
||||||
retErr = multierr.Append(retErr, fmt.Errorf("version %q is not a canonical semantic version", v.Version))
|
retErr = errors.Join(retErr, fmt.Errorf("version %q is not a canonical semantic version", v.Version))
|
||||||
}
|
}
|
||||||
if v.Kind == VersionKindUnknown {
|
if v.Kind == VersionKindUnknown {
|
||||||
retErr = multierr.Append(retErr, errors.New("version kind is unknown"))
|
retErr = errors.Join(retErr, errors.New("version kind is unknown"))
|
||||||
}
|
}
|
||||||
return retErr
|
return retErr
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ require (
|
|||||||
go.etcd.io/etcd/api/v3 v3.5.7
|
go.etcd.io/etcd/api/v3 v3.5.7
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.7
|
go.etcd.io/etcd/client/pkg/v3 v3.5.7
|
||||||
go.etcd.io/etcd/client/v3 v3.5.7
|
go.etcd.io/etcd/client/v3 v3.5.7
|
||||||
go.uber.org/multierr v1.9.0
|
|
||||||
golang.org/x/mod v0.8.0
|
golang.org/x/mod v0.8.0
|
||||||
google.golang.org/api v0.107.0
|
google.golang.org/api v0.107.0
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
@ -83,6 +82,7 @@ require (
|
|||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.6.0 // indirect
|
golang.org/x/crypto v0.6.0 // indirect
|
||||||
golang.org/x/net v0.6.0 // indirect
|
golang.org/x/net v0.6.0 // indirect
|
||||||
|
@ -8,12 +8,12 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
compute "cloud.google.com/go/compute/apiv1"
|
compute "cloud.google.com/go/compute/apiv1"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"go.uber.org/multierr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is a client for the Google Compute Engine.
|
// Client is a client for the Google Compute Engine.
|
||||||
@ -100,7 +100,7 @@ func closeAll(closers []closer) error {
|
|||||||
// close operations, even if a previous operation failed.
|
// close operations, even if a previous operation failed.
|
||||||
var errs error
|
var errs error
|
||||||
for _, closer := range closers {
|
for _, closer := range closers {
|
||||||
errs = multierr.Append(errs, closer.Close())
|
errs = errors.Join(errs, closer.Close())
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user