mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-14 21:36:54 +00:00
* Feat: show available versions and dependencies in `addon status` Also prettify output Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: show addon dependencies in `addon status` Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: adjust `addon status` output Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: remove spaces in `addon status` output Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Fix: truncate string if available versions too long if a local addon has been installed, the AVAILABLE-VERSIONS column of the registry one will not truncate. this commit fixes that. Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Perf: avoid unnecessary network requests to improve performance Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: do not display remote info for local addons Limit Description length when using `addon list` Use simpler method to get addon info Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests for cli/addon limitStringLength, generateParameterString Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Fix: fix output being empty if the searched addon does not exist anywhere Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests for generateAddonInfo Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests for generateAddonInfo and FindWholeAddonPackagesFromRegistry Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: format code Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: correct unnecessarily focused tests Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: remove unused code blocks Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: remove unnecessary output to stdout Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: remove added registry after tests has been completed Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: new RegistryDataStore every test, to avoid panics Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: fix failing tests due to incorrect registry name Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: move logic to get addon package out of where it is supposed to get addon status Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add test cases for secret-getting in TestGetAddonStatus Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: return error if an addon is not installed, nor does it exist in the registry Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: rename GetAddonWholePackage to GetDetailedAddon as per wonderflow Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: require --verbose option to show details in `vela addon status` Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: require --verbose option to show details in `vela addon status` Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * chore: run make reviewable Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: fix configmap being already existed Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Fix: fix output show addon does not exist when verbose is off and an addon is not installed, but it does exist in the registry Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: fix golangci-lint issues Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
90 lines
2.3 KiB
Go
90 lines
2.3 KiB
Go
/*
|
|
Copyright 2021 The KubeVela Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package cli
|
|
|
|
import (
|
|
"context"
|
|
"math/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
corev1 "k8s.io/api/core/v1"
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/discovery"
|
|
"k8s.io/client-go/rest"
|
|
"k8s.io/utils/pointer"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
|
|
|
"github.com/oam-dev/kubevela/apis/types"
|
|
"github.com/oam-dev/kubevela/pkg/utils/common"
|
|
)
|
|
|
|
func TestCli(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "Cli Suite")
|
|
}
|
|
|
|
var cfg *rest.Config
|
|
var k8sClient client.Client
|
|
var testEnv *envtest.Environment
|
|
var dc *discovery.DiscoveryClient
|
|
|
|
var _ = BeforeSuite(func(done Done) {
|
|
rand.Seed(time.Now().UnixNano())
|
|
By("bootstrapping test environment")
|
|
|
|
testEnv = &envtest.Environment{
|
|
ControlPlaneStartTimeout: time.Minute * 3,
|
|
ControlPlaneStopTimeout: time.Minute,
|
|
UseExistingCluster: pointer.BoolPtr(false),
|
|
CRDDirectoryPaths: []string{"../../charts/vela-core/crds"},
|
|
}
|
|
|
|
By("start kube test env")
|
|
var err error
|
|
cfg, err = testEnv.Start()
|
|
Expect(err).ShouldNot(HaveOccurred())
|
|
Expect(cfg).ToNot(BeNil())
|
|
|
|
By("new kube client")
|
|
cfg.Timeout = time.Minute * 2
|
|
k8sClient, err = client.New(cfg, client.Options{Scheme: common.Scheme})
|
|
Expect(err).Should(BeNil())
|
|
Expect(k8sClient).ToNot(BeNil())
|
|
|
|
dc, err = discovery.NewDiscoveryClientForConfig(cfg)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(dc).ShouldNot(BeNil())
|
|
|
|
By("new namespace")
|
|
err = k8sClient.Create(context.TODO(), &corev1.Namespace{
|
|
ObjectMeta: v1.ObjectMeta{Name: types.DefaultKubeVelaNS},
|
|
})
|
|
Expect(err).Should(BeNil())
|
|
close(done)
|
|
}, 240)
|
|
|
|
var _ = AfterSuite(func() {
|
|
if testEnv != nil {
|
|
err := testEnv.Stop()
|
|
Expect(err).Should(BeNil())
|
|
}
|
|
})
|