mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-16 13:12:21 -04:00
versionsapi: rename package
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
3c62b841ed
commit
9c9c8e3d46
5 changed files with 53 additions and 53 deletions
|
@ -22,7 +22,7 @@ import (
|
||||||
"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/sigstore"
|
"github.com/edgelesssys/constellation/v2/internal/sigstore"
|
||||||
"github.com/edgelesssys/constellation/v2/internal/update"
|
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||||
"github.com/manifoldco/promptui"
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -55,7 +55,7 @@ func runUpgradePlan(cmd *cobra.Command, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
patchLister := update.New()
|
patchLister := versionsapi.New()
|
||||||
rekor, err := sigstore.NewRekor()
|
rekor, err := sigstore.NewRekor()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("constructing Rekor client: %w", err)
|
return fmt.Errorf("constructing Rekor client: %w", err)
|
||||||
|
@ -335,5 +335,5 @@ type upgradePlanner interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type patchLister interface {
|
type patchLister interface {
|
||||||
PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*update.VersionsList, error)
|
PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*versionsapi.List, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,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/update"
|
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -163,7 +163,7 @@ func TestGetCompatibleImageMeasurements(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpgradePlan(t *testing.T) {
|
func TestUpgradePlan(t *testing.T) {
|
||||||
availablePatches := update.VersionsList{
|
availablePatches := versionsapi.List{
|
||||||
Versions: []string{"v1.0.0", "v1.0.1"},
|
Versions: []string{"v1.0.0", "v1.0.1"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,10 +488,10 @@ func (u stubUpgradePlanner) GetCurrentImage(context.Context) (*unstructured.Unst
|
||||||
}
|
}
|
||||||
|
|
||||||
type stubPatchLister struct {
|
type stubPatchLister struct {
|
||||||
list update.VersionsList
|
list versionsapi.List
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s stubPatchLister) PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*update.VersionsList, error) {
|
func (s stubPatchLister) PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*versionsapi.List, error) {
|
||||||
return &s.list, s.err
|
return &s.list, s.err
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
|
s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||||
"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/update"
|
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
|
@ -61,7 +61,7 @@ func main() {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
updateFetcher := update.New()
|
updateFetcher := versionsapi.New()
|
||||||
versionManager, err := newVersionManager(ctx, *region, *bucket, *distributionID)
|
versionManager, err := newVersionManager(ctx, *region, *bucket, *distributionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to create version uploader")
|
log.With(zap.Error(err)).Fatalf("Failed to create version uploader")
|
||||||
|
@ -74,7 +74,7 @@ func main() {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to get minor versions")
|
log.With(zap.Error(err)).Fatalf("Failed to get minor versions")
|
||||||
}
|
}
|
||||||
log.Infof("Version list for minor versions under %q does not exist. Creating new list.", major)
|
log.Infof("Version list for minor versions under %q does not exist. Creating new list.", major)
|
||||||
minorVersions = &update.VersionsList{
|
minorVersions = &versionsapi.List{
|
||||||
Stream: stream,
|
Stream: stream,
|
||||||
Granularity: "major",
|
Granularity: "major",
|
||||||
Base: major,
|
Base: major,
|
||||||
|
@ -98,7 +98,7 @@ func main() {
|
||||||
log.With(zap.Error(err)).Fatalf("Failed to get patch versions")
|
log.With(zap.Error(err)).Fatalf("Failed to get patch versions")
|
||||||
}
|
}
|
||||||
log.Infof("Version list for patch versions under %q does not exist. Creating new list.", minor)
|
log.Infof("Version list for patch versions under %q does not exist. Creating new list.", minor)
|
||||||
patchVersions = &update.VersionsList{
|
patchVersions = &versionsapi.List{
|
||||||
Stream: stream,
|
Stream: stream,
|
||||||
Granularity: "minor",
|
Granularity: "minor",
|
||||||
Base: minor,
|
Base: minor,
|
||||||
|
@ -150,7 +150,7 @@ func validateVersion(version string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureMinorVersionExists(ctx context.Context, fetcher *update.VersionsFetcher, version string) error {
|
func ensureMinorVersionExists(ctx context.Context, fetcher *versionsapi.Fetcher, version string) error {
|
||||||
major := semver.Major(version)
|
major := semver.Major(version)
|
||||||
minor := semver.MajorMinor(version)
|
minor := semver.MajorMinor(version)
|
||||||
existingMinorVersions, err := fetcher.MinorVersionsOf(ctx, stream, major, imageKind)
|
existingMinorVersions, err := fetcher.MinorVersionsOf(ctx, stream, major, imageKind)
|
||||||
|
@ -163,7 +163,7 @@ func ensureMinorVersionExists(ctx context.Context, fetcher *update.VersionsFetch
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensurePatchVersionExists(ctx context.Context, fetcher *update.VersionsFetcher, version string) error {
|
func ensurePatchVersionExists(ctx context.Context, fetcher *versionsapi.Fetcher, version string) error {
|
||||||
minor := semver.MajorMinor(version)
|
minor := semver.MajorMinor(version)
|
||||||
patch := semver.Canonical(version)
|
patch := semver.Canonical(version)
|
||||||
existingPatchVersions, err := fetcher.PatchVersionsOf(ctx, stream, minor, imageKind)
|
existingPatchVersions, err := fetcher.PatchVersionsOf(ctx, stream, minor, imageKind)
|
||||||
|
@ -203,29 +203,29 @@ func newVersionManager(ctx context.Context, region, bucket, distributionID strin
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) getMinorVersions(ctx context.Context, version string) (*update.VersionsList, error) {
|
func (m *versionManager) getMinorVersions(ctx context.Context, version string) (*versionsapi.List, error) {
|
||||||
baseVersion := semver.Major(version)
|
baseVersion := semver.Major(version)
|
||||||
return m.getVersions(ctx, baseVersion)
|
return m.getVersions(ctx, baseVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) getPatchVersions(ctx context.Context, version string) (*update.VersionsList, error) {
|
func (m *versionManager) getPatchVersions(ctx context.Context, version string) (*versionsapi.List, error) {
|
||||||
baseVersion := semver.MajorMinor(version)
|
baseVersion := semver.MajorMinor(version)
|
||||||
return m.getVersions(ctx, baseVersion)
|
return m.getVersions(ctx, baseVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) addMinorVersion(ctx context.Context, version string, minorVersions *update.VersionsList) error {
|
func (m *versionManager) addMinorVersion(ctx context.Context, version string, minorVersions *versionsapi.List) error {
|
||||||
baseVersion := semver.Major(version)
|
baseVersion := semver.Major(version)
|
||||||
minorVersion := semver.MajorMinor(version)
|
minorVersion := semver.MajorMinor(version)
|
||||||
return m.addVersion(ctx, baseVersion, minorVersion, minorVersions)
|
return m.addVersion(ctx, baseVersion, minorVersion, minorVersions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) addPatchVersion(ctx context.Context, version string, patchVersions *update.VersionsList) error {
|
func (m *versionManager) addPatchVersion(ctx context.Context, version string, patchVersions *versionsapi.List) error {
|
||||||
baseVersion := semver.MajorMinor(version)
|
baseVersion := semver.MajorMinor(version)
|
||||||
patchVersion := semver.Canonical(version)
|
patchVersion := semver.Canonical(version)
|
||||||
return m.addVersion(ctx, baseVersion, patchVersion, patchVersions)
|
return m.addVersion(ctx, baseVersion, patchVersion, patchVersions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) getVersions(ctx context.Context, baseVersion string) (*update.VersionsList, error) {
|
func (m *versionManager) getVersions(ctx context.Context, baseVersion string) (*versionsapi.List, error) {
|
||||||
granularity, err := granularityFromVersion(baseVersion)
|
granularity, err := granularityFromVersion(baseVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -242,14 +242,14 @@ func (m *versionManager) getVersions(ctx context.Context, baseVersion string) (*
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer out.Body.Close()
|
defer out.Body.Close()
|
||||||
var versions update.VersionsList
|
var versions versionsapi.List
|
||||||
if err := json.NewDecoder(out.Body).Decode(&versions); err != nil {
|
if err := json.NewDecoder(out.Body).Decode(&versions); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &versions, nil
|
return &versions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *versionManager) addVersion(ctx context.Context, baseVersion, version string, list *update.VersionsList) error {
|
func (m *versionManager) addVersion(ctx context.Context, baseVersion, version string, list *versionsapi.List) error {
|
||||||
granularity, err := granularityFromVersion(baseVersion)
|
granularity, err := granularityFromVersion(baseVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -4,7 +4,7 @@ Copyright (c) Edgeless Systems GmbH
|
||||||
SPDX-License-Identifier: AGPL-3.0-only
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package update
|
package versionsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -20,14 +20,14 @@ import (
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VersionsList represents a list of versions for a kind of resource.
|
// List represents a list of versions for a kind of resource.
|
||||||
// It has a granularity of either "major" or "minor".
|
// It has a granularity of either "major" or "minor".
|
||||||
//
|
//
|
||||||
// For example, a VersionsList with granularity "major" could contain
|
// For example, a List with granularity "major" could contain
|
||||||
// the base version "v1" and a list of minor versions "v1.0", "v1.1", "v1.2" etc.
|
// the base version "v1" and a list of minor versions "v1.0", "v1.1", "v1.2" etc.
|
||||||
// A VersionsList with granularity "minor" could contain the base version
|
// A List with granularity "minor" could contain the base version
|
||||||
// "v1.0" and a list of patch versions "v1.0.0", "v1.0.1", "v1.0.2" etc.
|
// "v1.0" and a list of patch versions "v1.0.0", "v1.0.1", "v1.0.2" etc.
|
||||||
type VersionsList struct {
|
type List struct {
|
||||||
// Stream is the update stream of the list.
|
// Stream is the update stream of the list.
|
||||||
// Currently, only "stable" is supported.
|
// Currently, only "stable" is supported.
|
||||||
Stream string `json:"stream"`
|
Stream string `json:"stream"`
|
||||||
|
@ -50,7 +50,7 @@ type VersionsList struct {
|
||||||
// - The kind is supported.
|
// - The kind is supported.
|
||||||
// - The base version is a valid semantic version that matches the granularity.
|
// - The base version is a valid semantic version that matches the granularity.
|
||||||
// - All versions in the list are valid semantic versions that are finer-grained than the base version.
|
// - All versions in the list are valid semantic versions that are finer-grained than the base version.
|
||||||
func (l *VersionsList) Validate() error {
|
func (l *List) Validate() error {
|
||||||
var issues []string
|
var issues []string
|
||||||
if l.Stream != "stable" {
|
if l.Stream != "stable" {
|
||||||
issues = append(issues, fmt.Sprintf("stream %q is not supported", l.Stream))
|
issues = append(issues, fmt.Sprintf("stream %q is not supported", l.Stream))
|
||||||
|
@ -91,7 +91,7 @@ func (l *VersionsList) Validate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains returns true if the list contains the given version.
|
// Contains returns true if the list contains the given version.
|
||||||
func (l *VersionsList) Contains(version string) bool {
|
func (l *List) Contains(version string) bool {
|
||||||
for _, v := range l.Versions {
|
for _, v := range l.Versions {
|
||||||
if v == version {
|
if v == version {
|
||||||
return true
|
return true
|
||||||
|
@ -100,35 +100,35 @@ func (l *VersionsList) Contains(version string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionsFetcher fetches a list of versions.
|
// Fetcher fetches a list of versions.
|
||||||
type VersionsFetcher struct {
|
type Fetcher struct {
|
||||||
httpc httpc
|
httpc httpc
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new VersionsFetcher.
|
// New returns a new VersionsFetcher.
|
||||||
func New() *VersionsFetcher {
|
func New() *Fetcher {
|
||||||
return &VersionsFetcher{
|
return &Fetcher{
|
||||||
httpc: http.DefaultClient,
|
httpc: http.DefaultClient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinorVersionsOf fetches the list of minor versions for a given stream, major version and kind.
|
// MinorVersionsOf fetches the list of minor versions for a given stream, major version and kind.
|
||||||
func (f *VersionsFetcher) MinorVersionsOf(ctx context.Context, stream, major, kind string) (*VersionsList, error) {
|
func (f *Fetcher) MinorVersionsOf(ctx context.Context, stream, major, kind string) (*List, error) {
|
||||||
return f.list(ctx, stream, "major", major, kind)
|
return f.list(ctx, stream, "major", major, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchVersionsOf fetches the list of patch versions for a given stream, minor version and kind.
|
// PatchVersionsOf fetches the list of patch versions for a given stream, minor version and kind.
|
||||||
func (f *VersionsFetcher) PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*VersionsList, error) {
|
func (f *Fetcher) PatchVersionsOf(ctx context.Context, stream, minor, kind string) (*List, error) {
|
||||||
return f.list(ctx, stream, "minor", minor, kind)
|
return f.list(ctx, stream, "minor", minor, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// list fetches the list of versions for a given stream, granularity, base and kind.
|
// list fetches the list of versions for a given stream, granularity, base and kind.
|
||||||
func (f *VersionsFetcher) list(ctx context.Context, stream, granularity, base, kind string) (*VersionsList, error) {
|
func (f *Fetcher) list(ctx context.Context, stream, granularity, base, kind string) (*List, error) {
|
||||||
raw, err := getFromURL(ctx, f.httpc, stream, granularity, base, kind)
|
raw, err := getFromURL(ctx, f.httpc, stream, granularity, base, kind)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("fetching versions list: %w", err)
|
return nil, fmt.Errorf("fetching versions list: %w", err)
|
||||||
}
|
}
|
||||||
list := &VersionsList{}
|
list := &List{}
|
||||||
if err := json.Unmarshal(raw, &list); err != nil {
|
if err := json.Unmarshal(raw, &list); err != nil {
|
||||||
return nil, fmt.Errorf("decoding versions list: %w", err)
|
return nil, fmt.Errorf("decoding versions list: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ func (f *VersionsFetcher) list(ctx context.Context, stream, granularity, base, k
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *VersionsFetcher) listMatchesRequest(list *VersionsList, stream, granularity, base, kind string) bool {
|
func (f *Fetcher) listMatchesRequest(list *List, stream, granularity, base, kind string) bool {
|
||||||
return list.Stream == stream && list.Granularity == granularity && list.Base == base && list.Kind == kind
|
return list.Stream == stream && list.Granularity == granularity && list.Base == base && list.Kind == kind
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ Copyright (c) Edgeless Systems GmbH
|
||||||
SPDX-License-Identifier: AGPL-3.0-only
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package update
|
package versionsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -25,8 +25,8 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
listFunc func() *VersionsList
|
listFunc func() *List
|
||||||
overrideFunc func(list *VersionsList)
|
overrideFunc func(list *List)
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
"valid major list": {
|
"valid major list": {
|
||||||
|
@ -37,56 +37,56 @@ func TestValidate(t *testing.T) {
|
||||||
},
|
},
|
||||||
"invalid stream": {
|
"invalid stream": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Stream = "invalid"
|
list.Stream = "invalid"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"invalid granularity": {
|
"invalid granularity": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Granularity = "invalid"
|
list.Granularity = "invalid"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"invalid kind": {
|
"invalid kind": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Kind = "invalid"
|
list.Kind = "invalid"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"base ver is not semantic version": {
|
"base ver is not semantic version": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Base = "invalid"
|
list.Base = "invalid"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"base ver does not reflect major granularity": {
|
"base ver does not reflect major granularity": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Base = "v1.0"
|
list.Base = "v1.0"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"base ver does not reflect minor granularity": {
|
"base ver does not reflect minor granularity": {
|
||||||
listFunc: minorList,
|
listFunc: minorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Base = "v1"
|
list.Base = "v1"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"version in list is not semantic version": {
|
"version in list is not semantic version": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Versions[0] = "invalid"
|
list.Versions[0] = "invalid"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"version in list is not sub version of base": {
|
"version in list is not sub version of base": {
|
||||||
listFunc: majorList,
|
listFunc: majorList,
|
||||||
overrideFunc: func(list *VersionsList) {
|
overrideFunc: func(list *List) {
|
||||||
list.Versions[0] = "v2.1"
|
list.Versions[0] = "v2.1"
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
@ -170,7 +170,7 @@ func TestList(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
stream, granularity, base, kind string
|
stream, granularity, base, kind string
|
||||||
overrideFile string
|
overrideFile string
|
||||||
wantList VersionsList
|
wantList List
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
"major list fetched remotely": {
|
"major list fetched remotely": {
|
||||||
|
@ -225,7 +225,7 @@ func TestList(t *testing.T) {
|
||||||
kind = tc.kind
|
kind = tc.kind
|
||||||
}
|
}
|
||||||
|
|
||||||
fetcher := &VersionsFetcher{
|
fetcher := &Fetcher{
|
||||||
httpc: client,
|
httpc: client,
|
||||||
}
|
}
|
||||||
list, err := fetcher.list(context.Background(), stream, granularity, base, kind)
|
list, err := fetcher.list(context.Background(), stream, granularity, base, kind)
|
||||||
|
@ -254,8 +254,8 @@ func newTestClient(fn roundTripFunc) *http.Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func majorList() *VersionsList {
|
func majorList() *List {
|
||||||
return &VersionsList{
|
return &List{
|
||||||
Stream: "stable",
|
Stream: "stable",
|
||||||
Granularity: "major",
|
Granularity: "major",
|
||||||
Base: "v1",
|
Base: "v1",
|
||||||
|
@ -266,8 +266,8 @@ func majorList() *VersionsList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func minorList() *VersionsList {
|
func minorList() *List {
|
||||||
return &VersionsList{
|
return &List{
|
||||||
Stream: "stable",
|
Stream: "stable",
|
||||||
Granularity: "minor",
|
Granularity: "minor",
|
||||||
Base: "v1.1",
|
Base: "v1.1",
|
Loading…
Add table
Add a link
Reference in a new issue