mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-23 14:23:54 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb9ddaabd3 | ||
|
|
f11a94612f | ||
|
|
56f9d7cb9c | ||
|
|
fbbc666019 | ||
|
|
d0788254cb | ||
|
|
c72a6aef87 | ||
|
|
195b7fe0c7 | ||
|
|
33c9e3b170 |
105
.github/workflows/registry.yml
vendored
105
.github/workflows/registry.yml
vendored
@@ -15,7 +15,7 @@ env:
|
||||
ARTIFACT_HUB_REPOSITORY_ID: ${{ secrets.ARTIFACT_HUB_REPOSITORY_ID }}
|
||||
|
||||
jobs:
|
||||
publish-images:
|
||||
publish-core-images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
@@ -55,12 +55,8 @@ jobs:
|
||||
with:
|
||||
driver-opts: image=moby/buildkit:master
|
||||
|
||||
- name: Build & Pushing vela-core for ACR
|
||||
run: |
|
||||
docker build --build-arg GOPROXY=https://proxy.golang.org --build-arg VERSION=${{ steps.get_version.outputs.VERSION }} --build-arg GITVERSION=git-${{ steps.vars.outputs.git_revision }} -t kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }} .
|
||||
docker push kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
- uses: docker/build-push-action@v2
|
||||
name: Build & Pushing vela-core for Dockerhub and GHCR
|
||||
name: Build & Pushing vela-core for Dockerhub, GHCR and ACR
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
@@ -75,36 +71,11 @@ jobs:
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
docker.io/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository }}/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-core:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- name: Build & Pushing vela-apiserver for ACR
|
||||
run: |
|
||||
docker build --build-arg GOPROXY=https://proxy.golang.org --build-arg VERSION=${{ steps.get_version.outputs.VERSION }} --build-arg GITVERSION=git-${{ steps.vars.outputs.git_revision }} -t kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }} -f Dockerfile.apiserver .
|
||||
docker push kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
- uses: docker/build-push-action@v2
|
||||
name: Build & Pushing vela-apiserver for Dockerhub and GHCR
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.apiserver
|
||||
labels: |-
|
||||
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
build-args: |
|
||||
GITVERSION=git-${{ steps.vars.outputs.git_revision }}
|
||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
docker.io/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository }}/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- name: Build & Pushing vela CLI for ACR
|
||||
run: |
|
||||
docker build --build-arg GOPROXY=https://proxy.golang.org --build-arg VERSION=${{ steps.get_version.outputs.VERSION }} --build-arg GITVERSION=git-${{ steps.vars.outputs.git_revision }} -t kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }} -f Dockerfile.cli .
|
||||
docker push kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
- uses: docker/build-push-action@v2
|
||||
name: Build & Pushing CLI for Dockerhub and GHCR
|
||||
name: Build & Pushing CLI for Dockerhub, GHCR and ACR
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.cli
|
||||
@@ -119,10 +90,70 @@ jobs:
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
docker.io/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository }}/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-cli:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
publish-addon-images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then
|
||||
VERSION=latest
|
||||
fi
|
||||
echo ::set-output name=VERSION::${VERSION}
|
||||
- name: Get git revision
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::set-output name=git_revision::$(git rev-parse --short HEAD)"
|
||||
- name: Login ghcr.io
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Login docker.io
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Login Alibaba Cloud ACR
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: kubevela-registry.cn-hangzhou.cr.aliyuncs.com
|
||||
username: ${{ secrets.ACR_USERNAME }}@aliyun-inner.com
|
||||
password: ${{ secrets.ACR_PASSWORD }}
|
||||
- uses: docker/setup-qemu-action@v1
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
driver-opts: image=moby/buildkit:master
|
||||
|
||||
- uses: docker/build-push-action@v2
|
||||
name: Build & Pushing runtime rollout for Dockerhub and GHCR
|
||||
name: Build & Pushing vela-apiserver for Dockerhub, GHCR and ACR
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.apiserver
|
||||
labels: |-
|
||||
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
build-args: |
|
||||
GITVERSION=git-${{ steps.vars.outputs.git_revision }}
|
||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
docker.io/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-apiserver:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- uses: docker/build-push-action@v2
|
||||
name: Build & Pushing runtime rollout Dockerhub, GHCR and ACR
|
||||
with:
|
||||
context: .
|
||||
file: runtime/rollout/Dockerfile
|
||||
@@ -137,7 +168,7 @@ jobs:
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
docker.io/oamdev/vela-rollout:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository }}/vela-rollout:${{ steps.get_version.outputs.VERSION }}
|
||||
ghcr.io/${{ github.repository_owner }}/oamdev/vela-rollout:${{ steps.get_version.outputs.VERSION }}
|
||||
kubevela-registry.cn-hangzhou.cr.aliyuncs.com/oamdev/vela-rollout:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
publish-charts:
|
||||
|
||||
@@ -226,7 +226,7 @@ admissionWebhooks:
|
||||
enabled: true
|
||||
image:
|
||||
repository: oamdev/kube-webhook-certgen
|
||||
tag: v2.4.0
|
||||
tag: v2.4.1
|
||||
pullPolicy: IfNotPresent
|
||||
nodeSelector: {}
|
||||
affinity: {}
|
||||
|
||||
@@ -203,7 +203,7 @@ admissionWebhooks:
|
||||
enabled: true
|
||||
image:
|
||||
repository: oamdev/kube-webhook-certgen
|
||||
tag: v2.4.0
|
||||
tag: v2.4.1
|
||||
pullPolicy: IfNotPresent
|
||||
nodeSelector: {}
|
||||
affinity: {}
|
||||
|
||||
4
go.mod
4
go.mod
@@ -16,7 +16,7 @@ require (
|
||||
github.com/barnettZQG/inject v0.0.1
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
|
||||
github.com/briandowns/spinner v1.11.1
|
||||
github.com/containerd/containerd v1.5.10
|
||||
github.com/containerd/containerd v1.5.13
|
||||
github.com/coreos/go-oidc v2.1.0+incompatible
|
||||
github.com/coreos/prometheus-operator v0.41.1
|
||||
github.com/crossplane/crossplane-runtime v0.14.1-0.20210722005935-0b469fcc77cd
|
||||
@@ -122,7 +122,7 @@ require (
|
||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
||||
github.com/Masterminds/squirrel v1.5.2 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/Microsoft/hcsshim v0.8.23 // indirect
|
||||
github.com/Microsoft/hcsshim v0.8.24 // indirect
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
|
||||
11
go.sum
11
go.sum
@@ -178,8 +178,8 @@ github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2
|
||||
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
|
||||
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
|
||||
github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
|
||||
github.com/Microsoft/hcsshim v0.8.23 h1:47MSwtKGXet80aIn+7h4YI6fwPmwIghAnsx2aOUrG2M=
|
||||
github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg=
|
||||
github.com/Microsoft/hcsshim v0.8.24 h1:jP+GMeRXIR1sH1kG4lJr9ShmSjVrua5jmFZDtfYGkn4=
|
||||
github.com/Microsoft/hcsshim v0.8.24/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg=
|
||||
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
|
||||
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
|
||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||
@@ -412,8 +412,9 @@ github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1
|
||||
github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo=
|
||||
github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102/go.mod h1:s5q4SojHctfxANBDvMeIaIovkq29IP48TKAxnhYRxvo=
|
||||
github.com/containerd/cgroups v0.0.0-20210114181951-8a68de567b68/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
|
||||
github.com/containerd/cgroups v1.0.1 h1:iJnMvco9XGvKUvNQkv88bE4uJXxRQH18efbKo9w5vHQ=
|
||||
github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU=
|
||||
github.com/containerd/cgroups v1.0.3 h1:ADZftAkglvCiD44c77s5YmMqaP2pzVCFZvBmAlBdAP4=
|
||||
github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8=
|
||||
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
|
||||
github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
|
||||
github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE=
|
||||
@@ -435,8 +436,8 @@ github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoT
|
||||
github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g=
|
||||
github.com/containerd/containerd v1.5.2/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g=
|
||||
github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c=
|
||||
github.com/containerd/containerd v1.5.10 h1:3cQ2uRVCkJVcx5VombsE7105Gl9Wrl7ORAO3+4+ogf4=
|
||||
github.com/containerd/containerd v1.5.10/go.mod h1:fvQqCfadDGga5HZyn3j4+dx56qj2I9YwBrlSdalvJYQ=
|
||||
github.com/containerd/containerd v1.5.13 h1:XqvKw9i4P7/mFrC3TSM7yV5cwFZ9avXe6M3YANKnzEE=
|
||||
github.com/containerd/containerd v1.5.13/go.mod h1:3AlCrzKROjIuP3JALsY14n8YtntaUDBu7vek+rPN5Vc=
|
||||
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
|
||||
@@ -18,7 +18,6 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/form3tech-oss/jwt-go"
|
||||
@@ -63,17 +62,17 @@ func (u *User) ShortTableName() string {
|
||||
|
||||
// PrimaryKey return custom primary key
|
||||
func (u *User) PrimaryKey() string {
|
||||
return verifyUserValue(u.Name)
|
||||
return u.Name
|
||||
}
|
||||
|
||||
// Index return custom index
|
||||
func (u *User) Index() map[string]string {
|
||||
index := make(map[string]string)
|
||||
if u.Name != "" {
|
||||
index["name"] = verifyUserValue(u.Name)
|
||||
index["name"] = u.Name
|
||||
}
|
||||
if u.Email != "" {
|
||||
index["email"] = verifyUserValue(u.Email)
|
||||
index["email"] = u.Email
|
||||
}
|
||||
return index
|
||||
}
|
||||
@@ -99,14 +98,14 @@ func (u *ProjectUser) ShortTableName() string {
|
||||
|
||||
// PrimaryKey return custom primary key
|
||||
func (u *ProjectUser) PrimaryKey() string {
|
||||
return fmt.Sprintf("%s-%s", u.ProjectName, verifyUserValue(u.Username))
|
||||
return fmt.Sprintf("%s-%s", u.ProjectName, u.Username)
|
||||
}
|
||||
|
||||
// Index return custom index
|
||||
func (u *ProjectUser) Index() map[string]string {
|
||||
index := make(map[string]string)
|
||||
if u.Username != "" {
|
||||
index["username"] = verifyUserValue(u.Username)
|
||||
index["username"] = u.Username
|
||||
}
|
||||
if u.ProjectName != "" {
|
||||
index["projectName"] = u.ProjectName
|
||||
@@ -114,12 +113,6 @@ func (u *ProjectUser) Index() map[string]string {
|
||||
return index
|
||||
}
|
||||
|
||||
func verifyUserValue(v string) string {
|
||||
s := strings.ReplaceAll(v, "@", "-")
|
||||
s = strings.ReplaceAll(s, " ", "-")
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
// CustomClaims is the custom claims
|
||||
type CustomClaims struct {
|
||||
Username string `json:"username"`
|
||||
|
||||
@@ -40,7 +40,6 @@ import (
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/domain/repository"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/infrastructure/datastore"
|
||||
v1 "github.com/oam-dev/kubevela/pkg/apiserver/interfaces/api/dto/v1"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/utils"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/utils/bcode"
|
||||
"github.com/oam-dev/kubevela/pkg/oam"
|
||||
"github.com/oam-dev/kubevela/pkg/oam/util"
|
||||
@@ -78,7 +77,7 @@ var _ = Describe("Test application service function", func() {
|
||||
projectService = &projectServiceImpl{Store: ds, K8sClient: k8sClient, RbacService: rbacService}
|
||||
envService = &envServiceImpl{Store: ds, KubeClient: k8sClient, ProjectService: projectService}
|
||||
workflowService = &workflowServiceImpl{Store: ds, EnvService: envService}
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient, caches: utils.NewMemoryCacheStore(context.Background())}
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient}
|
||||
envBindingService = &envBindingServiceImpl{Store: ds, EnvService: envService, WorkflowService: workflowService, KubeClient: k8sClient, DefinitionService: definitionService}
|
||||
targetService = &targetServiceImpl{Store: ds, K8sClient: k8sClient}
|
||||
appService = &applicationServiceImpl{
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"github.com/pkg/errors"
|
||||
@@ -55,7 +54,6 @@ type DefinitionService interface {
|
||||
|
||||
type definitionServiceImpl struct {
|
||||
KubeClient client.Client `inject:"kubeClient"`
|
||||
caches *utils.MemoryCacheStore
|
||||
}
|
||||
|
||||
// DefinitionQueryOption define a set of query options
|
||||
@@ -80,7 +78,7 @@ const (
|
||||
|
||||
// NewDefinitionService new definition service
|
||||
func NewDefinitionService() DefinitionService {
|
||||
return &definitionServiceImpl{caches: utils.NewMemoryCacheStore(context.Background())}
|
||||
return &definitionServiceImpl{}
|
||||
}
|
||||
|
||||
func (d *definitionServiceImpl) ListDefinitions(ctx context.Context, ops DefinitionQueryOption) ([]*apisv1.DefinitionBase, error) {
|
||||
@@ -95,9 +93,6 @@ func (d *definitionServiceImpl) ListDefinitions(ctx context.Context, ops Definit
|
||||
}
|
||||
|
||||
func (d *definitionServiceImpl) listDefinitions(ctx context.Context, list *unstructured.UnstructuredList, kind string, ops DefinitionQueryOption) ([]*apisv1.DefinitionBase, error) {
|
||||
if mc := d.caches.Get(ops.String()); mc != nil {
|
||||
return mc.([]*apisv1.DefinitionBase), nil
|
||||
}
|
||||
matchLabels := metav1.LabelSelector{
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
||||
{
|
||||
@@ -146,9 +141,6 @@ func (d *definitionServiceImpl) listDefinitions(ctx context.Context, list *unstr
|
||||
}
|
||||
defs = append(defs, definition)
|
||||
}
|
||||
if ops.AppliedWorkloads == "" {
|
||||
d.caches.Put(ops.String(), defs, time.Minute*3)
|
||||
}
|
||||
return defs, nil
|
||||
}
|
||||
|
||||
@@ -240,30 +232,27 @@ func (d *definitionServiceImpl) DetailDefinition(ctx context.Context, name, defT
|
||||
if err := d.KubeClient.Get(ctx, k8stypes.NamespacedName{
|
||||
Namespace: types.DefaultKubeVelaNS,
|
||||
Name: fmt.Sprintf("%s-schema-%s", defType, name),
|
||||
}, &cm); err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return nil, bcode.ErrDefinitionNoSchema
|
||||
}
|
||||
}, &cm); err != nil && !apierrors.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, ok := cm.Data[types.OpenapiV3JSONSchema]
|
||||
if !ok {
|
||||
return nil, bcode.ErrDefinitionNoSchema
|
||||
}
|
||||
schema := &openapi3.Schema{}
|
||||
if err := schema.UnmarshalJSON([]byte(data)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// render default ui schema
|
||||
defaultUISchema := renderDefaultUISchema(schema)
|
||||
// patch from custom ui schema
|
||||
customUISchema := d.renderCustomUISchema(ctx, name, defType, defaultUISchema)
|
||||
return &apisv1.DetailDefinitionResponse{
|
||||
definition := &apisv1.DetailDefinitionResponse{
|
||||
DefinitionBase: *base,
|
||||
APISchema: schema,
|
||||
UISchema: customUISchema,
|
||||
}, nil
|
||||
}
|
||||
data, ok := cm.Data[types.OpenapiV3JSONSchema]
|
||||
if ok {
|
||||
schema := &openapi3.Schema{}
|
||||
if err := schema.UnmarshalJSON([]byte(data)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
definition.APISchema = schema
|
||||
// render default ui schema
|
||||
defaultUISchema := renderDefaultUISchema(schema)
|
||||
// patch from custom ui schema
|
||||
definition.UISchema = d.renderCustomUISchema(ctx, name, defType, defaultUISchema)
|
||||
}
|
||||
|
||||
return definition, nil
|
||||
}
|
||||
|
||||
func (d *definitionServiceImpl) renderCustomUISchema(ctx context.Context, name, defType string, defaultSchema []*utils.UIParameter) []*utils.UIParameter {
|
||||
|
||||
@@ -44,7 +44,7 @@ var _ = Describe("Test namespace service functions", func() {
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient, caches: utils.NewMemoryCacheStore(context.TODO())}
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient}
|
||||
err := k8sClient.Create(context.Background(), &corev1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "vela-system",
|
||||
@@ -215,7 +215,6 @@ var _ = Describe("Test namespace service functions", func() {
|
||||
It("Test update ui schema", func() {
|
||||
du := &definitionServiceImpl{
|
||||
KubeClient: k8sClient,
|
||||
caches: utils.NewMemoryCacheStore(context.Background()),
|
||||
}
|
||||
cdata, err := ioutil.ReadFile("./testdata/workflowstep-apply-object.yaml")
|
||||
Expect(err).Should(Succeed())
|
||||
@@ -235,7 +234,6 @@ var _ = Describe("Test namespace service functions", func() {
|
||||
It("Test update status of the definition", func() {
|
||||
du := &definitionServiceImpl{
|
||||
KubeClient: k8sClient,
|
||||
caches: utils.NewMemoryCacheStore(context.Background()),
|
||||
}
|
||||
detail, err := du.UpdateDefinitionStatus(context.TODO(), "apply-object", v1.UpdateDefinitionStatusRequest{
|
||||
DefinitionType: "workflowstep",
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/domain/repository"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/infrastructure/datastore"
|
||||
apisv1 "github.com/oam-dev/kubevela/pkg/apiserver/interfaces/api/dto/v1"
|
||||
"github.com/oam-dev/kubevela/pkg/apiserver/utils"
|
||||
)
|
||||
|
||||
var _ = Describe("Test envBindingService functions", func() {
|
||||
@@ -54,7 +53,7 @@ var _ = Describe("Test envBindingService functions", func() {
|
||||
projectService := &projectServiceImpl{Store: ds, K8sClient: k8sClient, RbacService: rbacService}
|
||||
envService = &envServiceImpl{Store: ds, KubeClient: k8sClient, ProjectService: projectService}
|
||||
workflowService = &workflowServiceImpl{Store: ds, KubeClient: k8sClient, EnvService: envService}
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient, caches: utils.NewMemoryCacheStore(context.TODO())}
|
||||
definitionService = &definitionServiceImpl{KubeClient: k8sClient}
|
||||
envBindingService = &envBindingServiceImpl{Store: ds, WorkflowService: workflowService, DefinitionService: definitionService, KubeClient: k8sClient, EnvService: envService}
|
||||
envBindingDemo1 = apisv1.EnvBinding{
|
||||
Name: "envbinding-dev",
|
||||
|
||||
@@ -75,6 +75,7 @@ func generateName(entity datastore.Entity) string {
|
||||
// record the old ways here, it'll be migrated
|
||||
// name := fmt.Sprintf("veladatabase-%s-%s", entity.TableName(), entity.PrimaryKey())
|
||||
name := fmt.Sprintf("%s-%s", entity.ShortTableName(), entity.PrimaryKey())
|
||||
name = verifyValue(name)
|
||||
return strings.ReplaceAll(name, "_", "-")
|
||||
}
|
||||
|
||||
@@ -86,6 +87,9 @@ func (m *kubeapi) generateConfigMap(entity datastore.Entity) *corev1.ConfigMap {
|
||||
}
|
||||
labels["table"] = entity.TableName()
|
||||
labels["primaryKey"] = entity.PrimaryKey()
|
||||
for k, v := range labels {
|
||||
labels[k] = verifyValue(v)
|
||||
}
|
||||
var configMap = corev1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: generateName(entity),
|
||||
@@ -178,6 +182,9 @@ func (m *kubeapi) Put(ctx context.Context, entity datastore.Entity) error {
|
||||
}
|
||||
labels["table"] = entity.TableName()
|
||||
labels["primaryKey"] = entity.PrimaryKey()
|
||||
for k, v := range labels {
|
||||
labels[k] = verifyValue(v)
|
||||
}
|
||||
entity.SetUpdateTime(time.Now())
|
||||
var configMap corev1.ConfigMap
|
||||
if err := m.kubeClient.Get(ctx, types.NamespacedName{Namespace: m.namespace, Name: generateName(entity)}, &configMap); err != nil {
|
||||
@@ -345,7 +352,7 @@ func (m *kubeapi) List(ctx context.Context, entity datastore.Entity, op *datasto
|
||||
selector = selector.Add(*rq)
|
||||
|
||||
for k, v := range entity.Index() {
|
||||
rq, err := labels.NewRequirement(k, selection.Equals, []string{v})
|
||||
rq, err := labels.NewRequirement(k, selection.Equals, []string{verifyValue(v)})
|
||||
if err != nil {
|
||||
return nil, datastore.ErrIndexInvalid
|
||||
}
|
||||
@@ -353,7 +360,11 @@ func (m *kubeapi) List(ctx context.Context, entity datastore.Entity, op *datasto
|
||||
}
|
||||
if op != nil {
|
||||
for _, inFilter := range op.In {
|
||||
rq, err := labels.NewRequirement(inFilter.Key, selection.In, inFilter.Values)
|
||||
var values []string
|
||||
for _, value := range inFilter.Values {
|
||||
values = append(values, verifyValue(value))
|
||||
}
|
||||
rq, err := labels.NewRequirement(inFilter.Key, selection.In, values)
|
||||
if err != nil {
|
||||
log.Logger.Errorf("new list requirement failure %s", err.Error())
|
||||
return nil, datastore.ErrIndexInvalid
|
||||
@@ -431,7 +442,7 @@ func (m *kubeapi) Count(ctx context.Context, entity datastore.Entity, filterOpti
|
||||
return 0, datastore.NewDBError(err)
|
||||
}
|
||||
for k, v := range entity.Index() {
|
||||
rq, err := labels.NewRequirement(k, selection.Equals, []string{v})
|
||||
rq, err := labels.NewRequirement(k, selection.Equals, []string{verifyValue(v)})
|
||||
if err != nil {
|
||||
return 0, datastore.ErrIndexInvalid
|
||||
}
|
||||
@@ -439,7 +450,11 @@ func (m *kubeapi) Count(ctx context.Context, entity datastore.Entity, filterOpti
|
||||
}
|
||||
if filterOptions != nil {
|
||||
for _, inFilter := range filterOptions.In {
|
||||
rq, err := labels.NewRequirement(inFilter.Key, selection.In, inFilter.Values)
|
||||
var values []string
|
||||
for _, value := range inFilter.Values {
|
||||
values = append(values, verifyValue(value))
|
||||
}
|
||||
rq, err := labels.NewRequirement(inFilter.Key, selection.In, values)
|
||||
if err != nil {
|
||||
return 0, datastore.ErrIndexInvalid
|
||||
}
|
||||
@@ -473,3 +488,9 @@ func (m *kubeapi) Count(ctx context.Context, entity datastore.Entity, filterOpti
|
||||
}
|
||||
return int64(len(items)), nil
|
||||
}
|
||||
|
||||
func verifyValue(v string) string {
|
||||
s := strings.ReplaceAll(v, "@", "-")
|
||||
s = strings.ReplaceAll(s, " ", "-")
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
@@ -246,4 +246,42 @@ var _ = Describe("Test kubeapi datastore driver", func() {
|
||||
equal := cmp.Equal(err, datastore.ErrRecordNotExist, cmpopts.EquateErrors())
|
||||
Expect(equal).Should(BeTrue())
|
||||
})
|
||||
|
||||
It("Test verify index", func() {
|
||||
var usr = model.User{Name: "can@delete", Email: "xxx@xx.com"}
|
||||
err := kubeStore.Add(context.TODO(), &usr)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
usr.Email = "change"
|
||||
err = kubeStore.Put(context.TODO(), &usr)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
err = kubeStore.Get(context.TODO(), &usr)
|
||||
Expect(err).Should(BeNil())
|
||||
diff := cmp.Diff(usr.Email, "change")
|
||||
Expect(diff).Should(BeEmpty())
|
||||
|
||||
list, err := kubeStore.List(context.TODO(), &usr, &datastore.ListOptions{FilterOptions: datastore.FilterOptions{In: []datastore.InQueryOption{
|
||||
{
|
||||
Key: "name",
|
||||
Values: []string{"can@delete"},
|
||||
},
|
||||
}}})
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
diff = cmp.Diff(len(list), 1)
|
||||
Expect(diff).Should(BeEmpty())
|
||||
|
||||
count, err := kubeStore.Count(context.TODO(), &usr, &datastore.FilterOptions{In: []datastore.InQueryOption{
|
||||
{
|
||||
Key: "name",
|
||||
Values: []string{"can@delete"},
|
||||
},
|
||||
}})
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
Expect(count).Should(Equal(int64(1)))
|
||||
|
||||
usr.Name = "can@delete"
|
||||
err = kubeStore.Delete(context.TODO(), &usr)
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
@@ -92,7 +92,9 @@ func (clusterConfig *KubeClusterConfig) RegisterByVelaSecret(ctx context.Context
|
||||
var credentialType clusterv1alpha1.CredentialType
|
||||
data := map[string][]byte{
|
||||
"endpoint": []byte(clusterConfig.Cluster.Server),
|
||||
"ca.crt": clusterConfig.Cluster.CertificateAuthorityData,
|
||||
}
|
||||
if !clusterConfig.Cluster.InsecureSkipTLSVerify {
|
||||
data["ca.crt"] = clusterConfig.Cluster.CertificateAuthorityData
|
||||
}
|
||||
if len(clusterConfig.AuthInfo.Token) > 0 {
|
||||
credentialType = clusterv1alpha1.CredentialTypeServiceAccountToken
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v12 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -677,6 +678,10 @@ func iteratorChildResources(ctx context.Context, cluster string, k8sClient clien
|
||||
clusterCTX := multicluster.ContextWithClusterName(ctx, cluster)
|
||||
items, err := listItemByRule(clusterCTX, k8sClient, resource, *parentObject, specifiedFunc, rules.DefaultGenListOptionFunc)
|
||||
if err != nil {
|
||||
if meta.IsNoMatchError(err) || runtime.IsNotRegisteredError(err) {
|
||||
log.Logger.Errorf("error to list subresources: %s err: %v", resource.Kind, err)
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
for _, item := range items {
|
||||
|
||||
@@ -1380,6 +1380,54 @@ var _ = Describe("unit-test to e2e test", func() {
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(len(res.List)).Should(Equal(2))
|
||||
})
|
||||
|
||||
It("Test not exist api don't break whole process", func() {
|
||||
notExistRuleStr := `
|
||||
- parentResourceType:
|
||||
group: apps
|
||||
kind: Deployment
|
||||
childrenResourceType:
|
||||
- apiVersion: v2
|
||||
kind: Pod
|
||||
`
|
||||
notExistParentResourceStr := `
|
||||
- parentResourceType:
|
||||
group: badgroup
|
||||
kind: Deployment
|
||||
childrenResourceType:
|
||||
- apiVersion: v2
|
||||
kind: Pod
|
||||
`
|
||||
Expect(k8sClient.Create(ctx, &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "vela-system"}})).Should(SatisfyAny(BeNil(), util.AlreadyExistMatcher{}))
|
||||
badRuleConfigMap := v1.ConfigMap{TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "ConfigMap"},
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: types3.DefaultKubeVelaNS, Name: "bad-rule", Labels: map[string]string{oam.LabelResourceRules: "true"}},
|
||||
Data: map[string]string{relationshipKey: notExistRuleStr},
|
||||
}
|
||||
Expect(k8sClient.Create(ctx, &badRuleConfigMap)).Should(BeNil())
|
||||
|
||||
notExistParentConfigMap := v1.ConfigMap{TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "ConfigMap"},
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: types3.DefaultKubeVelaNS, Name: "not-exist-parent", Labels: map[string]string{oam.LabelResourceRules: "true"}},
|
||||
Data: map[string]string{relationshipKey: notExistParentResourceStr},
|
||||
}
|
||||
Expect(k8sClient.Create(ctx, ¬ExistParentConfigMap)).Should(BeNil())
|
||||
|
||||
prd := provider{cli: k8sClient}
|
||||
opt := `app: {
|
||||
name: "app"
|
||||
namespace: "test-namespace"
|
||||
}`
|
||||
v, err := value.NewValue(opt, nil, "")
|
||||
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(prd.GetApplicationResourceTree(nil, v, nil)).Should(BeNil())
|
||||
type Res struct {
|
||||
List []types.AppliedResource `json:"list"`
|
||||
}
|
||||
var res Res
|
||||
err = v.UnmarshalTo(&res)
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(len(res.List)).Should(Equal(2))
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("test merge globalRules", func() {
|
||||
|
||||
@@ -223,12 +223,25 @@ func getAddonRegistry(ctx context.Context, c common.Args, name string) error {
|
||||
return err
|
||||
}
|
||||
table := uitable.New()
|
||||
if registry.OSS != nil {
|
||||
switch {
|
||||
case registry.OSS != nil:
|
||||
table.AddRow("NAME", "Type", "ENDPOINT", "BUCKET", "PATH")
|
||||
table.AddRow(registry.Name, "OSS", registry.OSS.Endpoint, registry.OSS.Bucket, registry.OSS.Path)
|
||||
} else {
|
||||
case registry.Helm != nil:
|
||||
table.AddRow("NAME", "Type", "ENDPOINT")
|
||||
table.AddRow(registry.Name, "Helm", registry.Helm.URL)
|
||||
case registry.Gitee != nil:
|
||||
table.AddRow("NAME", "Type", "ENDPOINT", "PATH")
|
||||
table.AddRow(registry.Name, "git", registry.Git.URL, registry.Git.Path)
|
||||
table.AddRow(registry.Name, "Gitee", registry.Gitee.URL, registry.Gitee.Path)
|
||||
case registry.Gitlab != nil:
|
||||
table.AddRow("NAME", "Type", "ENDPOINT", "REPOSITORY", "PATH")
|
||||
table.AddRow(registry.Name, "Gitlab", registry.Gitlab.URL, registry.Gitlab.Repo, registry.Gitlab.Path)
|
||||
case registry.Git != nil:
|
||||
table.AddRow("NAME", "Type", "ENDPOINT", "PATH")
|
||||
table.AddRow(registry.Name, "Git", registry.Git.URL, registry.Git.Path)
|
||||
default:
|
||||
table.AddRow("Name")
|
||||
table.AddRow(registry.Name)
|
||||
}
|
||||
fmt.Println(table.String())
|
||||
return nil
|
||||
|
||||
@@ -226,7 +226,7 @@ func PrintInstalledCompDef(c common2.Args, io cmdutil.IOStreams, filter filterFu
|
||||
}
|
||||
|
||||
table := newUITable()
|
||||
table.AddRow("NAME", "DEFINITION")
|
||||
table.AddRow("NAME", "DEFINITION", "DESCRIPTION")
|
||||
|
||||
for _, cd := range list.Items {
|
||||
data, err := json.Marshal(cd)
|
||||
@@ -242,7 +242,7 @@ func PrintInstalledCompDef(c common2.Args, io cmdutil.IOStreams, filter filterFu
|
||||
if filter != nil && !filter(capa) {
|
||||
continue
|
||||
}
|
||||
table.AddRow(capa.Name, capa.CrdName)
|
||||
table.AddRow(capa.Name, capa.CrdName, capa.Description)
|
||||
}
|
||||
io.Info(table.String())
|
||||
return nil
|
||||
|
||||
@@ -228,6 +228,7 @@ func PrintInstalledTraitDef(c common2.Args, io cmdutil.IOStreams, filter filterF
|
||||
|
||||
table := newUITable()
|
||||
table.AddRow("NAME", "APPLIES-TO")
|
||||
table.AddRow("NAME", "APPLIES-TO", "DESCRIPTION")
|
||||
|
||||
for _, td := range list.Items {
|
||||
data, err := json.Marshal(td)
|
||||
@@ -243,7 +244,7 @@ func PrintInstalledTraitDef(c common2.Args, io cmdutil.IOStreams, filter filterF
|
||||
if filter != nil && !filter(capa) {
|
||||
continue
|
||||
}
|
||||
table.AddRow(capa.Name, capa.AppliesTo)
|
||||
table.AddRow(capa.Name, capa.AppliesTo, capa.Description)
|
||||
}
|
||||
io.Info(table.String())
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user