Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to go 1.20 as other deps depend on new interfaces. #6420

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/kubeapps-general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ env:
BRANCH_KUBEAPPS_REPO: "main"
README_GENERATOR_REPO: "bitnami-labs/readme-generator-for-helm"
DOCKER_REGISTRY_VERSION: "2.8.2"
GOLANG_VERSION: "1.19.10"
GOLANG_VERSION: "1.20.5"
HELM_VERSION_MIN: "v3.8.0"
HELM_VERSION_STABLE: "v3.12.1"
GITHUB_VERSION: "2.31.0"
Expand Down
2 changes: 1 addition & 1 deletion cmd/apprepository-controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# syntax = docker/dockerfile:1

FROM bitnami/golang:1.19.10 as builder
FROM bitnami/golang:1.20.5 as builder
WORKDIR /go/src/github.com/vmware-tanzu/kubeapps
COPY go.mod go.sum ./
COPY pkg pkg
Expand Down
2 changes: 1 addition & 1 deletion cmd/asset-syncer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# syntax = docker/dockerfile:1

FROM bitnami/golang:1.19.10 as builder
FROM bitnami/golang:1.20.5 as builder
WORKDIR /go/src/github.com/vmware-tanzu/kubeapps
COPY go.mod go.sum ./
COPY pkg pkg
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeapps-apis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# syntax = docker/dockerfile:1

FROM bitnami/golang:1.19.10 as builder
FROM bitnami/golang:1.20.5 as builder
WORKDIR /go/src/github.com/vmware-tanzu/kubeapps
COPY go.mod go.sum ./
ARG VERSION="devel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"context"
"fmt"
"math/rand"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -47,7 +48,7 @@ import (
// -rw-rw-rw-@ 1 gfichtenholt staff 10394218 Nov 7 19:41 bitnami_index.yaml
// Also now we are caching helmcharts themselves for each repo so that will affect how many will fit too
func TestKindClusterGetAvailablePackageSummariesForLargeReposAndTinyRedis(t *testing.T) {
fluxPlugin, _, err := checkEnv(t)
fluxPlugin, _, rnd, err := checkEnv(t)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -131,7 +132,7 @@ func TestKindClusterGetAvailablePackageSummariesForLargeReposAndTinyRedis(t *tes
// one particular code path I'd like to test:
// make sure that GetAvailablePackageVersions() works w.r.t. a cache entry that's been evicted
name := types.NamespacedName{
Name: "test-create-admin-" + randSeq(4),
Name: "test-create-admin-" + randSeq(rnd, 4),
Namespace: "default",
}
grpcContext, err := newGrpcAdminContext(t, name)
Expand Down Expand Up @@ -271,14 +272,14 @@ func TestKindClusterGetAvailablePackageSummariesForLargeReposAndTinyRedis(t *tes
//
// ref https://github.com/vmware-tanzu/kubeapps/issues/4390
func TestKindClusterRepoAndChartRBAC(t *testing.T) {
fluxPluginClient, _, err := checkEnv(t)
fluxPluginClient, _, rnd, err := checkEnv(t)
if err != nil {
t.Fatal(err)
}

names := []types.NamespacedName{
{Name: "podinfo-1", Namespace: "test-" + randSeq(4)},
{Name: "podinfo-2", Namespace: "test-" + randSeq(4)},
{Name: "podinfo-1", Namespace: "test-" + randSeq(rnd, 4)},
{Name: "podinfo-2", Namespace: "test-" + randSeq(rnd, 4)},
}

for _, n := range names {
Expand All @@ -294,7 +295,7 @@ func TestKindClusterRepoAndChartRBAC(t *testing.T) {
}

svcAcctName := types.NamespacedName{
Name: "test-repo-rbac-admin-" + randSeq(4),
Name: "test-repo-rbac-admin-" + randSeq(rnd, 4),
Namespace: "default",
}
grpcCtxAdmin, err := newGrpcAdminContext(t, svcAcctName)
Expand All @@ -310,7 +311,7 @@ func TestKindClusterRepoAndChartRBAC(t *testing.T) {
}

svcAcctName2 := types.NamespacedName{
Name: "test-repo-rbac-loser-" + randSeq(4),
Name: "test-repo-rbac-loser-" + randSeq(rnd, 4),
Namespace: "default",
}
grpcCtxLoser, err := newGrpcContextForServiceAccountWithoutAccessToAnyNamespace(t, svcAcctName2)
Expand Down Expand Up @@ -341,7 +342,7 @@ func TestKindClusterRepoAndChartRBAC(t *testing.T) {
}

svcAcctName3 := types.NamespacedName{
Name: "test-repo-rbac-limited-" + randSeq(4),
Name: "test-repo-rbac-limited-" + randSeq(rnd, 4),
Namespace: "default",
}

Expand Down Expand Up @@ -527,7 +528,7 @@ type testCaseKindClusterAvailablePackageEndpointsForOCISpec struct {
unauthorized bool
}

func testCaseKindClusterAvailablePackageEndpointsForGitHub(t *testing.T) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
func testCaseKindClusterAvailablePackageEndpointsForGitHub(t *testing.T, rnd *rand.Rand) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
ghUser := os.Getenv("GITHUB_USER")
ghToken := os.Getenv("GITHUB_TOKEN")
if ghUser == "" || ghToken == "" {
Expand All @@ -538,7 +539,7 @@ func testCaseKindClusterAvailablePackageEndpointsForGitHub(t *testing.T) []testC
testName: "Testing [" + github_stefanprodan_podinfo_oci_registry_url + "] with basic auth secret",
registryUrl: github_stefanprodan_podinfo_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
ghUser,
ghToken,
Expand All @@ -548,15 +549,15 @@ func testCaseKindClusterAvailablePackageEndpointsForGitHub(t *testing.T) []testC
testName: "Testing [" + github_stefanprodan_podinfo_oci_registry_url + "] with dockerconfigjson secret",
registryUrl: github_stefanprodan_podinfo_oci_registry_url,
secret: newDockerConfigJsonSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
"ghcr.io", ghUser, ghToken,
),
},
}
}

func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T, rnd *rand.Rand) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
if err := setupHarborForIntegrationTest(t); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -586,7 +587,7 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harbor_stefanprodan_podinfo_oci_registry_url + "] with basic auth secret (admin)",
registryUrl: harbor_stefanprodan_podinfo_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harbor_admin_user,
harbor_admin_pwd,
Expand All @@ -596,7 +597,7 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harbor_stefanprodan_podinfo_oci_registry_url + "] with basic auth secret (robot)",
registryUrl: harbor_stefanprodan_podinfo_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harborRobotName,
harborRobotSecret,
Expand All @@ -607,7 +608,7 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harbor_stefanprodan_podinfo_private_oci_registry_url + "] with basic auth secret (admin)",
registryUrl: harbor_stefanprodan_podinfo_private_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harbor_admin_user,
harbor_admin_pwd,
Expand All @@ -618,7 +619,7 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harbor_stefanprodan_podinfo_private_oci_registry_url + "] with basic auth secret (robot)",
registryUrl: harbor_stefanprodan_podinfo_private_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harborRobotName,
harborRobotSecret,
Expand All @@ -635,7 +636,7 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harbor_stefanprodan_podinfo_private_oci_registry_url + "] bad username/secret",
registryUrl: harbor_stefanprodan_podinfo_private_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
"kaka",
"kaka"),
Expand All @@ -645,15 +646,15 @@ func testCaseKindClusterAvailablePackageEndpointsForHarbor(t *testing.T) []testC
testName: "Testing [" + harborCorpVMwareRepoUrl + "]",
registryUrl: harborCorpVMwareRepoUrl,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harborCorpVMwareRepoRobotUser,
harborCorpVMwareRepoRobotSecret),
},
}
}

func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T, rnd *rand.Rand) []testCaseKindClusterAvailablePackageEndpointsForOCISpec {
// ref: https://cloud.google.com/artifact-registry/docs/helm/authentication#token
gcpUser := "oauth2accesstoken"
gcpPasswd, err := gcloudPrintAccessToken(t)
Expand All @@ -678,7 +679,7 @@ func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T) []testCase
testName: "Testing [" + gcp_stefanprodan_podinfo_oci_registry_url + "] with service access token",
registryUrl: gcp_stefanprodan_podinfo_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
gcpUser,
string(gcpPasswd),
Expand All @@ -688,7 +689,7 @@ func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T) []testCase
testName: "Testing [" + gcp_stefanprodan_podinfo_oci_registry_url + "] with JSON key",
registryUrl: gcp_stefanprodan_podinfo_oci_registry_url,
secret: newDockerConfigJsonSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
gcpServer2,
gcpUser2,
Expand All @@ -706,7 +707,7 @@ func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T) []testCase
testName: "Testing [" + gcp_stefanprodan_podinfo_oci_registry_url + "] bad username/secret",
registryUrl: gcp_stefanprodan_podinfo_oci_registry_url,
secret: newDockerConfigJsonSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
gcpServer2,
"kaka",
Expand All @@ -718,17 +719,17 @@ func testCaseKindClusterAvailablePackageEndpointsForGcp(t *testing.T) []testCase
}

func TestKindClusterAvailablePackageEndpointsForOCI(t *testing.T) {
fluxPluginClient, fluxPluginReposClient, err := checkEnv(t)
fluxPluginClient, fluxPluginReposClient, rnd, err := checkEnv(t)
if err != nil {
t.Fatal(err)
}

// this is written this way so its relatively easy to comment out and run just a subset
// of the test cases when debugging failures
testCases := []testCaseKindClusterAvailablePackageEndpointsForOCISpec{}
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForGitHub(t)...)
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForHarbor(t)...)
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForGcp(t)...)
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForGitHub(t, rnd)...)
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForHarbor(t, rnd)...)
testCases = append(testCases, testCaseKindClusterAvailablePackageEndpointsForGcp(t, rnd)...)

// TODO (gfichtenholt) harbor plainHTTP (not HTTPS) repo with robot account
// this may or may not work see https://github.com/fluxcd/source-controller/issues/807
Expand All @@ -749,27 +750,27 @@ func TestKindClusterAvailablePackageEndpointsForOCI(t *testing.T) {
testName: "Testing [" + in_cluster_oci_registry_url + "]",
registryUrl: in_cluster_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
"foo",
"bar",
),
},
*/

testKindClusterAvailablePackageEndpointsForOCIHelper(t, testCases, fluxPluginClient, fluxPluginReposClient)
testKindClusterAvailablePackageEndpointsForOCIHelper(t, testCases, fluxPluginClient, fluxPluginReposClient, rnd)
}

