mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
minor fixes
This commit is contained in:
17
README.md
17
README.md
@@ -171,4 +171,21 @@ $ source <(vela completion zsh)
|
||||
|
||||
To load completions for every new session, execute once:
|
||||
$ vela completion zsh > "${fpath[1]}/_vela"
|
||||
```
|
||||
|
||||
### Clean your environment
|
||||
|
||||
```shell script
|
||||
$ helm uninstall core-runtime -n oam-system
|
||||
release "core-runtime" uninstalled
|
||||
```
|
||||
|
||||
```shell script
|
||||
$ kubectl delete crd workloaddefinitions.core.oam.dev traitdefinitions.core.oam.dev
|
||||
customresourcedefinition.apiextensions.k8s.io "workloaddefinitions.core.oam.dev" deleted
|
||||
customresourcedefinition.apiextensions.k8s.io "traitdefinitions.core.oam.dev" deleted
|
||||
```
|
||||
|
||||
```shell script
|
||||
$ rm -r ~/.vela
|
||||
```
|
||||
@@ -76,7 +76,7 @@ func newCommand() *cobra.Command {
|
||||
cmd.Println("Flags:")
|
||||
cmd.Println(" -h, --help help for vela")
|
||||
cmd.Println()
|
||||
cmd.Println(`Want more? Use "vela [command] --help" for more information about a command.`)
|
||||
cmd.Println(`Use "vela [command] --help" for more information about a command.`)
|
||||
},
|
||||
SilenceUsage: true,
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
@@ -162,7 +162,7 @@ func PrintHelpByTag(cmd *cobra.Command, all []*cobra.Command, tag string) {
|
||||
if len(table.Rows) > 0 {
|
||||
cmd.Println()
|
||||
}
|
||||
cmd.Println(" <use 'vela refresh' to sync from cluster or install by `vela cap` >")
|
||||
cmd.Println(" Want more? <use 'vela refresh' to sync from cluster or install by `vela cap` >")
|
||||
}
|
||||
cmd.Println()
|
||||
}
|
||||
|
||||
@@ -15,22 +15,35 @@ spec:
|
||||
kind: "Deployment"
|
||||
metadata: name: deployment.name
|
||||
spec: {
|
||||
containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
selector:
|
||||
matchLabels:
|
||||
app: deployment.name
|
||||
template: {
|
||||
metadata:
|
||||
labels:
|
||||
app: deployment.name
|
||||
spec: containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deployment: {
|
||||
name: string
|
||||
name: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
port: *8080 | int
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *8080 | int
|
||||
env: [...{
|
||||
name: string
|
||||
value: string
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("example test", func () {
|
||||
var _ = Describe("example test", func() {
|
||||
|
||||
It("Test get environment", func() {
|
||||
w := httptest.NewRecorder()
|
||||
@@ -20,4 +20,4 @@ var _ = Describe("example test", func () {
|
||||
// TODO: unmarshall the body and check
|
||||
fmt.Println(w.Body.String())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -10,6 +10,8 @@ metadata:
|
||||
spec:
|
||||
appliesToWorkloads:
|
||||
- core.oam.dev/v1alpha2.ContainerizedWorkload
|
||||
- apps/v1.Deployment
|
||||
workloadRefPath: spec.workloadRef
|
||||
definitionRef:
|
||||
name: manualscalertraits.core.oam.dev
|
||||
extension:
|
||||
@@ -18,10 +20,10 @@ spec:
|
||||
apiVersion: "core.oam.dev/v1alpha2"
|
||||
kind: "ManualScalerTrait"
|
||||
spec: {
|
||||
replicaCount: manualscaler.replica
|
||||
replicaCount: scale.replica
|
||||
}
|
||||
}
|
||||
manualscaler: {
|
||||
scale: {
|
||||
//+short=r
|
||||
replica: *2 | int
|
||||
}
|
||||
|
||||
@@ -17,22 +17,35 @@ spec:
|
||||
kind: "Deployment"
|
||||
metadata: name: deployment.name
|
||||
spec: {
|
||||
containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
selector:
|
||||
matchLabels:
|
||||
app: deployment.name
|
||||
template: {
|
||||
metadata:
|
||||
labels:
|
||||
app: deployment.name
|
||||
spec: containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deployment: {
|
||||
name: string
|
||||
name: string
|
||||
// +usage=specify app image
|
||||
// +short=i
|
||||
image: string
|
||||
port: *8080 | int
|
||||
// +usage=specify port for container
|
||||
// +short=p
|
||||
port: *8080 | int
|
||||
env: [...{
|
||||
name: string
|
||||
value: string
|
||||
|
||||
@@ -372,7 +372,7 @@ func InstallCapability(client client.Client, centerName, capabilityName string,
|
||||
}
|
||||
|
||||
func InstallHelmChart(ioStreams cmdutil.IOStreams, c types.Chart) error {
|
||||
return HelmInstall(ioStreams, c.Repo, c.URl, c.Name, c.Version, c.Name)
|
||||
return HelmInstall(ioStreams, c.Repo, c.URl, c.Name, c.Version, c.Name, nil)
|
||||
}
|
||||
|
||||
func GetSyncedCapabilities(repoName, addonName string) (types.Capability, error) {
|
||||
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
func NewRefreshCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Command {
|
||||
ctx := context.Background()
|
||||
cmd := &cobra.Command{
|
||||
Use: "refresh",
|
||||
Use: "system:update",
|
||||
DisableFlagsInUseLine: true,
|
||||
Short: "Sync definition from cluster",
|
||||
Long: "Refresh and sync definition files from cluster",
|
||||
Example: `vela refresh`,
|
||||
Example: `vela system:update`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
newClient, err := client.New(c.Config, client.Options{Scheme: c.Schema})
|
||||
if err != nil {
|
||||
|
||||
@@ -148,7 +148,7 @@ func NewAdminInitCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Comma
|
||||
}
|
||||
|
||||
func (i *initCmd) run(ioStreams cmdutil.IOStreams) error {
|
||||
ioStreams.Info("- Install OAM Kubernetes Runtime:")
|
||||
ioStreams.Info("- Installing OAM Kubernetes Runtime:")
|
||||
if !cmdutil.IsNamespaceExist(i.client, types.DefaultOAMNS) {
|
||||
if err := cmdutil.NewNamespace(i.client, types.DefaultOAMNS); err != nil {
|
||||
return err
|
||||
@@ -163,10 +163,15 @@ func (i *initCmd) run(ioStreams cmdutil.IOStreams) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ioStreams.Info("- Apply builtin capabilities:")
|
||||
ioStreams.Info("- Installing builtin capabilities:")
|
||||
if err := GenNativeResourceDefinition(i.client); err != nil {
|
||||
return err
|
||||
}
|
||||
ioStreams.Info()
|
||||
if err := RefreshDefinitions(context.Background(), i.client, ioStreams); err != nil {
|
||||
return err
|
||||
}
|
||||
ioStreams.Info("- Finished.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -194,10 +199,10 @@ func IsHelmReleaseRunning(releaseName, chartName string, streams cmdutil.IOStrea
|
||||
}
|
||||
|
||||
func InstallOamRuntime(ioStreams cmdutil.IOStreams, version string) error {
|
||||
return HelmInstall(ioStreams, types.DefaultOAMRepoName, types.DefaultOAMRepoUrl, types.DefaultOAMRuntimeChartName, version, types.DefaultOAMReleaseName)
|
||||
return HelmInstall(ioStreams, types.DefaultOAMRepoName, types.DefaultOAMRepoUrl, types.DefaultOAMRuntimeChartName, version, types.DefaultOAMReleaseName, nil)
|
||||
}
|
||||
|
||||
func HelmInstall(ioStreams cmdutil.IOStreams, repoName, repoUrl, chartName, version, releaseName string) error {
|
||||
func HelmInstall(ioStreams cmdutil.IOStreams, repoName, repoUrl, chartName, version, releaseName string, vals map[string]interface{}) error {
|
||||
if !IsHelmRepositoryExist(repoName, repoUrl) {
|
||||
err := AddHelmRepository(repoName, repoUrl,
|
||||
"", "", "", "", "", false, ioStreams.Out)
|
||||
@@ -217,7 +222,7 @@ func HelmInstall(ioStreams cmdutil.IOStreams, repoName, repoUrl, chartName, vers
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
release, err := chartClient.Run(chartRequested, nil)
|
||||
release, err := chartClient.Run(chartRequested, vals)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -254,6 +259,9 @@ func NewHelmInstall(version, releaseName string, ioStreams cmdutil.IOStreams) (*
|
||||
|
||||
client := action.NewInstall(actionConfig)
|
||||
client.ReleaseName = releaseName
|
||||
// MUST set here, client didn't use namespace from configuration
|
||||
client.Namespace = types.DefaultOAMNS
|
||||
|
||||
if len(version) > 0 {
|
||||
client.Version = version
|
||||
} else {
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestEval(t *testing.T) {
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"name":"myapp"},"spec":{"containers":[{"name":"myapp","env":[{"name":"MYDB","value":"true"}],"image":"nginx:v1","ports":[{"name":"default","containerPort":8080,"protocol":"TCP"}]}]}}`,
|
||||
assert.Equal(t, `{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"name":"myapp"},"spec":{"selector":{"matchLabels":{"app":"myapp"}},"template":{"metadata":{"labels":{"app":"myapp"}},"spec":{"containers":[{"name":"myapp","env":[{"name":"MYDB","value":"true"}],"image":"nginx:v1","ports":[{"name":"default","containerPort":8080,"protocol":"TCP"}]}]}}}}`,
|
||||
data)
|
||||
}
|
||||
|
||||
|
||||
26
pkg/cue/testdata/workloads/deployment.cue
vendored
26
pkg/cue/testdata/workloads/deployment.cue
vendored
@@ -3,16 +3,24 @@
|
||||
kind: "Deployment"
|
||||
metadata: name: deployment.name
|
||||
spec: {
|
||||
containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
selector:
|
||||
matchLabels:
|
||||
app: deployment.name
|
||||
template: {
|
||||
metadata:
|
||||
labels:
|
||||
app: deployment.name
|
||||
spec: containers: [{
|
||||
image: deployment.image
|
||||
name: deployment.name
|
||||
env: deployment.env
|
||||
ports: [{
|
||||
containerPort: deployment.port
|
||||
protocol: "TCP"
|
||||
name: "default"
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user