using Environment intead of ENV fixes #350

This commit is contained in:
天元 2020-10-08 16:20:16 +08:00
parent e4570e22ae
commit 189175c4db
52 changed files with 70 additions and 70 deletions

View File

@ -39,7 +39,7 @@ vela install
## Use
* Create ENV
* Create environment
```shell script
vela env init myenv --namespace myenv --email my@email.com --domain kubevela.io

View File

@ -60,7 +60,7 @@ func newCommand() *cobra.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
}
cmds.PersistentFlags().StringP("env", "e", "", "specify env name for application")
cmds.PersistentFlags().StringP("env", "e", "", "specify environment name for application")
restConf, err := config.GetConfig()
if err != nil {
fmt.Println("get kubeconfig err", err)

View File

@ -107,7 +107,7 @@ sample response
- example
sample response
```json
{"code":200,"data":"Set env succeed"}
{"code":200,"data":"Set environment succeed"}
```
```json

View File

@ -13,7 +13,7 @@ vela [flags]
### Options
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
-h, --help help for vela
```

View File

@ -21,7 +21,7 @@ vela app <command>
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela app delete frontend
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela app ls
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela app run myAppBundle
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela app show <APPLICATION-NAME>
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela status <APPLICATION-NAME>
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -15,7 +15,7 @@ Capability Management with config, list, add, remove capabilities
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela cap add mycenter/route
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -15,7 +15,7 @@ Manage Capability Center with config, sync, list
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela cap center config mycenter https://github.com/oam-dev/catalog/cap-center
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela cap center ls
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela cap center remove mycenter
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela cap center sync mycenter
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela cap ls
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela cap remove route
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -16,7 +16,7 @@ Manage Components
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela comp delete frontend
```
-a, --app string specify application name for component
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela comp ls
```
-a, --app string specify application name for component
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -28,7 +28,7 @@ vela comp deploy -t <workload-type>
```
-a, --app string specify application name for component
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela comp show <COMPONENT-NAME>
```
-a, --app string specify application name for component
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela comp status <COMPONENT-NAME>
```
-a, --app string specify application name for component
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -18,7 +18,7 @@ of vela commands.
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -29,7 +29,7 @@ vela completion bash
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela completion zsh
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -31,7 +31,7 @@ dashboard
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -1,4 +1,4 @@
## vela env
## vela environment
Manage application environments
@ -9,13 +9,13 @@ Manage application environments
### Options
```
-h, --help help for env
-h, --help help for environment
```
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela env delete test
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -20,13 +20,13 @@ vela env init test --namespace test
```
-h, --help help for init
--namespace string specify K8s namespace for env (default "default")
--namespace string specify K8s namespace for environment (default "default")
```
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela env list [env-name]
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela env set test
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -20,7 +20,7 @@ vela install [flags]
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -19,7 +19,7 @@ vela logs <appname> [flags]
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -29,7 +29,7 @@ vela manualscaler frontend
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -31,7 +31,7 @@ vela rollout frontend
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -29,7 +29,7 @@ vela scale frontend
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -15,7 +15,7 @@ system management utilities
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -19,7 +19,7 @@ vela system info [flags]
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela system update
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -26,7 +26,7 @@ vela traits
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -19,7 +19,7 @@ vela version [flags]
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -25,7 +25,7 @@ vela workloads
### Options inherited from parent commands
```
-e, --env string specify env name for application
-e, --env string specify environment name for application
```
### SEE ALSO

View File

@ -61,7 +61,7 @@ var _ = ginkgo.Describe("API", func() {
e2e.APIEnvInitContext("post /envs/", envHelloMeta)
ginkgo.Context("get /envs/:envName", func() {
ginkgo.It("should get an env", func() {
ginkgo.It("should get an environment", func() {
resp, err := http.Get(util.URL("/envs/" + envHelloMeta.EnvName))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
defer resp.Body.Close()
@ -78,7 +78,7 @@ var _ = ginkgo.Describe("API", func() {
e2e.APIEnvInitContext("post /envs/", envWorldMeta)
ginkgo.Context("set /envs/:envName", func() {
ginkgo.It("should set an env as the currently using one", func() {
ginkgo.It("should set an environment as the currently using one", func() {
req, err := http.NewRequest("PATCH", util.URL("/envs/"+envHelloMeta.EnvName), nil)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
resp, err := http.DefaultClient.Do(req)
@ -90,7 +90,7 @@ var _ = ginkgo.Describe("API", func() {
err = json.Unmarshal(result, &r)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(http.StatusOK).To(gomega.Equal(r.Code))
content := fmt.Sprintf("Set env succeed, current env is " + envHelloMeta.EnvName)
content := fmt.Sprintf("Set environment succeed, current environment is " + envHelloMeta.EnvName)
gomega.Expect(r.Data.(string)).To(gomega.ContainSubstring(content))
})
})

View File

@ -56,11 +56,11 @@ var (
// EnvInitContext used for test Env
EnvInitContext = func(context string, envName string) bool {
return ginkgo.Context(context, func() {
ginkgo.It("should print env initiation successful message", func() {
ginkgo.It("should print environment initiation successful message", func() {
cli := fmt.Sprintf("vela env init %s", envName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
expectedOutput := fmt.Sprintf("ENV %s CREATED,", envName)
expectedOutput := fmt.Sprintf("environment %s created,", envName)
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
})
})
@ -68,7 +68,7 @@ var (
DeleteEnvFunc = func(context string, envName string) bool {
return ginkgo.Context(context, func() {
ginkgo.It("should print env initiation successful message", func() {
ginkgo.It("should print environment initiation successful message", func() {
cli := fmt.Sprintf("vela env delete %s", envName)
_, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@ -78,7 +78,7 @@ var (
EnvShowContext = func(context string, envName string) bool {
return ginkgo.Context(context, func() {
ginkgo.It("should show detailed env message", func() {
ginkgo.It("should show detailed environment message", func() {
cli := fmt.Sprintf("vela env ls %s", envName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@ -91,11 +91,11 @@ var (
EnvSetContext = func(context string, envName string) bool {
return ginkgo.Context(context, func() {
ginkgo.It("should show env set message", func() {
ginkgo.It("should show environment set message", func() {
cli := fmt.Sprintf("vela env sw %s", envName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
expectedOutput := fmt.Sprintf("Set env succeed, current env is %s", envName)
expectedOutput := fmt.Sprintf("Set environment succeed, current environment is %s", envName)
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
})
})
@ -103,7 +103,7 @@ var (
EnvDeleteContext = func(context string, envName string) bool {
return ginkgo.Context(context, func() {
ginkgo.It("should delete an env", func() {
ginkgo.It("should delete an environment", func() {
cli := fmt.Sprintf("vela env delete %s", envName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
@ -118,7 +118,7 @@ var (
cli := fmt.Sprintf("vela env delete %s", envName)
output, err := Exec(cli)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
expectedOutput := fmt.Sprintf("Error: you can't delete current using env %s", envName)
expectedOutput := fmt.Sprintf("Error: you can't delete current using environment %s", envName)
gomega.Expect(output).To(gomega.ContainSubstring(expectedOutput))
})
})
@ -226,7 +226,7 @@ var (
err = json.Unmarshal(result, &r)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(http.StatusOK).Should(gomega.Equal(r.Code))
gomega.Expect(r.Data.(string)).To(gomega.ContainSubstring("CREATED"))
gomega.Expect(r.Data.(string)).To(gomega.ContainSubstring("created"))
})
})
}

View File

@ -135,7 +135,7 @@ func ListEnvs(args []string, ioStreams cmdutil.IOStreams) error {
func DeleteEnv(ctx context.Context, args []string, ioStreams cmdutil.IOStreams) error {
if len(args) < 1 {
return fmt.Errorf("you must specify env name for vela env delete command")
return fmt.Errorf("you must specify environment name for 'vela env delete' command")
}
for _, envName := range args {
msg, err := oam.DeleteEnv(envName)
@ -149,7 +149,7 @@ func DeleteEnv(ctx context.Context, args []string, ioStreams cmdutil.IOStreams)
func CreateOrUpdateEnv(ctx context.Context, c client.Client, envArgs *types.EnvMeta, args []string, ioStreams cmdutil.IOStreams) error {
if len(args) < 1 {
return fmt.Errorf("you must specify env name for vela env init command")
return fmt.Errorf("you must specify environment name for 'vela env init' command")
}
envName := args[0]
envArgs.Name = envName
@ -163,7 +163,7 @@ func CreateOrUpdateEnv(ctx context.Context, c client.Client, envArgs *types.EnvM
func SetEnv(args []string, ioStreams cmdutil.IOStreams) error {
if len(args) < 1 {
return fmt.Errorf("you must specify env name for vela env command")
return fmt.Errorf("you must specify environment name for vela env command")
}
envName := args[0]
msg, err := oam.SetEnv(envName)

View File

@ -112,7 +112,7 @@ var _ = Describe("Metrics Trait Integration Test", func() {
})
AfterEach(func() {
// Control-runtime test ENV has a bug that can't delete resources like deployment/namespaces
// Control-runtime test environment has a bug that can't delete resources like deployment/namespaces
// We have to use different names to segregate between tests
logf.Log.Info("[TEST] Clean up resources after an integration test")
})

View File

@ -95,7 +95,7 @@ func CreateOrUpdateEnv(ctx context.Context, c client.Client, envName string, env
if err = ioutil.WriteFile(curEnvPath, []byte(envName), 0644); err != nil {
return message, err
}
message = fmt.Sprintf("ENV %s CREATED, Namespace: %s, Email: %s.", envName, envArgs.Namespace, envArgs.Email)
message = fmt.Sprintf("environment %s created, Namespace: %s, Email: %s.", envName, envArgs.Namespace, envArgs.Email)
return message, nil
}
@ -205,7 +205,7 @@ func DeleteEnv(envName string) (string, error) {
return message, err
}
if envName == curEnv {
err = fmt.Errorf("you can't delete current using env %s", curEnv)
err = fmt.Errorf("you can't delete current using environment %s", curEnv)
return message, err
}
envdir, err := system.GetEnvDir()
@ -239,6 +239,6 @@ func SetEnv(envName string) (string, error) {
if err = ioutil.WriteFile(currentEnvPath, []byte(envName), 0644); err != nil {
return msg, err
}
msg = fmt.Sprintf("Set env succeed, current env is " + envName + ", namespace is " + envMeta.Namespace)
msg = fmt.Sprintf("Set environment succeed, current environment is " + envName + ", namespace is " + envMeta.Namespace)
return msg, nil
}

View File

@ -145,7 +145,7 @@ func ValidateAndMutateForCore(traitType, workloadName string, flags *pflag.FlagS
domain, _ := flags.GetString("domain")
if domain == "" {
if env.Domain == "" {
return fmt.Errorf("--domain is required if not set in env")
return fmt.Errorf("--domain is required if not contain in environment")
}
if strings.HasPrefix(env.Domain, "https://") {
env.Domain = strings.TrimPrefix(env.Domain, "https://")
@ -160,7 +160,7 @@ func ValidateAndMutateForCore(traitType, workloadName string, flags *pflag.FlagS
issuer, _ := flags.GetString("issuer")
if issuer == "" {
if env.Issuer == "" {
return fmt.Errorf("--issuer is required, you can also set email in env and let it generate automatically")
return fmt.Errorf("--issuer is required, you can also set email in environment and let it generate automatically")
}
if err := flags.Set("issuer", env.Issuer); err != nil {
return fmt.Errorf("set flag for vela-core trait('route') err %v, please make sure your template is right", err)

View File

@ -11,7 +11,7 @@ import (
"github.com/oam-dev/kubevela/pkg/server/util"
)
// ENV related handlers
// environment related handlers
func CreateEnv(c *gin.Context) {
var environment apis.Environment
if err := c.ShouldBindJSON(&environment); err != nil {