diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_ctrl_packages.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_ctrl_packages.go index 138098cea93..6b2e8969570 100644 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_ctrl_packages.go +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_ctrl_packages.go @@ -1,4 +1,4 @@ -// Copyright 2021-2023 the Kubeapps contributors. +// Copyright 2021-2024 the Kubeapps contributors. // SPDX-License-Identifier: Apache-2.0 package main @@ -9,12 +9,12 @@ import ( "strings" "time" + "carvel.dev/vendir/pkg/vendir/versions" + vendirversions "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" "github.com/bufbuild/connect-go" packagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" datapackagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" kappctrlpackageinstall "github.com/vmware-tanzu/carvel-kapp-controller/pkg/packageinstall" - "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions" - vendirversions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1" "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/connecterror" "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/k8sutils" @@ -724,7 +724,7 @@ func (s *Server) UpdateInstalledPackage(ctx context.Context, request *connect.Re } // Set the versionSelection - pkgInstall.Spec.PackageRef.VersionSelection = versionSelection + pkgInstall.Spec.PackageRef.VersionSelection = toOldVendirVSS(versionSelection) // Allow this PackageInstall to be downgraded // https://carvel.dev/kapp-controller/docs/v0.32.0/package-consumer-concepts/#downgrading diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_data_adapters.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_data_adapters.go index 79af2bc90a0..b28884fe69e 100644 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_data_adapters.go +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_data_adapters.go @@ -1,4 +1,4 @@ -// Copyright 2021-2023 the Kubeapps contributors. +// Copyright 2021-2024 the Kubeapps contributors. // SPDX-License-Identifier: Apache-2.0 package main @@ -13,12 +13,12 @@ import ( "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/connecterror" "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/k8sutils" + "carvel.dev/vendir/pkg/vendir/versions" + vendirversions "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" kappctrlv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" packagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" datapackagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" kappctrlpackageinstall "github.com/vmware-tanzu/carvel-kapp-controller/pkg/packageinstall" - "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions" - vendirversions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1" kappcorev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/plugins/kapp_controller/packages/v1alpha1" "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/pkgutils" @@ -390,7 +390,7 @@ func (s *Server) buildPkgInstall(installedPackageName, targetCluster, targetName // }, PackageRef: &packagingv1alpha1.PackageRef{ RefName: packageRefName, - VersionSelection: versionSelection, + VersionSelection: toOldVendirVSS(versionSelection), }, }, } diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go index 2b6463502e8..738210df1d8 100644 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_test.go @@ -25,6 +25,7 @@ import ( "google.golang.org/protobuf/types/known/anypb" + vendirversions "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" "github.com/cppforlife/go-cli-ui/ui" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -38,7 +39,6 @@ import ( kappcmdtools "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/cmd/tools" "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/logger" ctlres "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/resources" - vendirversions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1" pluginv1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/plugins/v1alpha1" kappcorev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/plugins/kapp_controller/packages/v1alpha1" @@ -1762,9 +1762,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -1896,9 +1896,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2024,9 +2024,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2128,9 +2128,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2260,9 +2260,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2304,9 +2304,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2452,9 +2452,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2594,9 +2594,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2729,9 +2729,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "9.9.9", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2933,9 +2933,9 @@ func TestGetInstalledPackageDetail(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -3168,9 +3168,9 @@ fetchStderr ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -3365,9 +3365,9 @@ fetchStderr ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "9.9.9", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -3674,9 +3674,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -3914,9 +3914,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4069,9 +4069,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "my-sa", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4226,10 +4226,10 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: nil, - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4496,10 +4496,10 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{}, - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4654,10 +4654,10 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{Identifiers: []string{"rc"}}, - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4808,9 +4808,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4965,9 +4965,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5122,9 +5122,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0 <2.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5279,9 +5279,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0 <1.1.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5437,9 +5437,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5604,9 +5604,9 @@ func TestUpdateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5668,9 +5668,9 @@ func TestUpdateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5778,9 +5778,9 @@ func TestUpdateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5908,9 +5908,9 @@ func TestDeleteInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -5977,9 +5977,9 @@ func TestDeleteInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -6098,9 +6098,9 @@ func TestGetInstalledPackageResourceRefs(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -6197,9 +6197,9 @@ func TestGetInstalledPackageResourceRefs(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -6296,9 +6296,9 @@ func TestGetInstalledPackageResourceRefs(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -6353,9 +6353,9 @@ func TestGetInstalledPackageResourceRefs(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: &vendirversions.VersionSelectionSemver{ + VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }, + }), }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -6857,14 +6857,14 @@ func TestAddPackageRepository(t *testing.T) { repository.Spec.Fetch = &packagingv1alpha1.PackageRepositoryFetch{ ImgpkgBundle: &kappctrlv1alpha1.AppFetchImgpkgBundle{ Image: "projects.registry.example.com/repo-1/main@sha256:abcd", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -6898,14 +6898,14 @@ func TestAddPackageRepository(t *testing.T) { Image: &kappctrlv1alpha1.AppFetchImage{ URL: "projects.registry.example.com/repo-1/main@sha256:abcd", SubPath: "packages", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -6942,14 +6942,14 @@ func TestAddPackageRepository(t *testing.T) { URL: "https://github.com/projects.registry.vmware.com/tce/main", Ref: "main", SubPath: "packages", - RefSelection: &vendirversions.VersionSelection{ + RefSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), LFSSkipSmudge: true, }, } @@ -7560,14 +7560,14 @@ func TestUpdatePackageRepository(t *testing.T) { repository.Spec.Fetch = &packagingv1alpha1.PackageRepositoryFetch{ ImgpkgBundle: &kappctrlv1alpha1.AppFetchImgpkgBundle{ Image: "projects.registry.example.com/repo-1/main@sha256:abcd", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -7608,14 +7608,14 @@ func TestUpdatePackageRepository(t *testing.T) { Image: &kappctrlv1alpha1.AppFetchImage{ URL: "projects.registry.example.com/repo-1/main@sha256:abcd", SubPath: "packages", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -7659,14 +7659,14 @@ func TestUpdatePackageRepository(t *testing.T) { URL: "https://github.com/projects.registry.vmware.com/tce/main", Ref: "main", SubPath: "packages", - RefSelection: &vendirversions.VersionSelection{ + RefSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), LFSSkipSmudge: true, }, } @@ -8416,14 +8416,14 @@ func TestGetPackageRepositoryDetail(t *testing.T) { repository.Spec.Fetch = &packagingv1alpha1.PackageRepositoryFetch{ ImgpkgBundle: &kappctrlv1alpha1.AppFetchImgpkgBundle{ Image: "projects.registry.example.com/repo-1/main@sha256:abcd", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -8455,14 +8455,14 @@ func TestGetPackageRepositoryDetail(t *testing.T) { Image: &kappctrlv1alpha1.AppFetchImage{ URL: "projects.registry.example.com/repo-1/main@sha256:abcd", SubPath: "packages", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, } return repository @@ -8496,14 +8496,14 @@ func TestGetPackageRepositoryDetail(t *testing.T) { URL: "https://github.com/projects.registry.vmware.com/tce/main", Ref: "main", SubPath: "packages", - RefSelection: &vendirversions.VersionSelection{ + RefSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), LFSSkipSmudge: true, }, } @@ -9026,14 +9026,14 @@ func TestGetPackageRepositorySummaries(t *testing.T) { Fetch: &packagingv1alpha1.PackageRepositoryFetch{ ImgpkgBundle: &kappctrlv1alpha1.AppFetchImgpkgBundle{ Image: "projects.registry.example.com/repo-1/main@sha256:abcd", - TagSelection: &vendirversions.VersionSelection{ + TagSelection: toOldVendirVS(&vendirversions.VersionSelection{ Semver: &vendirversions.VersionSelectionSemver{ Constraints: ">0.10.0 <0.11.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{ Identifiers: []string{"beta", "rc"}, }, }, - }, + }), }, }, }, diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils.go index a24b981385a..b9176b88cef 100644 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils.go +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils.go @@ -1,4 +1,4 @@ -// Copyright 2021-2023 the Kubeapps contributors. +// Copyright 2021-2024 the Kubeapps contributors. // SPDX-License-Identifier: Apache-2.0 package main @@ -16,12 +16,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/rest" + vendirversions "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" "github.com/Masterminds/semver/v3" kappctrlv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" packagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" datapackagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" kappcmdcore "github.com/vmware-tanzu/carvel-kapp/pkg/kapp/cmd/core" - vendirversions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1" kappcorev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/plugins/kapp_controller/packages/v1alpha1" "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/pkgutils" @@ -350,7 +350,7 @@ func toFetchImgpkg(pkgfetch *kappctrlv1alpha1.AppFetchImgpkgBundle) *kappcorev1. } fetch := &kappcorev1.PackageRepositoryFetch{ ImgpkgBundle: &kappcorev1.PackageRepositoryImgpkg{ - TagSelection: toVersionSelection(pkgfetch.TagSelection), + TagSelection: toVersionSelection(toNewVendirVS(pkgfetch.TagSelection)), }, } return fetch @@ -363,7 +363,7 @@ func toFetchImage(pkgfetch *kappctrlv1alpha1.AppFetchImage) *kappcorev1.PackageR fetch := &kappcorev1.PackageRepositoryFetch{ Image: &kappcorev1.PackageRepositoryImage{ SubPath: pkgfetch.SubPath, - TagSelection: toVersionSelection(pkgfetch.TagSelection), + TagSelection: toVersionSelection(toNewVendirVS(pkgfetch.TagSelection)), }, } return fetch @@ -376,7 +376,7 @@ func toFetchGit(pkgfetch *kappctrlv1alpha1.AppFetchGit) *kappcorev1.PackageRepos fetch := &kappcorev1.PackageRepositoryFetch{ Git: &kappcorev1.PackageRepositoryGit{ Ref: pkgfetch.Ref, - RefSelection: toVersionSelection(pkgfetch.RefSelection), + RefSelection: toVersionSelection(toNewVendirVS(pkgfetch.RefSelection)), SubPath: pkgfetch.SubPath, LfsSkipSmudge: pkgfetch.LFSSkipSmudge, }, @@ -451,17 +451,17 @@ func toVersionSelection(pkgversion *vendirversions.VersionSelection) *kappcorev1 } func toPkgFetchImgpkg(from *kappcorev1.PackageRepositoryImgpkg, to *kappctrlv1alpha1.AppFetchImgpkgBundle) { - to.TagSelection = toPkgVersionSelection(from.TagSelection) + to.TagSelection = toOldVendirVS(toPkgVersionSelection(from.TagSelection)) } func toPkgFetchImage(from *kappcorev1.PackageRepositoryImage, to *kappctrlv1alpha1.AppFetchImage) { to.SubPath = from.SubPath - to.TagSelection = toPkgVersionSelection(from.TagSelection) + to.TagSelection = toOldVendirVS(toPkgVersionSelection(from.TagSelection)) } func toPkgFetchGit(from *kappcorev1.PackageRepositoryGit, to *kappctrlv1alpha1.AppFetchGit) { to.Ref = from.Ref - to.RefSelection = toPkgVersionSelection(from.RefSelection) + to.RefSelection = toOldVendirVS(toPkgVersionSelection(from.RefSelection)) to.SubPath = from.SubPath to.LFSSkipSmudge = from.LfsSkipSmudge } diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils_test.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils_test.go index a01639292a6..5f2203c57a4 100644 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils_test.go +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/server_utils_test.go @@ -8,12 +8,12 @@ import ( "testing" "time" + vendirversions "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" "github.com/Masterminds/semver/v3" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" kappctrlv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" datapackagingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" - vendirversions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/gen/core/packages/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go new file mode 100644 index 00000000000..3aa8c7deef9 --- /dev/null +++ b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go @@ -0,0 +1,51 @@ +// Copyright 2024 the Kubeapps contributors. +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + new "carvel.dev/vendir/pkg/vendir/versions/v1alpha1" + old "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" +) + +// This is a temporary function to convert from the new vendir version to the old +// vendir version. This can be removed once the new vendir version is released. +// More details at https://github.com/vmware-tanzu/kubeapps/pull/7515 + +func toOldVendirVSS(ver *new.VersionSelectionSemver) *old.VersionSelectionSemver { + old := &old.VersionSelectionSemver{ + Constraints: ver.Constraints, + Prereleases: &old.VersionSelectionSemverPrereleases{}, + } + + if ver.Prereleases != nil { + old.Prereleases.Identifiers = ver.Prereleases.Identifiers + } + + return old +} + +func toNewVendirVS(ver *old.VersionSelection) *new.VersionSelection { + return &new.VersionSelection{ + Semver: toNewVendirVSS(ver.Semver), + } +} + +func toNewVendirVSS(ver *old.VersionSelectionSemver) *new.VersionSelectionSemver { + new := &new.VersionSelectionSemver{ + Constraints: ver.Constraints, + Prereleases: &new.VersionSelectionSemverPrereleases{}, + } + + if ver.Prereleases != nil { + new.Prereleases.Identifiers = ver.Prereleases.Identifiers + } + + return new +} + +func toOldVendirVS(ver *new.VersionSelection) *old.VersionSelection { + return &old.VersionSelection{ + Semver: toOldVendirVSS(ver.Semver), + } +} diff --git a/go.mod b/go.mod index faec2759f74..9ce9dc935cc 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ module github.com/vmware-tanzu/kubeapps go 1.21 require ( + carvel.dev/vendir v0.40.0 github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/Masterminds/semver/v3 v3.2.1 github.com/adhocore/gronx v1.6.7 diff --git a/go.sum b/go.sum index 1cfa25135fd..a9d4a1af453 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +carvel.dev/vendir v0.40.0 h1:JdhCp/EjAPGI8F5zoAVYwZHf1sPEFee19RpgGb3ciT8= +carvel.dev/vendir v0.40.0/go.mod h1:XPdluJu7322RZNx05AA4gYnV52aKywBdh7Ma12GuM2Q= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=