Compare commits

...

9 Commits

Author SHA1 Message Date
Tianxin Dong
4209080adc Fix: add volume bottom check in resource topology rule (#5835)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2023-04-13 10:56:46 +08:00
github-actions[bot]
61348b9d45 Fix: use step id to filter the log data and fix the regex (#5813)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
(cherry picked from commit 308093159f)

Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2023-04-07 10:40:41 +08:00
github-actions[bot]
aa5e825683 Fix: fix step id to name in workflow logs (#5807)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
(cherry picked from commit 6b1f57e877)

Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2023-04-06 14:59:44 +08:00
github-actions[bot]
95d04c370d Fix: vela top cannot switch the theme (#5756)
Signed-off-by: howieyuen <howieyuen@outlook.com>
(cherry picked from commit cb1c33bed1)

Co-authored-by: howieyuen <howieyuen@outlook.com>
2023-03-28 15:38:55 +08:00
github-actions[bot]
a583f66b0d [Backport release-1.7] Fix: gateway message is wrong (#5751)
Co-authored-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>
2023-03-28 09:30:29 +08:00
github-actions[bot]
7ae1aff648 [Backport release-1.7] Fix: fix vela-minimal helm chart unrecognised options (#5729)
* fix(vela-minimal): fix unrecognised options

Signed-off-by: florent.madiot.e <florent.madiot.e@thalesdigital.io>
(cherry picked from commit c9394a18a6)

* Fix(vela-minimal): make reviewable

Signed-off-by: florent.madiot.e <florent.madiot.e@thalesdigital.io>
(cherry picked from commit f4f7f96cc8)

---------

Co-authored-by: florent.madiot.e <florent.madiot.e@thalesdigital.io>
2023-03-24 11:29:34 +08:00
github-actions[bot]
0ff40d75e5 Fix: use logs to show errs intead of return in adopt all (#5712)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
(cherry picked from commit f0e3c33be2)

Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2023-03-21 13:40:54 +08:00
github-actions[bot]
3d410fed5f Fix: system crd validation hook should not always use the default vela system (#5711)
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
(cherry picked from commit b4b0f99f41)

Co-authored-by: Somefive <yd219913@alibaba-inc.com>
2023-03-21 10:18:28 +08:00
Tianxin Dong
f8285df49d Feat: add adopt all command (#5690) (#5696) (#5697)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
2023-03-20 13:40:04 +08:00
15 changed files with 114 additions and 63 deletions

View File

@@ -113,19 +113,20 @@ spec:
}
if context.outputs.ingress.status.loadBalancer.ingress != _|_ {
let igs = context.outputs.ingress.status.loadBalancer.ingress
let host = context.outputs.ingress.spec.rules[0].host
if igs[0].ip != _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].host == _|_ {
if host == _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster with IP: " + igs[0].ip
}
}
if igs[0].ip == _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
if igs[0].host != _|_ {
if host != _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster"
}
}

View File

@@ -65,7 +65,6 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-minimal --
| `controllerArgs.reSyncPeriod` | The period for resync the applications | `5m` |
| `OAMSpecVer` | OAMSpecVer is the oam spec version controller want to setup | `minimal` |
| `disableCaps` | Disable capability | `envbinding,rollout` |
| `applyOnceOnly` | Valid applyOnceOnly values: true/false/on/off/force | `off` |
| `dependCheckWait` | dependCheckWait is the time to wait for ApplicationConfiguration's dependent-resource ready | `30s` |
@@ -97,20 +96,29 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-minimal --
| `healthCheck.port` | KubeVela health check port | `9440` |
### KubeVela controller optimization parameters
| Name | Description | Value |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `featureGates.applyOnce` | if enabled, the apply-once feature will be applied to all applications, no state-keep and no resource data storage in ResourceTracker | `false` |
### MultiCluster parameters
| Name | Description | Value |
| ----------------------------------------------------- | -------------------------------- | -------------------------------- |
| `multicluster.enabled` | Whether to enable multi-cluster | `true` |
| `multicluster.clusterGateway.replicaCount` | ClusterGateway replica count | `1` |
| `multicluster.clusterGateway.port` | ClusterGateway port | `9443` |
| `multicluster.clusterGateway.image.repository` | ClusterGateway image repository | `oamdev/cluster-gateway` |
| `multicluster.clusterGateway.image.tag` | ClusterGateway image tag | `v1.7.0` |
| `multicluster.clusterGateway.image.pullPolicy` | ClusterGateway image pull policy | `IfNotPresent` |
| `multicluster.clusterGateway.resources.limits.cpu` | ClusterGateway cpu limit | `100m` |
| `multicluster.clusterGateway.resources.limits.memory` | ClusterGateway memory limit | `200Mi` |
| `multicluster.clusterGateway.secureTLS.enabled` | Whether to enable secure TLS | `true` |
| `multicluster.clusterGateway.secureTLS.certPath` | Path to the certificate file | `/etc/k8s-cluster-gateway-certs` |
| Name | Description | Value |
| ------------------------------------------------------- | -------------------------------- | -------------------------------- |
| `multicluster.enabled` | Whether to enable multi-cluster | `true` |
| `multicluster.clusterGateway.replicaCount` | ClusterGateway replica count | `1` |
| `multicluster.clusterGateway.port` | ClusterGateway port | `9443` |
| `multicluster.clusterGateway.image.repository` | ClusterGateway image repository | `oamdev/cluster-gateway` |
| `multicluster.clusterGateway.image.tag` | ClusterGateway image tag | `v1.8.0-alpha.3` |
| `multicluster.clusterGateway.image.pullPolicy` | ClusterGateway image pull policy | `IfNotPresent` |
| `multicluster.clusterGateway.resources.requests.cpu` | ClusterGateway cpu request | `50m` |
| `multicluster.clusterGateway.resources.requests.memory` | ClusterGateway memory request | `20Mi` |
| `multicluster.clusterGateway.resources.limits.cpu` | ClusterGateway cpu limit | `500m` |
| `multicluster.clusterGateway.resources.limits.memory` | ClusterGateway memory limit | `200Mi` |
| `multicluster.clusterGateway.secureTLS.enabled` | Whether to enable secure TLS | `true` |
| `multicluster.clusterGateway.secureTLS.certPath` | Path to the certificate file | `/etc/k8s-cluster-gateway-certs` |
### Test parameters

View File

@@ -113,19 +113,20 @@ spec:
}
if context.outputs.ingress.status.loadBalancer.ingress != _|_ {
let igs = context.outputs.ingress.status.loadBalancer.ingress
let host = context.outputs.ingress.spec.rules[0].host
if igs[0].ip != _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].host == _|_ {
if host == _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster with IP: " + igs[0].ip
}
}
if igs[0].ip == _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
if igs[0].host != _|_ {
if host != _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster"
}
}

View File

@@ -166,10 +166,8 @@ spec:
- "--use-webhook=true"
- "--webhook-port={{ .Values.webhookService.port }}"
- "--webhook-cert-dir={{ .Values.admissionWebhooks.certificate.mountPath }}"
- "--autogen-workload-definition={{ .Values.admissionWebhooks.autoGenWorkloadDefinition }}"
{{ end }}
- "--health-addr=:{{ .Values.healthCheck.port }}"
- "--apply-once-only={{ .Values.applyOnceOnly }}"
{{ if ne .Values.disableCaps "" }}
- "--disable-caps={{ .Values.disableCaps }}"
{{ end }}
@@ -188,6 +186,7 @@ spec:
- "--max-workflow-step-error-retry-times={{ .Values.workflow.step.errorRetryTimes }}"
- "--feature-gates=EnableSuspendOnFailure={{- .Values.workflow.enableSuspendOnFailure | toString -}}"
- "--feature-gates=AuthenticateApplication={{- .Values.authentication.enabled | toString -}}"
- "--feature-gates=ApplyOnce={{- .Values.featureGates.applyOnce | toString -}}"
{{ if .Values.authentication.enabled }}
{{ if .Values.authentication.withUser }}
- "--authentication-with-user"

View File

@@ -26,9 +26,6 @@ OAMSpecVer: "minimal"
## @param disableCaps Disable capability
disableCaps: "envbinding,rollout"
## @param applyOnceOnly Valid applyOnceOnly values: true/false/on/off/force
applyOnceOnly: "off"
## @param dependCheckWait dependCheckWait is the time to wait for ApplicationConfiguration's dependent-resource ready
dependCheckWait: 30s
@@ -86,6 +83,11 @@ webhookService:
healthCheck:
port: 9440
## @section KubeVela controller optimization parameters
##@param featureGates.applyOnce if enabled, the apply-once feature will be applied to all applications, no state-keep and no resource data storage in ResourceTracker
featureGates:
applyOnce: false
## @section MultiCluster parameters
@@ -95,6 +97,8 @@ healthCheck:
## @param multicluster.clusterGateway.image.repository ClusterGateway image repository
## @param multicluster.clusterGateway.image.tag ClusterGateway image tag
## @param multicluster.clusterGateway.image.pullPolicy ClusterGateway image pull policy
## @param multicluster.clusterGateway.resources.requests.cpu ClusterGateway cpu request
## @param multicluster.clusterGateway.resources.requests.memory ClusterGateway memory request
## @param multicluster.clusterGateway.resources.limits.cpu ClusterGateway cpu limit
## @param multicluster.clusterGateway.resources.limits.memory ClusterGateway memory limit
## @param multicluster.clusterGateway.secureTLS.enabled Whether to enable secure TLS
@@ -106,11 +110,14 @@ multicluster:
port: 9443
image:
repository: oamdev/cluster-gateway
tag: v1.7.0
tag: v1.8.0-alpha.3
pullPolicy: IfNotPresent
resources:
requests:
cpu: 50m
memory: 20Mi
limits:
cpu: 100m
cpu: 500m
memory: 200Mi
secureTLS:
enabled: true

View File

@@ -22,6 +22,7 @@ import (
"time"
"github.com/kubevela/pkg/util/compression"
"github.com/kubevela/pkg/util/k8s"
"github.com/kubevela/pkg/util/singleton"
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog/v2"
@@ -55,7 +56,7 @@ func (in *SystemCRDValidationHook) Run(ctx context.Context) error {
feature.DefaultMutableFeatureGate.Enabled(features.GzipApplicationRevision) {
appRev := &v1beta1.ApplicationRevision{}
appRev.Name = fmt.Sprintf("core.pre-check.%d", time.Now().UnixNano())
appRev.Namespace = types.DefaultKubeVelaNS
appRev.Namespace = k8s.GetRuntimeNamespace()
key := client.ObjectKeyFromObject(appRev)
appRev.SetLabels(map[string]string{oam.LabelPreCheck: types.VelaCoreName})
appRev.Spec.Application.Name = appRev.Name

8
go.mod
View File

@@ -56,9 +56,9 @@ require (
github.com/imdario/mergo v0.3.13
github.com/kubevela/pkg v0.0.0-20230316114047-e2b41b377bac
github.com/kubevela/prism v1.7.0-alpha.1
github.com/kubevela/workflow v0.4.1
github.com/kubevela/workflow v0.4.3
github.com/kyokomi/emoji v2.2.4+incompatible
github.com/mitchellh/hashstructure/v2 v2.0.1
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/oam-dev/cluster-gateway v1.7.0-alpha.1
github.com/oam-dev/cluster-register v1.0.4-0.20220928064144-5f76a9d7ca8c
@@ -87,7 +87,7 @@ require (
go.mongodb.org/mongo-driver v1.5.1
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.4.0
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c
golang.org/x/term v0.5.0
golang.org/x/text v0.7.0
gomodules.xyz/jsonpatch/v2 v2.2.0
@@ -309,7 +309,7 @@ require (
golang.org/x/tools v0.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
gopkg.in/inf.v0 v0.9.1 // indirect

15
go.sum
View File

@@ -1289,8 +1289,8 @@ github.com/kubevela/pkg v0.0.0-20230316114047-e2b41b377bac h1:TLQchMx+BRTnHyebDp
github.com/kubevela/pkg v0.0.0-20230316114047-e2b41b377bac/go.mod h1:GilLxt+9L4sU2tLeZAGHga8wiYmjjfPX/Q6JkyuuXSM=
github.com/kubevela/prism v1.7.0-alpha.1 h1:oeZFn1Oy6gxSSFzMTfsWjLOCKaaooMVm1JGNK4j4Mlo=
github.com/kubevela/prism v1.7.0-alpha.1/go.mod h1:AJSDfdA+RkRSnWx3xEcogbmOTpX+l7RSIwqVHxwUtaI=
github.com/kubevela/workflow v0.4.1 h1:lYeWE9KgSSkb368u8G7cGfyzCz41Am8MdxgViRFJxXE=
github.com/kubevela/workflow v0.4.1/go.mod h1:AX/WL3G/YBkpmNpA/SKKm9M3Y0T9y95gZA8mFWylkyM=
github.com/kubevela/workflow v0.4.3 h1:1WAMb4xrRXQW5hK5bXwV2WFHlxn2+ezkblai8oC5DmY=
github.com/kubevela/workflow v0.4.3/go.mod h1:U94Hz5rlHPAatN+Birhumly26zjAguMumdhrYk+e5mo=
github.com/kulti/thelper v0.4.0/go.mod h1:vMu2Cizjy/grP+jmsvOFDx1kYP6+PD1lqg4Yu5exl2U=
github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4=
github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
@@ -1435,8 +1435,8 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ=
github.com/mitchellh/hashstructure/v2 v2.0.1 h1:L60q1+q7cXE4JeEJJKMnh2brFIe3rZxCihYAB61ypAY=
github.com/mitchellh/hashstructure/v2 v2.0.1/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
@@ -2319,8 +2319,8 @@ golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE=
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 h1:+jnHzr9VPj32ykQVai5DNahi9+NSp7yYuCsl5eAQtL0=
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE=
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY=
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -2813,8 +2813,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=

View File

@@ -273,11 +273,13 @@ func (opt *AdoptOptions) MultipleRun(f velacmd.Factory, cmd *cobra.Command) erro
list := &unstructured.UnstructuredList{}
list.SetGroupVersionKind(gvk)
if err := f.Client().List(ctx, list, &client.ListOptions{Namespace: opt.AppNamespace, LabelSelector: selector}); err != nil {
return err
apiVersion, kind := gvk.ToAPIVersionAndKind()
_, _ = fmt.Fprintf(opt.Out, "Warning: failed to list resources from %s/%s: %s", apiVersion, kind, err.Error())
continue
}
engine := resourcetopology.New(opt.ResourceTopologyRule)
dedup := make([]k8s.ResourceIdentifier, 0)
for _, item := range list.Items {
engine := resourcetopology.New(opt.ResourceTopologyRule)
itemIdentifier := k8s.ResourceIdentifier{
Name: item.GetName(),
Namespace: item.GetNamespace(),
@@ -287,22 +289,26 @@ func (opt *AdoptOptions) MultipleRun(f velacmd.Factory, cmd *cobra.Command) erro
if velaslices.Contains(dedup, itemIdentifier) {
continue
}
peers, err := engine.GetPeerResources(ctx, itemIdentifier)
dedup = append(dedup, peers...)
if err != nil {
return err
}
firstElement := item
r := []*unstructured.Unstructured{&firstElement}
peers, err := engine.GetPeerResources(ctx, itemIdentifier)
if err != nil {
_, _ = fmt.Fprintf(opt.Out, "Warning: failed to get peer resources for %s/%s: %s", itemIdentifier.APIVersion, itemIdentifier.Kind, err.Error())
resources = append(resources, r)
continue
}
dedup = append(dedup, peers...)
for _, peer := range peers {
gvk, err := k8s.GetGVKFromResource(peer)
if err != nil {
return err
_, _ = fmt.Fprintf(opt.Out, "Warning: failed to get gvk from resource %s/%s: %s", peer.APIVersion, peer.Kind, err.Error())
continue
}
peerResource := &unstructured.Unstructured{}
peerResource.SetGroupVersionKind(gvk)
if err := f.Client().Get(ctx, apitypes.NamespacedName{Namespace: peer.Namespace, Name: peer.Name}, peerResource); err != nil {
return err
_, _ = fmt.Fprintf(opt.Out, "Warning: failed to get resource %s/%s: %s", peer.Namespace, peer.Name, err.Error())
continue
}
r = append(r, peerResource)
}
@@ -322,7 +328,8 @@ func (opt *AdoptOptions) MultipleRun(f velacmd.Factory, cmd *cobra.Command) erro
opt.AppName = r[0].GetName()
opt.AppNamespace = r[0].GetNamespace()
if err := opt.Run(f, cmd); err != nil {
return err
_, _ = fmt.Fprintf(opt.Out, "Error: failed to adopt %s/%s: %s", opt.AppNamespace, opt.AppName, err.Error())
continue
}
}
for _, r := range releases {
@@ -332,10 +339,12 @@ func (opt *AdoptOptions) MultipleRun(f velacmd.Factory, cmd *cobra.Command) erro
opt.HelmReleaseNamespace = r.Namespace
// TODO(fog): filter the helm that already adopted by vela
if err := opt.loadHelm(); err != nil {
return err
_, _ = fmt.Fprintf(opt.Out, "Error: failed to load helm for %s/%s: %s", opt.AppNamespace, opt.AppName, err.Error())
continue
}
if err := opt.Run(f, cmd); err != nil {
return err
_, _ = fmt.Fprintf(opt.Out, "Error: failed to adopt %s/%s: %s", opt.AppNamespace, opt.AppName, err.Error())
continue
}
}
return nil

View File

@@ -19,6 +19,7 @@ package cli
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/fatih/color"
@@ -34,6 +35,8 @@ import (
"github.com/oam-dev/kubevela/references/appfile"
)
var re = regexp.MustCompile(`"((?:[^"\\]|\\.)*)"`)
// NewLogsCommand creates `logs` command to tail logs of application
func NewLogsCommand(c common.Args, order string, ioStreams util.IOStreams) *cobra.Command {
largs := &Args{Args: c}
@@ -122,6 +125,10 @@ func (l *Args) printPodLogs(ctx context.Context, ioStreams util.IOStreams, selec
}
}
if show {
match := re.FindStringSubmatch(str)
if len(match) > 1 {
str = strings.ReplaceAll(match[1], "\\n", "\n")
}
ioStreams.Infonln(str)
}
case <-ctx.Done():

View File

@@ -58,8 +58,10 @@ commonPeerResources: [{
resource: "configMap"
selectors: {
name: [
for v in context.data.spec.template.spec.volumes if v.configMap != _|_ if v.configMap.name != _|_ {
v.configMap.name
if context.data.spec.template.spec.volumes != _|_ {
for v in context.data.spec.template.spec.volumes if v.configMap != _|_ if v.configMap.name != _|_ {
v.configMap.name
},
},
]
}
@@ -68,8 +70,10 @@ commonPeerResources: [{
resource: "secret"
selectors: {
name: [
for v in context.data.spec.template.spec.volumes if v.secret != _|_ if v.secret.name != _|_ {
v.secret.name
if context.data.spec.template.spec.volumes != _|_ {
for v in context.data.spec.template.spec.volumes if v.secret != _|_ if v.secret.name != _|_ {
v.secret.name
},
},
]
}

View File

@@ -291,7 +291,7 @@ func makeThemeConfigFileIfNotExist() bool {
if _, err := os.Open(filepath.Clean(themeConfigFilePath)); err != nil {
if os.IsNotExist(err) {
// make file if not exist
_ = os.MkdirAll(filepath.Clean(velaThemeHome), 0600)
_ = os.MkdirAll(filepath.Clean(velaThemeHome), 0700)
_ = os.WriteFile(filepath.Clean(themeConfigFilePath), []byte("name : "+DefaultTheme), 0600)
}
return false

View File

@@ -17,6 +17,8 @@ limitations under the License.
package config
import (
"os"
"strings"
"testing"
"github.com/gdamore/tcell/v2"
@@ -35,3 +37,11 @@ func TestColor(t *testing.T) {
c2 := Color("red")
assert.Equal(t, c2.Color(), tcell.GetColor("red").TrueColor())
}
func TestPersistentThemeConfig(t *testing.T) {
defer PersistentThemeConfig(DefaultTheme)
PersistentThemeConfig("foo")
bytes, err := os.ReadFile(themeConfigFilePath)
assert.Nil(t, err)
assert.True(t, strings.Contains(string(bytes), "foo"))
}

View File

@@ -243,6 +243,7 @@ type WorkflowArgs struct {
Writer io.Writer
Args common.Args
StepName string
StepID string
ErrMap map[string]string
App *v1beta1.Application
WorkflowRun *workflowv1alpha1.WorkflowRun
@@ -399,7 +400,7 @@ func (w *WorkflowArgs) printStepLogs(ctx context.Context, cli client.Client, ioS
return w.printResourceLogs(ctx, cli, ioStreams, []wfTypes.Resource{{
Namespace: types.DefaultKubeVelaNS,
LabelSelector: w.ControllerLabels,
}}, []string{fmt.Sprintf(`step_name="%s"`, w.StepName), fmt.Sprintf("%s/%s", w.WorkflowInstance.Namespace, w.WorkflowInstance.Name), "cue logs"})
}}, []string{fmt.Sprintf(`stepSessionID="%s"`, w.StepID), fmt.Sprintf("%s/%s", w.WorkflowInstance.Namespace, w.WorkflowInstance.Name), "cue logs"})
case logConfig.Source != nil:
if len(logConfig.Source.Resources) > 0 {
return w.printResourceLogs(ctx, cli, ioStreams, logConfig.Source.Resources, nil)
@@ -454,7 +455,8 @@ func (w *WorkflowArgs) selectWorkflowStep(msg string) error {
if err != nil {
return fmt.Errorf("failed to select step %s: %w", unwrapStepName(w.StepName), err)
}
w.StepName = unwrapStepID(stepName, w.WorkflowInstance)
w.StepName = unwrapStepName(stepName)
w.StepID = unwrapStepID(stepName, w.WorkflowInstance)
return nil
}

View File

@@ -14,19 +14,20 @@ gateway: {
}
if context.outputs.ingress.status.loadBalancer.ingress != _|_ {
let igs = context.outputs.ingress.status.loadBalancer.ingress
let host = context.outputs.ingress.spec.rules[0].host
if igs[0].ip != _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host + ", IP: " + igs[0].ip
}
if igs[0].host == _|_ {
if host == _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster with IP: " + igs[0].ip
}
}
if igs[0].ip == _|_ {
if igs[0].host != _|_ {
if host != _|_ {
message: "Visiting URL: " + context.outputs.ingress.spec.rules[0].host
}
if igs[0].host != _|_ {
if host != _|_ {
message: "Host not specified, visit the cluster or load balancer in front of the cluster"
}
}