mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-30 10:38:46 -04:00
api: use correct error types in versions/cli (#1867)
Imported wrong error types during refactoring.
This commit is contained in:
parent
6bda62d397
commit
315b6c2f01
6 changed files with 12 additions and 14 deletions
|
@ -12,7 +12,7 @@ go_library(
|
||||||
importpath = "github.com/edgelesssys/constellation/v2/internal/api/versions/cli",
|
importpath = "github.com/edgelesssys/constellation/v2/internal/api/versions/cli",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//internal/api/fetcher",
|
"//internal/api/client",
|
||||||
"//internal/api/versions",
|
"//internal/api/versions",
|
||||||
"//internal/api/versions/client",
|
"//internal/api/versions/client",
|
||||||
"//internal/constants",
|
"//internal/constants",
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
apifetcher "github.com/edgelesssys/constellation/v2/internal/api/fetcher"
|
apiclient "github.com/edgelesssys/constellation/v2/internal/api/client"
|
||||||
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
||||||
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
|
@ -116,7 +116,7 @@ func ensureVersion(ctx context.Context, client *verclient.VersionsClient, kind v
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
}
|
}
|
||||||
verList, err := client.FetchVersionList(ctx, verListReq)
|
verList, err := client.FetchVersionList(ctx, verListReq)
|
||||||
var notFoundErr *apifetcher.NotFoundError
|
var notFoundErr *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬FoundErr) {
|
if errors.As(err, ¬FoundErr) {
|
||||||
log.Infof("Version list for %s versions under %q does not exist. Creating new list", gran.String(), ver.Major())
|
log.Infof("Version list for %s versions under %q does not exist. Creating new list", gran.String(), ver.Major())
|
||||||
verList = verListReq
|
verList = verListReq
|
||||||
|
@ -152,7 +152,7 @@ func updateLatest(ctx context.Context, client *verclient.VersionsClient, kind ve
|
||||||
Kind: kind,
|
Kind: kind,
|
||||||
}
|
}
|
||||||
latest, err := client.FetchVersionLatest(ctx, latest)
|
latest, err := client.FetchVersionLatest(ctx, latest)
|
||||||
var notFoundErr *apifetcher.NotFoundError
|
var notFoundErr *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬FoundErr) {
|
if errors.As(err, ¬FoundErr) {
|
||||||
log.Debugf("Latest version for ref %q and stream %q not found", ver.Ref, ver.Stream)
|
log.Debugf("Latest version for ref %q and stream %q not found", ver.Ref, ver.Stream)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
|
|
||||||
apifetcher "github.com/edgelesssys/constellation/v2/internal/api/fetcher"
|
apiclient "github.com/edgelesssys/constellation/v2/internal/api/client"
|
||||||
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
||||||
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
|
@ -69,7 +69,7 @@ func runList(cmd *cobra.Command, _ []string) error {
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("Getting minor versions")
|
log.Debugf("Getting minor versions")
|
||||||
minorVersions, err = listMinorVersions(cmd.Context(), client, flags.ref, flags.stream)
|
minorVersions, err = listMinorVersions(cmd.Context(), client, flags.ref, flags.stream)
|
||||||
var errNotFound *apifetcher.NotFoundError
|
var errNotFound *apiclient.NotFoundError
|
||||||
if err != nil && errors.As(err, &errNotFound) {
|
if err != nil && errors.As(err, &errNotFound) {
|
||||||
log.Infof("No minor versions found for ref %q and stream %q.", flags.ref, flags.stream)
|
log.Infof("No minor versions found for ref %q and stream %q.", flags.ref, flags.stream)
|
||||||
return nil
|
return nil
|
||||||
|
@ -80,7 +80,7 @@ func runList(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
log.Debugf("Getting patch versions")
|
log.Debugf("Getting patch versions")
|
||||||
patchVersions, err := listPatchVersions(cmd.Context(), client, flags.ref, flags.stream, minorVersions)
|
patchVersions, err := listPatchVersions(cmd.Context(), client, flags.ref, flags.stream, minorVersions)
|
||||||
var errNotFound *apifetcher.NotFoundError
|
var errNotFound *apiclient.NotFoundError
|
||||||
if err != nil && errors.As(err, &errNotFound) {
|
if err != nil && errors.As(err, &errNotFound) {
|
||||||
log.Infof("No patch versions found for ref %q, stream %q and minor versions %v.", flags.ref, flags.stream, minorVersions)
|
log.Infof("No patch versions found for ref %q, stream %q and minor versions %v.", flags.ref, flags.stream, minorVersions)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||||
"github.com/aws/smithy-go"
|
"github.com/aws/smithy-go"
|
||||||
apifetcher "github.com/edgelesssys/constellation/v2/internal/api/fetcher"
|
apiclient "github.com/edgelesssys/constellation/v2/internal/api/client"
|
||||||
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
||||||
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
verclient "github.com/edgelesssys/constellation/v2/internal/api/versions/client"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||||
|
@ -158,7 +158,7 @@ func deleteRef(ctx context.Context, clients rmImageClients, ref string, dryrun b
|
||||||
log.Infof("Listing versions of stream %s", stream)
|
log.Infof("Listing versions of stream %s", stream)
|
||||||
|
|
||||||
minorVersions, err := listMinorVersions(ctx, clients.version, ref, stream)
|
minorVersions, err := listMinorVersions(ctx, clients.version, ref, stream)
|
||||||
var notFoundErr *apifetcher.NotFoundError
|
var notFoundErr *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬FoundErr) {
|
if errors.As(err, ¬FoundErr) {
|
||||||
log.Debugf("No minor versions found for stream %s", stream)
|
log.Debugf("No minor versions found for stream %s", stream)
|
||||||
continue
|
continue
|
||||||
|
@ -203,7 +203,7 @@ func deleteImage(ctx context.Context, clients rmImageClients, ver versionsapi.Ve
|
||||||
Version: ver.Version,
|
Version: ver.Version,
|
||||||
}
|
}
|
||||||
imageInfo, err := clients.version.FetchImageInfo(ctx, imageInfo)
|
imageInfo, err := clients.version.FetchImageInfo(ctx, imageInfo)
|
||||||
var notFound *apifetcher.NotFoundError
|
var notFound *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬Found) {
|
if errors.As(err, ¬Found) {
|
||||||
log.Warnf("Image info for %s not found", ver.Version)
|
log.Warnf("Image info for %s not found", ver.Version)
|
||||||
log.Warnf("Skipping image deletion")
|
log.Warnf("Skipping image deletion")
|
||||||
|
|
|
@ -7,7 +7,6 @@ go_library(
|
||||||
visibility = ["//:__subpackages__"],
|
visibility = ["//:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//internal/api/client",
|
"//internal/api/client",
|
||||||
"//internal/api/fetcher",
|
|
||||||
"//internal/api/versions",
|
"//internal/api/versions",
|
||||||
"//internal/constants",
|
"//internal/constants",
|
||||||
"//internal/logger",
|
"//internal/logger",
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
|
|
||||||
apiclient "github.com/edgelesssys/constellation/v2/internal/api/client"
|
apiclient "github.com/edgelesssys/constellation/v2/internal/api/client"
|
||||||
apifetcher "github.com/edgelesssys/constellation/v2/internal/api/fetcher"
|
|
||||||
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
versionsapi "github.com/edgelesssys/constellation/v2/internal/api/versions"
|
||||||
"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"
|
||||||
|
@ -166,7 +165,7 @@ func (c *VersionsClient) deleteVersionFromMinorVersionList(ctx context.Context,
|
||||||
}
|
}
|
||||||
c.Client.Log.Debugf("Fetching minor version list for version %s", ver.Version)
|
c.Client.Log.Debugf("Fetching minor version list for version %s", ver.Version)
|
||||||
minorList, err := c.FetchVersionList(ctx, minorList)
|
minorList, err := c.FetchVersionList(ctx, minorList)
|
||||||
var notFoundErr *apifetcher.NotFoundError
|
var notFoundErr *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬FoundErr) {
|
if errors.As(err, ¬FoundErr) {
|
||||||
c.Client.Log.Warnf("Minor version list for version %s not found", ver.Version)
|
c.Client.Log.Warnf("Minor version list for version %s not found", ver.Version)
|
||||||
c.Client.Log.Warnf("Skipping update of minor version list")
|
c.Client.Log.Warnf("Skipping update of minor version list")
|
||||||
|
@ -223,7 +222,7 @@ func (c *VersionsClient) deleteVersionFromLatest(ctx context.Context, ver versio
|
||||||
}
|
}
|
||||||
c.Client.Log.Debugf("Fetching latest version from %s", latest.JSONPath())
|
c.Client.Log.Debugf("Fetching latest version from %s", latest.JSONPath())
|
||||||
latest, err := c.FetchVersionLatest(ctx, latest)
|
latest, err := c.FetchVersionLatest(ctx, latest)
|
||||||
var notFoundErr *apifetcher.NotFoundError
|
var notFoundErr *apiclient.NotFoundError
|
||||||
if errors.As(err, ¬FoundErr) {
|
if errors.As(err, ¬FoundErr) {
|
||||||
c.Client.Log.Warnf("Latest version for %s not found", latest.JSONPath())
|
c.Client.Log.Warnf("Latest version for %s not found", latest.JSONPath())
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue