Skip to content

Commit

Permalink
Rename 'application-engine' and 'TAE' naming references with 'tanzu'
Browse files Browse the repository at this point in the history
- Renamed the commands with tae naming reference with tanzu
- Updated the plugin-runtime APIs and context type references to user updated APIs and Context types name "tanzu" instead of application-engine/tae

Signed-off-by: Prem Kumar Kalle <[email protected]>
  • Loading branch information
prkalle committed Oct 23, 2023
1 parent 363f522 commit c91404b
Show file tree
Hide file tree
Showing 16 changed files with 737 additions and 288 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/vmware-tanzu/carvel-ytt v0.40.0
github.com/vmware-tanzu/tanzu-cli/test/e2e/framework v0.0.0-00010101000000-000000000000
github.com/vmware-tanzu/tanzu-framework/capabilities/client v0.0.0-20230523145612-1c6fbba34686
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231020193057-c7a71fb36ee4
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231023221021-fc19ad7090a4
go.pinniped.dev v0.20.0
golang.org/x/mod v0.12.0
golang.org/x/oauth2 v0.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ github.com/vmware-tanzu/tanzu-framework/apis/run v0.0.0-20230419030809-7081502eb
github.com/vmware-tanzu/tanzu-framework/apis/run v0.0.0-20230419030809-7081502ebf68/go.mod h1:e1Uef+Ux5BIHpYwqbeP2ZZmOzehBcez2vUEWXHe+xHE=
github.com/vmware-tanzu/tanzu-framework/capabilities/client v0.0.0-20230523145612-1c6fbba34686 h1:VcuXqUXFxm5WDqWkzAlU/6cJXua0ozELnqD59fy7J6E=
github.com/vmware-tanzu/tanzu-framework/capabilities/client v0.0.0-20230523145612-1c6fbba34686/go.mod h1:AFGOXZD4tH+KhpmtV0VjWjllXhr8y57MvOsIxTtywc4=
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231020193057-c7a71fb36ee4 h1:HCQL7DW377uZUbFERnklBRH2Q3UXHpFmcdld/MxvsdI=
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231020193057-c7a71fb36ee4/go.mod h1:M7WVZoItdyQp53tEprQIa6PZmhbrLe3CzuyQphWuRyI=
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231023221021-fc19ad7090a4 h1:84h/u6SbEOubNMq8FP83LS66oWlCR0kGl5sZ4xBiklI=
github.com/vmware-tanzu/tanzu-plugin-runtime v1.1.0-dev.0.20231023221021-fc19ad7090a4/go.mod h1:M7WVZoItdyQp53tEprQIa6PZmhbrLe3CzuyQphWuRyI=
github.com/xanzy/go-gitlab v0.83.0 h1:37p0MpTPNbsTMKX/JnmJtY8Ch1sFiJzVF342+RvZEGw=
github.com/xanzy/go-gitlab v0.83.0/go.mod h1:5ryv+MnpZStBH8I/77HuQBsMbBGANtVpLWC15qOjWAw=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
Expand Down
455 changes: 451 additions & 4 deletions go.work.sum

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions pkg/auth/tae/kubeconfig.go → pkg/auth/tanzu/kubeconfig.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2023 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// Package tae provides TAE authentication functions.
package tae
// Package tanzu provides functionality related to authentication for the Tanzu control plane
package tanzu

import (
"encoding/base64"
Expand All @@ -18,8 +18,8 @@ import (
configtypes "github.com/vmware-tanzu/tanzu-plugin-runtime/config/types"
)

// GetTAEKubeconfig constructs and returns the kubeconfig that points to TAE Org and
func GetTAEKubeconfig(c *configtypes.Context, endpoint, orgID, endpointCACertPath string, skipTLSVerify bool) (string, string, string, error) {
// GetTanzuKubeconfig constructs and returns the kubeconfig that points to Tanzu Org and
func GetTanzuKubeconfig(c *configtypes.Context, endpoint, orgID, endpointCACertPath string, skipTLSVerify bool) (string, string, string, error) {
clusterAPIServerURL := strings.TrimSpace(endpoint)
if !strings.HasPrefix(clusterAPIServerURL, "https://") && !strings.HasPrefix(clusterAPIServerURL, "http://") {
clusterAPIServerURL = "https://" + clusterAPIServerURL
Expand Down Expand Up @@ -54,27 +54,27 @@ func GetTAEKubeconfig(c *configtypes.Context, endpoint, orgID, endpointCACertPat

kubeconfigByes, err := json.Marshal(config)
if err != nil {
return "", "", "", errors.Wrap(err, "failed to marshal the TAE kubeconfig")
return "", "", "", errors.Wrap(err, "failed to marshal the tanzu kubeconfig")
}
kubeconfigPath := kubeutils.GetDefaultKubeConfigFile()
err = kubeutils.MergeKubeConfigWithoutSwitchContext(kubeconfigByes, kubeconfigPath)
if err != nil {
return "", "", "", errors.Wrap(err, "failed to merge the TAE kubeconfig")
return "", "", "", errors.Wrap(err, "failed to merge the tanzu kubeconfig")
}

return kubeconfigPath, contextName, clusterAPIServerURL, nil
}

func kubeconfigContextName(taeContextName string) string {
return "tanzu-cli-" + taeContextName
func kubeconfigContextName(tanzuContextName string) string {
return "tanzu-cli-" + tanzuContextName
}

func kubeconfigClusterName(taeContextName string) string {
return "tanzu-cli-" + taeContextName + "/current"
func kubeconfigClusterName(tanzuContextName string) string {
return "tanzu-cli-" + tanzuContextName + "/current"
}

func kubeconfigUserName(taeContextName string) string {
return "tanzu-cli-" + taeContextName + "-user"
func kubeconfigUserName(tanzuContextName string) string {
return "tanzu-cli-" + tanzuContextName + "-user"
}

func getExecConfig(c *configtypes.Context) *clientcmdapi.ExecConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package tae
package tanzu

import (
"fmt"
Expand All @@ -19,35 +19,35 @@ import (

var testingDir string

func TestTAEAuth(t *testing.T) {
func TestTanzuAuth(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "pkg/auth/tae Suite")
RunSpecs(t, "pkg/auth/tanzu Suite")
}

const (
fakeCAcertPath = "../../fakes/certs/fake-ca.crt"
)

var _ = Describe("Unit tests for tae auth", func() {
var _ = Describe("Unit tests for tanzu auth", func() {
var (
err error
endpoint string
taeContext *configtypes.Context
err error
endpoint string
tanzuContext *configtypes.Context
)

const (
fakeContextName = "fake-tae-context"
fakeContextName = "fake-tanzu-context"
fakeAccessToken = "fake-access-token"
fakeOrgID = "fake-org-id"
fakeEndpoint = "fake.tae.cloud.vmware.com"
fakeEndpoint = "fake.tanzu.cloud.vmware.com"
)

Describe("GetTAEKubeconfig()", func() {
Describe("GetTanzuKubeconfig()", func() {
var kubeConfigPath, kubeContext, clusterAPIServerURL string
BeforeEach(func() {
err = createTempDirectory("kubeconfig-test")
Expect(err).ToNot(HaveOccurred())
taeContext = &configtypes.Context{
tanzuContext = &configtypes.Context{
Name: fakeContextName,
GlobalOpts: &configtypes.GlobalServer{
Auth: configtypes.GlobalServerAuth{
Expand All @@ -66,7 +66,7 @@ var _ = Describe("Unit tests for tae auth", func() {
Context("When the endpoint caCertPath file doesn't exist", func() {
BeforeEach(func() {
nonExistingCACertPath := filepath.Join(testingDir, "non-existing-file")
_, _, _, err = GetTAEKubeconfig(taeContext, fakeEndpoint, fakeOrgID, nonExistingCACertPath, false)
_, _, _, err = GetTanzuKubeconfig(tanzuContext, fakeEndpoint, fakeOrgID, nonExistingCACertPath, false)
})
It("should return the error", func() {
Expect(err).To(HaveOccurred())
Expand All @@ -75,12 +75,12 @@ var _ = Describe("Unit tests for tae auth", func() {
})
Context("When the endpoint caCertPath provided exists and skipTLSVerify is set to false", func() {
BeforeEach(func() {
kubeConfigPath, kubeContext, clusterAPIServerURL, err = GetTAEKubeconfig(taeContext, fakeEndpoint, fakeOrgID, fakeCAcertPath, false)
kubeConfigPath, kubeContext, clusterAPIServerURL, err = GetTanzuKubeconfig(tanzuContext, fakeEndpoint, fakeOrgID, fakeCAcertPath, false)
})
It("should set the 'certificate-authority-data' in kubeconfig and 'insecure-skip-tls-verify' should be unset", func() {
Expect(err).ToNot(HaveOccurred())
Expect(kubeConfigPath).Should(Equal(filepath.Join(testingDir, ".kube", "config")))
Expect(kubeContext).Should(Equal(kubeconfigContextName(taeContext.Name)))
Expect(kubeContext).Should(Equal(kubeconfigContextName(tanzuContext.Name)))
config, err := clientcmd.LoadFromFile(kubeConfigPath)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -89,20 +89,20 @@ var _ = Describe("Unit tests for tae auth", func() {
user := config.AuthInfos[config.Contexts[kubeContext].AuthInfo]

Expect(cluster.Server).To(Equal(clusterAPIServerURL))
Expect(config.Contexts[kubeContext].AuthInfo).To(Equal(kubeconfigUserName(taeContext.Name)))
Expect(gotClusterName).To(Equal(kubeconfigClusterName(taeContext.Name)))
Expect(config.Contexts[kubeContext].AuthInfo).To(Equal(kubeconfigUserName(tanzuContext.Name)))
Expect(gotClusterName).To(Equal(kubeconfigClusterName(tanzuContext.Name)))
Expect(len(cluster.CertificateAuthorityData)).ToNot(Equal(0))
Expect(user.Exec).To(Equal(getExecConfig(taeContext)))
Expect(user.Exec).To(Equal(getExecConfig(tanzuContext)))
})
})
Context("When endpointCACertPath is not provided and skipTLSVerify is set to true", func() {
BeforeEach(func() {
kubeConfigPath, kubeContext, clusterAPIServerURL, err = GetTAEKubeconfig(taeContext, endpoint, fakeOrgID, "", true)
kubeConfigPath, kubeContext, clusterAPIServerURL, err = GetTanzuKubeconfig(tanzuContext, endpoint, fakeOrgID, "", true)
})
It("should not set the 'certificate-authority-data' in kubeconfig and 'insecure-skip-tls-verify' should be set", func() {
Expect(err).ToNot(HaveOccurred())
Expect(kubeConfigPath).Should(Equal(filepath.Join(testingDir, ".kube", "config")))
Expect(kubeContext).Should(Equal("tanzu-cli-" + taeContext.Name))
Expect(kubeContext).Should(Equal("tanzu-cli-" + tanzuContext.Name))
config, err := clientcmd.LoadFromFile(kubeConfigPath)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -111,11 +111,11 @@ var _ = Describe("Unit tests for tae auth", func() {
user := config.AuthInfos[config.Contexts[kubeContext].AuthInfo]

Expect(cluster.Server).To(Equal(clusterAPIServerURL))
Expect(config.Contexts[kubeContext].AuthInfo).To(Equal("tanzu-cli-" + taeContext.Name + "-user"))
Expect(gotClusterName).To(Equal("tanzu-cli-" + taeContext.Name + "/current"))
Expect(config.Contexts[kubeContext].AuthInfo).To(Equal("tanzu-cli-" + tanzuContext.Name + "-user"))
Expect(gotClusterName).To(Equal("tanzu-cli-" + tanzuContext.Name + "/current"))
Expect(len(cluster.CertificateAuthorityData)).To(Equal(0))
Expect(cluster.InsecureSkipTLSVerify).To(Equal(true))
Expect(user.Exec).To(Equal(getExecConfig(taeContext)))
Expect(user.Exec).To(Equal(getExecConfig(tanzuContext)))
})
})

Expand Down
6 changes: 3 additions & 3 deletions pkg/command/completion_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const (
compTMCTarget = "tmc\tFor interactions with a Tanzu Mission Control endpoint"

// Completion strings for the values of the --type flag
compK8sContextType = "k8s\tContext for a Kubernetes cluster"
compTAEContextType = "tae\tContext for a Tanzu Application Engine endpoint"
compTMCContextType = "tmc\tContext for a Tanzu Mission Control endpoint"
compK8sContextType = "k8s\tContext for a Kubernetes cluster"
compTanzuContextType = "tanzu\tContext for a Tanzu endpoint"
compTMCContextType = "tmc\tContext for a Tanzu Mission Control endpoint"

// Completion strings for the values of the --output flag
compTableOutput = "table\tOutput results in human-readable format"
Expand Down
Loading

0 comments on commit c91404b

Please sign in to comment.