From acfc45eb264702031b97fc1a74509beca50fdfae Mon Sep 17 00:00:00 2001 From: Antonio Gamez Diaz Date: Mon, 25 Mar 2024 12:18:53 +0100 Subject: [PATCH] Partially revert https://github.com/vmware-tanzu/kubeapps/pull/7515 Signed-off-by: Antonio Gamez Diaz --- .../packages/v1alpha1/server_data_adapters.go | 2 +- .../packages/v1alpha1/server_test.go | 142 +++++++++--------- .../packages/v1alpha1/server_utils.go | 12 +- .../packages/v1alpha1/utils.go | 51 ------- go.mod | 2 +- go.sum | 4 +- 6 files changed, 81 insertions(+), 132 deletions(-) delete mode 100644 cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go 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 b28884fe69e..ba2fcc85520 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 @@ -390,7 +390,7 @@ func (s *Server) buildPkgInstall(installedPackageName, targetCluster, targetName // }, PackageRef: &packagingv1alpha1.PackageRef{ RefName: packageRefName, - VersionSelection: toOldVendirVSS(versionSelection), + VersionSelection: 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 738210df1d8..8c68c14be1b 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 @@ -1762,9 +1762,9 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }), + }, }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -2594,7 +2594,7 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", }), }, @@ -2729,7 +2729,7 @@ func TestGetInstalledPackageSummaries(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "9.9.9", }), }, @@ -2933,7 +2933,7 @@ func TestGetInstalledPackageDetail(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", }), }, @@ -3168,7 +3168,7 @@ fetchStderr ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">1.0.0 <2.0.0", }), }, @@ -3365,7 +3365,7 @@ fetchStderr ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "9.9.9", }), }, @@ -3674,9 +3674,9 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.2.3", - }), + }, }, Values: []packagingv1alpha1.PackageInstallValues{{ SecretRef: &packagingv1alpha1.PackageInstallValuesSecretRef{ @@ -4226,7 +4226,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: nil, }), @@ -4496,7 +4496,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{}, }), @@ -4654,7 +4654,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", Prereleases: &vendirversions.VersionSelectionSemverPrereleases{Identifiers: []string{"rc"}}, }), @@ -4808,7 +4808,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", }), }, @@ -4965,7 +4965,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0", }), }, @@ -5122,7 +5122,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0 <2.0.0", }), }, @@ -5279,7 +5279,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: ">=1.0.0 <1.1.0", }), }, @@ -5437,7 +5437,7 @@ func TestCreateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &vendirversions.VersionSelectionSemver{ Constraints: "1.0.0", }), }, @@ -5604,9 +5604,9 @@ func TestUpdateInstalledPackage(t *testing.T) { ServiceAccountName: "default", PackageRef: &packagingv1alpha1.PackageRef{ RefName: "tetris.foo.example.com", - VersionSelection: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVSS(&vendirversions.VersionSelectionSemver{ + VersionSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + RefSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + RefSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: (&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: toOldVendirVS(&vendirversions.VersionSelection{ + RefSelection: &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: toOldVendirVS(&vendirversions.VersionSelection{ + TagSelection: &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 b9176b88cef..e3defa2199c 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 @@ -350,7 +350,7 @@ func toFetchImgpkg(pkgfetch *kappctrlv1alpha1.AppFetchImgpkgBundle) *kappcorev1. } fetch := &kappcorev1.PackageRepositoryFetch{ ImgpkgBundle: &kappcorev1.PackageRepositoryImgpkg{ - TagSelection: toVersionSelection(toNewVendirVS(pkgfetch.TagSelection)), + TagSelection: toVersionSelection(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(toNewVendirVS(pkgfetch.TagSelection)), + TagSelection: toVersionSelection(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(toNewVendirVS(pkgfetch.RefSelection)), + RefSelection: toVersionSelection(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 = toOldVendirVS(toPkgVersionSelection(from.TagSelection)) + to.TagSelection = toPkgVersionSelection(from.TagSelection) } func toPkgFetchImage(from *kappcorev1.PackageRepositoryImage, to *kappctrlv1alpha1.AppFetchImage) { to.SubPath = from.SubPath - to.TagSelection = toOldVendirVS(toPkgVersionSelection(from.TagSelection)) + to.TagSelection = toPkgVersionSelection(from.TagSelection) } func toPkgFetchGit(from *kappcorev1.PackageRepositoryGit, to *kappctrlv1alpha1.AppFetchGit) { to.Ref = from.Ref - to.RefSelection = toOldVendirVS(toPkgVersionSelection(from.RefSelection)) + to.RefSelection = toPkgVersionSelection(from.RefSelection) to.SubPath = from.SubPath to.LFSSkipSmudge = from.LfsSkipSmudge } diff --git a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go b/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go deleted file mode 100644 index 3aa8c7deef9..00000000000 --- a/cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/utils.go +++ /dev/null @@ -1,51 +0,0 @@ -// 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 682640f4b0c..6733eb2528e 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,6 @@ require ( github.com/stretchr/testify v1.9.0 github.com/vmware-tanzu/carvel-kapp v0.60.0 github.com/vmware-tanzu/carvel-kapp-controller v0.50.2 - github.com/vmware-tanzu/carvel-vendir v0.36.1 golang.org/x/net v0.22.0 golang.org/x/sync v0.6.0 google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe @@ -204,6 +203,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/vito/go-interact v1.0.1 // indirect + github.com/vmware-tanzu/carvel-vendir v0.36.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect diff --git a/go.sum b/go.sum index 7e145199ecc..3d7ffce7a40 100644 --- a/go.sum +++ b/go.sum @@ -799,8 +799,8 @@ github.com/vmware-tanzu/carvel-kapp v0.60.0 h1:UHAtNtiiYkWJuyfkRmctHg8geApbC3KLD github.com/vmware-tanzu/carvel-kapp v0.60.0/go.mod h1:ljKb/3GsVn74l1cEpqnZudFU1cwqj4OaLcOeEFjfD7Q= github.com/vmware-tanzu/carvel-kapp-controller v0.50.2 h1:/0iDxqCzQIDLhasdnx2Hw+iW5VbL2OenfHESbWOZ5fE= github.com/vmware-tanzu/carvel-kapp-controller v0.50.2/go.mod h1:dcE+zg3cMl6CWRWwA1K9I9x24wGF98wlsatz5UEfdFo= -github.com/vmware-tanzu/carvel-vendir v0.36.1 h1:/x93p4cmSSsv7ZqZPxV15VwzsV2VWcDthPPGtLwKEwQ= -github.com/vmware-tanzu/carvel-vendir v0.36.1/go.mod h1:rPGI/zItMK4QgLRpLix2aykoYufavHyKqqLTONXb2uE= +github.com/vmware-tanzu/carvel-vendir v0.36.0 h1:F9FNk2YysC6DlUDP2Nl2ynsv6JH8S0FYT4OK6HrRco0= +github.com/vmware-tanzu/carvel-vendir v0.36.0/go.mod h1:rPGI/zItMK4QgLRpLix2aykoYufavHyKqqLTONXb2uE= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=