func testKindClusterAvailablePackageEndpointsForOCIHelper(
t *testing.T,
testCases []testCaseKindClusterAvailablePackageEndpointsForOCISpec,
fluxPluginClient fluxplugin.FluxV2PackagesServiceClient,
fluxPluginReposClient fluxplugin.FluxV2RepositoriesServiceClient) {
fluxPluginReposClient fluxplugin.FluxV2RepositoriesServiceClient, rnd *rand.Rand) {

for _, tc := range testCases {
t.Run(tc.testName, func(t *testing.T) {
repoName := types.NamespacedName{
Name: "my-podinfo-" + randSeq(4),
Name: "my-podinfo-" + randSeq(rnd, 4),
Namespace: "default",
}

Expand Down Expand Up @@ -805,7 +806,7 @@ func testKindClusterAvailablePackageEndpointsForOCIHelper(
}

adminName := types.NamespacedName{
Name: "test-admin-" + randSeq(4),
Name: "test-admin-" + randSeq(rnd, 4),
Namespace: "default",
}
grpcContext, err := newGrpcAdminContext(t, adminName)
Expand Down Expand Up @@ -923,7 +924,7 @@ func testKindClusterAvailablePackageEndpointsForOCIHelper(
}

func TestKindClusterAvailablePackageEndpointsOCIRepo2Charts(t *testing.T) {
fluxPluginClient, _, err := checkEnv(t)
fluxPluginClient, _, rnd, err := checkEnv(t)
if err != nil {
t.Fatal(err)
}
Expand All @@ -940,7 +941,7 @@ func TestKindClusterAvailablePackageEndpointsOCIRepo2Charts(t *testing.T) {
testName: "Testing [" + harbor_repo_with_2_charts_oci_registry_url + "] with basic auth secret (admin)",
registryUrl: harbor_repo_with_2_charts_oci_registry_url,
secret: newBasicAuthSecret(types.NamespacedName{
Name: "oci-repo-secret-" + randSeq(4),
Name: "oci-repo-secret-" + randSeq(rnd, 4),
Namespace: "default"},
harbor_admin_user,
harbor_admin_pwd,
Expand All @@ -951,7 +952,7 @@ func TestKindClusterAvailablePackageEndpointsOCIRepo2Charts(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.testName, func(t *testing.T) {
repoName := types.NamespacedName{
Name: "my-podinfo-" + randSeq(4),
Name: "my-podinfo-" + randSeq(rnd, 4),
Namespace: "default",
}

Expand All @@ -975,7 +976,7 @@ func TestKindClusterAvailablePackageEndpointsOCIRepo2Charts(t *testing.T) {
}

adminName := types.NamespacedName{
Name: "test-admin-" + randSeq(4),
Name: "test-admin-" + randSeq(rnd, 4),
Namespace: "default",
}

Expand Down Expand Up @@ -1010,13 +1011,13 @@ func TestKindClusterAvailablePackageEndpointsOCIRepo2Charts(t *testing.T) {
// The goal of this integration test is to ensure that when the contents of remote HTTP helm repo is changed,
// that fact is recorded locally and processed properly (repo/chart cache is updated with latest, etc.)
func TestKindClusterAddRemovePackageVersionsInHttpRepo(t *testing.T) {
fluxPluginPackagesClient, _, err := checkEnv(t)
fluxPluginPackagesClient, _, rnd, err := checkEnv(t)
if err != nil {
t.Fatal(err)
}

adminAcctName := types.NamespacedName{
Name: "test-add-remove-versions-repo-admin-" + randSeq(4),
Name: "test-add-remove-versions-repo-admin-" + randSeq(rnd, 4),
Namespace: "default",
}
grpcContext, err := newGrpcAdminContext(t, adminAcctName)
Expand All @@ -1026,7 +1027,7 @@ func TestKindClusterAddRemovePackageVersionsInHttpRepo(t *testing.T) {

repoName := types.NamespacedName{
Name: "podinfo",
Namespace: "test-" + randSeq(4),
Namespace: "test-" + randSeq(rnd, 4),
}
if err := kubeCreateNamespaceAndCleanup(t, repoName.Namespace); err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ func RWMutexWriteLocked(rw *sync.RWMutex) bool {
// TODO(minelson): Note the danger of checking private variables like this
// is that they change underneath you. This fails with go 1.20 because
// readerCount has changed from an Int to an atomic.Int32 (struct).
// We'll need to update when upgrading.
// Updated to 1.20, but warning is still applicable.
func RWMutexReadLocked(rw *sync.RWMutex) bool {
return reflect.ValueOf(rw).Elem().FieldByName("readerCount").Int() > 0
return reflect.ValueOf(rw).Elem().FieldByName("readerCount").FieldByName("v").Int() > 0
}

// https://github.com/vmware-tanzu/kubeapps/pull/3044#discussion_r662733334
Expand Down
Loading