mirror of https://github.com/kubevela/velaux.git
Compare commits
27 Commits
Author | SHA1 | Date |
---|---|---|
|
9c8cc5d816 | |
|
0d00d92f55 | |
|
021024e4af | |
|
d9b7ae102f | |
|
8e11f93ed7 | |
|
5704854899 | |
|
73334e7516 | |
|
127f5325e9 | |
|
d5ea29f5ab | |
|
2ab672c09a | |
|
4579408f62 | |
|
d14a2b6538 | |
|
7937d098d5 | |
|
8438aa72e9 | |
|
27b45c265c | |
|
d0b2a3b995 | |
|
3978079cfd | |
|
76a39a7b99 | |
|
470699b3fb | |
|
2570713556 | |
|
0e56cec6b5 | |
|
8a81aa1e1d | |
|
28dea8a27e | |
|
118a9fee6c | |
|
580372f9d0 | |
|
ff8382cba0 | |
|
7a81518059 |
|
@ -1 +1 @@
|
|||
node_modules
|
||||
**/node_modules/
|
||||
|
|
|
@ -15,7 +15,7 @@ on:
|
|||
|
||||
env:
|
||||
# Common versions
|
||||
GO_VERSION: '1.19'
|
||||
GO_VERSION: '1.22.0'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -23,13 +23,13 @@ permissions:
|
|||
jobs:
|
||||
|
||||
detect-noop:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
noop: ${{ steps.noop.outputs.should_skip }}
|
||||
steps:
|
||||
- name: Detect No-op Changes
|
||||
id: noop
|
||||
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281
|
||||
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
|
||||
|
@ -37,23 +37,23 @@ jobs:
|
|||
continue-on-error: true
|
||||
|
||||
arm64-build-test:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: detect-noop
|
||||
if: needs.detect-noop.outputs.noop != 'true'
|
||||
|
||||
steps:
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4
|
||||
- name: Build linux/arm64 image
|
||||
id: docker_build_2
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c
|
||||
with:
|
||||
context: ./
|
||||
build-args: |
|
||||
|
|
|
@ -7,16 +7,16 @@ on:
|
|||
jobs:
|
||||
# align with crossplane's choice https://github.com/crossplane/crossplane/blob/master/.github/workflows/backport.yml
|
||||
open-pr:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
if: github.event.pull_request.merged
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Open Backport PR
|
||||
uses: zeebe-io/backport-action@v0.0.6
|
||||
uses: zeebe-io/backport-action@v0.0.9
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_workspace: ${{ github.workspace }}
|
||||
|
|
|
@ -24,18 +24,18 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
queries: +security-and-quality
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{ matrix.language }}"
|
||||
|
|
|
@ -11,9 +11,11 @@ on:
|
|||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: thehanimo/pr-title-checker@v1.3.1
|
||||
- uses: thehanimo/pr-title-checker@v1.4.2
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
pass_on_octokit_error: true
|
||||
configuration_path: ".github/pr-title-checker-config.json"
|
||||
configuration_path: '.github/pr-title-checker-config.json'
|
||||
|
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
|
||||
- name: Build Vela Core image from Dockerfile
|
||||
run: |
|
||||
|
@ -23,7 +23,7 @@ jobs:
|
|||
output: 'trivy-results.sarif'
|
||||
|
||||
- name: Upload Trivy scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v1
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
if: always()
|
||||
with:
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
|
|
|
@ -10,18 +10,18 @@ permissions:
|
|||
|
||||
jobs:
|
||||
bot:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
repository: "oam-dev/kubevela-github-actions"
|
||||
path: ./actions
|
||||
ref: v0.4.2
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
|
||||
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
|
||||
with:
|
||||
node-version: '14'
|
||||
node-version: '16'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: ./actions/package-lock.json
|
||||
- name: Install Dependencies
|
||||
|
@ -51,7 +51,7 @@ jobs:
|
|||
allow-edits: "false"
|
||||
permission-level: read
|
||||
- name: Handle Command
|
||||
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
||||
env:
|
||||
VERSION: ${{ steps.command.outputs.command-arguments }}
|
||||
with:
|
||||
|
@ -72,11 +72,11 @@ jobs:
|
|||
})
|
||||
console.log("Added '" + label + "' label.")
|
||||
- name: Checkout
|
||||
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Open Backport PR
|
||||
uses: zeebe-io/backport-action@a759fd2d7d3314c9bb57d97a0350a12e878d3c7a
|
||||
uses: zeebe-io/backport-action@v0.0.9
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_workspace: ${{ github.workspace }}
|
||||
|
@ -91,7 +91,7 @@ jobs:
|
|||
issues: write
|
||||
steps:
|
||||
- name: Retest the current pull request
|
||||
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
||||
env:
|
||||
PULL_REQUEST_ID: ${{ github.event.issue.number }}
|
||||
COMMENT_ID: ${{ github.event.comment.id }}
|
||||
|
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: |
|
||||
|
@ -25,24 +25,18 @@ jobs:
|
|||
run: |
|
||||
echo "git_revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v3.2.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to Aliyun Container Registry (ACR)
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: acr.kubevela.net
|
||||
username: "${{ secrets.ACR_USERNAME }}"
|
||||
password: "${{ secrets.ACR_PASSWORD }}"
|
||||
- uses: docker/setup-qemu-action@v1
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- uses: docker/setup-qemu-action@v3.1.0
|
||||
- uses: docker/setup-buildx-action@v3.4.0
|
||||
with:
|
||||
driver-opts: image=moby/buildkit:master
|
||||
- name: Build docker image
|
||||
id: acr_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v6.3.0
|
||||
with:
|
||||
context: ./
|
||||
file: ./Dockerfile
|
||||
|
@ -53,5 +47,4 @@ jobs:
|
|||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||
GOPROXY=https://proxy.golang.org
|
||||
tags: |-
|
||||
acr.kubevela.net/oamdev/velaux:${{ steps.get_version.outputs.VERSION }}
|
||||
oamdev/velaux:${{ steps.get_version.outputs.VERSION }}
|
||||
|
|
|
@ -15,7 +15,7 @@ on:
|
|||
|
||||
env:
|
||||
# Common versions
|
||||
GO_VERSION: '1.19'
|
||||
GO_VERSION: '1.22.0'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
@ -23,13 +23,13 @@ permissions:
|
|||
jobs:
|
||||
|
||||
detect-noop:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
noop: ${{ steps.noop.outputs.should_skip }}
|
||||
steps:
|
||||
- name: Detect No-op Changes
|
||||
id: noop
|
||||
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281
|
||||
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
|
||||
|
@ -37,24 +37,24 @@ jobs:
|
|||
continue-on-error: true
|
||||
|
||||
server-unit-tests:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: detect-noop
|
||||
if: needs.detect-noop.outputs.noop != 'true'
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568
|
||||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Cache Go Dependencies
|
||||
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .work/pkg
|
||||
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
|
||||
|
@ -66,18 +66,32 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y golang-ginkgo-dev
|
||||
|
||||
- name : Set up MySQL
|
||||
uses: mirromutth/mysql-action@v1.1
|
||||
with:
|
||||
mysql database: 'kubevela'
|
||||
mysql root password: 'kubevelaSQL123'
|
||||
|
||||
- name: Set up Postgres
|
||||
uses: Harmon758/postgresql-action@v1
|
||||
with:
|
||||
postgresql version: '11'
|
||||
postgresql db: 'kubevela'
|
||||
postgresql user: 'kubevela'
|
||||
postgresql password: 'Kubevela-123'
|
||||
|
||||
- name: Start MongoDB
|
||||
uses: supercharge/mongodb-github-action@d26215f71b2ce60420a2a3776a25893d11a65f85 # 1.9.0
|
||||
uses: supercharge/mongodb-github-action@5a87bd81f88e2a8b195f8b7b656f5cda1350815a # 1.11.0
|
||||
with:
|
||||
mongodb-version: '5.0'
|
||||
|
||||
# TODO need update action version to resolve node 12 deprecated.
|
||||
- name: install Kubebuilder
|
||||
uses: RyanSiu1995/kubebuilder-action@ff52bff1bae252239223476e5ab0d71d6ba02343
|
||||
uses: RyanSiu1995/kubebuilder-action@e7e4de1c1eaf1d089b9a186f7526239acadf0b40
|
||||
with:
|
||||
version: 3.1.0
|
||||
kubebuilderOnly: false
|
||||
kubernetesVersion: v1.21.2
|
||||
kubernetesVersion: v1.26.0
|
||||
|
||||
- name: Run api server unit test
|
||||
run: make unit-test-server
|
||||
|
@ -91,30 +105,30 @@ jobs:
|
|||
name: codecov-umbrella
|
||||
|
||||
server-e2e-tests:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [ detect-noop ]
|
||||
if: needs.detect-noop.outputs.noop != 'true'
|
||||
strategy:
|
||||
matrix:
|
||||
k8s-version: ["v1.21", "v1.26"]
|
||||
k8s-version: ["v1.26"]
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.k8s-version }}
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568
|
||||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
|
||||
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
with:
|
||||
submodules: true
|
||||
- name: Build docker image
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c
|
||||
with:
|
||||
context: ./
|
||||
build-args: |
|
||||
|
@ -179,7 +193,7 @@ jobs:
|
|||
make enable-addon
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70
|
||||
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: /tmp/e2e_apiserver_test.out
|
||||
|
|
|
@ -12,17 +12,17 @@ on:
|
|||
- release-*
|
||||
env:
|
||||
# Common versions
|
||||
GO_VERSION: '1.19'
|
||||
GO_VERSION: '1.22.0'
|
||||
|
||||
jobs:
|
||||
detect-noop:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
noop: ${{ steps.noop.outputs.should_skip }}
|
||||
steps:
|
||||
- name: Detect No-op Changes
|
||||
id: noop
|
||||
uses: fkirc/skip-duplicate-actions@v3.3.0
|
||||
uses: fkirc/skip-duplicate-actions@v5.3.1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
paths_ignore: '["**.md", "**.mdx", "**.png", "**.jpg"]'
|
||||
|
@ -30,17 +30,20 @@ jobs:
|
|||
concurrent_skipping: false
|
||||
|
||||
check:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
|
||||
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
|
||||
with:
|
||||
node-version: '16'
|
||||
cache: 'yarn'
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568
|
||||
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
id: go
|
||||
- name: Install Yarn
|
||||
run: npm install --global yarn
|
||||
- name: upgrade yarn
|
||||
run: yarn set version 3.6.0
|
||||
- run: yarn install
|
||||
|
|
4
Makefile
4
Makefile
|
@ -1,6 +1,8 @@
|
|||
include makefiles/const.mk
|
||||
include makefiles/build.mk
|
||||
|
||||
all: docker-build
|
||||
|
||||
.PHONY: golangci
|
||||
golangci:
|
||||
ifeq ($(shell $(GLOBAL_GOLANGCILINT) version --format short), $(GOLANGCILINT_VERSION))
|
||||
|
@ -25,7 +27,7 @@ ifeq (, $(shell which staticcheck))
|
|||
@{ \
|
||||
set -e ;\
|
||||
echo 'installing honnef.co/go/tools/cmd/staticcheck ' ;\
|
||||
go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 ;\
|
||||
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7 ;\
|
||||
}
|
||||
STATICCHECK=$(GOBIN)/staticcheck
|
||||
else
|
||||
|
|
|
@ -24,6 +24,8 @@ import (
|
|||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/kubevela/pkg/util/profiling"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/fatih/color"
|
||||
"github.com/go-openapi/spec"
|
||||
|
@ -33,7 +35,6 @@ import (
|
|||
"github.com/kubevela/velaux/cmd/server/app/options"
|
||||
"github.com/kubevela/velaux/pkg/server"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/utils"
|
||||
"github.com/oam-dev/kubevela/version"
|
||||
)
|
||||
|
||||
|
@ -45,7 +46,7 @@ func NewAPIServerCommand() *cobra.Command {
|
|||
Long: `The KubeVela API server validates and configures data for the API objects.
|
||||
The API Server services REST operations and provides the frontend to the
|
||||
cluster's shared state through which all other components interact.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive,unused
|
||||
if err := s.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ cluster's shared state through which all other components interact.`,
|
|||
buildSwaggerCmd := &cobra.Command{
|
||||
Use: "build-swagger",
|
||||
Short: "Build swagger documentation of KubeVela apiserver",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive,unused
|
||||
name := "docs/apidoc/latest-swagger.json"
|
||||
if len(args) > 0 {
|
||||
name = args[0]
|
||||
|
@ -111,9 +112,7 @@ func Run(s *options.ServerRunOptions) error {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
if s.GenericServerRunOptions.PprofAddr != "" {
|
||||
go utils.EnablePprof(s.GenericServerRunOptions.PprofAddr, errChan)
|
||||
}
|
||||
go profiling.StartProfilingServer(errChan)
|
||||
|
||||
go func() {
|
||||
if err := run(ctx, s, errChan); err != nil {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
|||
name: bar
|
||||
version: 1.0.0
|
||||
description: Vela test addon named bar
|
||||
icon: https://www.nar.com/icon
|
||||
url: https://www.bar.com
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
name: mock-dep-addon
|
||||
version: v1.0.0
|
||||
version: 1.0.0
|
||||
description: Vela test addon named mock-dep-addon
|
||||
icon: https://www.test.com/icon
|
||||
url: https://www.test.com
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,8 +7,8 @@ entries:
|
|||
icon: https://www.test.com
|
||||
name: mock-be-dep-addon
|
||||
urls:
|
||||
- http://127.0.0.1:9098/helm/mock-be-dep-addon-v1.0.0.tgz
|
||||
version: v1.0.0
|
||||
- http://127.0.0.1:9098/helm/mock-be-dep-addon-1.0.0.tgz
|
||||
version: 1.0.0
|
||||
foo:
|
||||
- created: "2022-10-29T09:11:16.865230605Z"
|
||||
description: Vela test addon named foo
|
||||
|
@ -16,8 +16,8 @@ entries:
|
|||
icon: https://www.foo.com
|
||||
name: foo
|
||||
urls:
|
||||
- http://127.0.0.1:9098/helm/foo-v1.0.0.tgz
|
||||
version: v1.0.0
|
||||
- http://127.0.0.1:9098/helm/foo-1.0.0.tgz
|
||||
version: 1.0.0
|
||||
bar:
|
||||
- created: "2022-10-29T09:11:16.865230605Z"
|
||||
description: Vela test addon named bar
|
||||
|
@ -25,14 +25,14 @@ entries:
|
|||
icon: https://www.bar.com
|
||||
name: foo
|
||||
urls:
|
||||
- http://127.0.0.1:9098/helm/bar-v1.0.0.tgz
|
||||
version: v1.0.0
|
||||
- http://127.0.0.1:9098/helm/bar-1.0.0.tgz
|
||||
version: 1.0.0
|
||||
- created: "2022-10-29T09:11:16.865230605Z"
|
||||
description: Vela test addon named bar
|
||||
home: https://www.bar.com/icon
|
||||
icon: https://www.bar.com
|
||||
name: foo
|
||||
urls:
|
||||
- http://127.0.0.1:9098/helm/bar-v2.0.0.tgz
|
||||
version: v2.0.0
|
||||
- http://127.0.0.1:9098/helm/bar-2.0.0.tgz
|
||||
version: 2.0.0
|
||||
generated: "2022-06-15T13:17:04.733573+08:00"
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -114,44 +114,26 @@ var helmHandler http.HandlerFunc = func(rw http.ResponseWriter, req *http.Reques
|
|||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "fluxcd-test-version-1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/fluxcd-test-version-1.0.0.tgz")
|
||||
case strings.Contains(req.URL.Path, "foo-1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/foo-1.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "fluxcd-test-version-2.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/fluxcd-test-version-2.0.0.tgz")
|
||||
case strings.Contains(req.URL.Path, "bar-1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/bar-1.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "vela-workflow-v0.3.5.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/vela-workflow-v0.3.5.tgz")
|
||||
case strings.Contains(req.URL.Path, "bar-2.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/bar-2.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "foo-v1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/foo-v1.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "bar-v1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/bar-v1.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "bar-v2.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/bar-v2.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
_, _ = rw.Write(file)
|
||||
case strings.Contains(req.URL.Path, "mock-be-dep-addon-v1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/mock-be-dep-addon-v1.0.0.tgz")
|
||||
case strings.Contains(req.URL.Path, "mock-be-dep-addon-1.0.0.tgz"):
|
||||
file, err := os.ReadFile("./e2e-test/addon/testrepo/helm-repo/mock-be-dep-addon-1.0.0.tgz")
|
||||
if err != nil {
|
||||
_, _ = rw.Write([]byte(err.Error()))
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/addon"
|
||||
|
@ -229,7 +229,7 @@ var _ = Describe("Test addon rest api", func() {
|
|||
var newaddonStatus apisv1.AddonStatusResponse
|
||||
g.Expect(decodeResponseBody(status, &newaddonStatus)).Should(Succeed())
|
||||
g.Expect(newaddonStatus.Name).Should(BeEquivalentTo("bar"))
|
||||
g.Expect(newaddonStatus.InstalledVersion).Should(BeEquivalentTo("v1.0.0"))
|
||||
g.Expect(newaddonStatus.InstalledVersion).Should(BeEquivalentTo("1.0.0"))
|
||||
}, 30*time.Second, 300*time.Millisecond).Should(Succeed())
|
||||
})
|
||||
})
|
||||
|
@ -248,7 +248,7 @@ var _ = Describe("Test addon rest api", func() {
|
|||
var newaddonStatus apisv1.AddonStatusResponse
|
||||
g.Expect(decodeResponseBody(status, &newaddonStatus)).Should(Succeed())
|
||||
g.Expect(newaddonStatus.Name).Should(BeEquivalentTo("mock-dep-addon"))
|
||||
g.Expect(newaddonStatus.InstalledVersion).Should(BeEquivalentTo("v1.0.0"))
|
||||
g.Expect(newaddonStatus.InstalledVersion).Should(BeEquivalentTo("1.0.0"))
|
||||
g.Expect(newaddonStatus.Phase).Should(BeEquivalentTo(apisv1.AddonPhaseEnabled))
|
||||
}, 30*time.Second, 300*time.Millisecond).Should(Succeed())
|
||||
})
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/kubevela/workflow/api/v1alpha1"
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/kubevela/pkg/util/rand"
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/types"
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/multicluster"
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/kubevela/workflow/api/v1alpha1"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"cuelang.org/go/pkg/strings"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
||||
|
@ -36,9 +36,7 @@ func enablePlugin(id string) {
|
|||
}
|
||||
|
||||
var _ = Describe("Test the plugin rest api", func() {
|
||||
Context("Test manage plugin API", func() {
|
||||
By("Request to /manage/plugins")
|
||||
|
||||
Context("Test manage plugin API. Request to /manage/plugins", func() {
|
||||
It("Test list installed plugins", func() {
|
||||
defer GinkgoRecover()
|
||||
res := get("/manage/plugins")
|
||||
|
@ -109,9 +107,7 @@ var _ = Describe("Test the plugin rest api", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("Test plugin API", func() {
|
||||
By("Request to /proxy/plugins")
|
||||
|
||||
Context("Test plugin API. Request to /proxy/plugins", func() {
|
||||
It("Test to request the kube API", func() {
|
||||
defer GinkgoRecover()
|
||||
By("Before enable the plugin, request the plugin API should return 400")
|
||||
|
@ -131,9 +127,7 @@ var _ = Describe("Test the plugin rest api", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("Test to request the plugin static files", func() {
|
||||
By("Request to /public/plugins")
|
||||
|
||||
Context("Test to request the plugin static files. Request to /public/plugins", func() {
|
||||
It("Test to get the module file", func() {
|
||||
defer GinkgoRecover()
|
||||
res := get(baseDomain + "/public/plugins/app-demo/module.js")
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
|
|
|
@ -19,7 +19,7 @@ package e2e_test
|
|||
import (
|
||||
"io"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
@ -147,7 +147,7 @@ var _ = BeforeSuite(func() {
|
|||
err = json.NewDecoder(resp.Body).Decode(code)
|
||||
Expect(err).Should(BeNil())
|
||||
return fmt.Errorf("rest service not ready code:%d message:%s", resp.StatusCode, code.Message)
|
||||
}, time.Second*60, time.Millisecond*200).Should(Succeed())
|
||||
}).WithTimeout(time.Second * 60).WithPolling(time.Millisecond * 200).Should(Succeed())
|
||||
var err error
|
||||
k8sClient, err = clients.GetKubeClient()
|
||||
Expect(err).ShouldNot(HaveOccurred())
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package e2e_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
|
|
|
@ -19,7 +19,7 @@ package e2e_test
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
types2 "github.com/oam-dev/kubevela/pkg/velaql/providers/query/types"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/pkg/errors"
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
|
|
200
go.mod
200
go.mod
|
@ -1,91 +1,83 @@
|
|||
module github.com/kubevela/velaux
|
||||
|
||||
go 1.19
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
cuelang.org/go v0.5.0
|
||||
github.com/AlecAivazis/survey/v2 v2.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.2.1 // indirect
|
||||
github.com/agiledragon/gomonkey/v2 v2.4.0
|
||||
github.com/alibabacloud-go/cs-20151215/v3 v3.0.32 // indirect
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.4 // indirect
|
||||
github.com/alibabacloud-go/tea v1.1.20 // indirect
|
||||
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b // indirect
|
||||
github.com/barnettZQG/inject v0.0.1
|
||||
github.com/briandowns/spinner v1.11.1 // indirect
|
||||
github.com/chartmuseum/helm-push v0.10.3 // indirect
|
||||
github.com/cloudtty/cloudtty v0.2.0
|
||||
github.com/containerd/containerd v1.6.18 // indirect
|
||||
github.com/briandowns/spinner v1.23.0 // indirect
|
||||
github.com/chartmuseum/helm-push v0.10.4 // indirect
|
||||
github.com/cloudtty/cloudtty v0.5.0
|
||||
github.com/containerd/containerd v1.7.2 // indirect
|
||||
github.com/coreos/go-oidc v2.2.1+incompatible
|
||||
github.com/crossplane/crossplane-runtime v0.19.2 // indirect
|
||||
github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/emicklei/go-restful-openapi/v2 v2.9.1
|
||||
github.com/emicklei/go-restful/v3 v3.10.2
|
||||
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
|
||||
github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691 // indirect
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/fluxcd/helm-controller/api v0.32.1 // indirect
|
||||
github.com/fluxcd/helm-controller/api v0.32.2 // indirect
|
||||
github.com/fluxcd/source-controller/api v0.24.4 // indirect
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible
|
||||
github.com/getkin/kin-openapi v0.107.0
|
||||
github.com/form3tech-oss/jwt-go v3.2.5+incompatible
|
||||
github.com/getkin/kin-openapi v0.118.0
|
||||
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
|
||||
github.com/go-git/go-git/v5 v5.6.1 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-git/go-git/v5 v5.7.0 // indirect
|
||||
github.com/go-logr/logr v1.2.4 // indirect
|
||||
github.com/go-openapi/spec v0.20.7
|
||||
github.com/go-playground/validator/v10 v10.9.0
|
||||
github.com/go-resty/resty/v2 v2.7.0 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/google/go-cmp v0.5.9
|
||||
github.com/google/go-containerregistry v0.13.0
|
||||
github.com/google/go-containerregistry v0.15.2
|
||||
github.com/google/go-github/v32 v32.1.0 // indirect
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/gosuri/uitable v0.0.4 // indirect
|
||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.16.2 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
|
||||
github.com/imdario/mergo v0.3.16 // indirect
|
||||
github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c
|
||||
github.com/kubevela/pkg v1.8.1-0.20230410075324-9f0ba3b09495
|
||||
github.com/kubevela/prism v1.7.0-alpha.1
|
||||
github.com/kubevela/workflow v0.5.1-0.20230412142923-1f15ba091699
|
||||
github.com/kubevela/pkg v1.8.1-0.20230613075152-2cef0c31b14e
|
||||
github.com/kubevela/prism v1.7.0-alpha.1.0.20230403030519-b7e45f7f842e
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
|
||||
github.com/oam-dev/cluster-gateway v1.9.0-alpha.2
|
||||
github.com/oam-dev/cluster-register v1.0.4-0.20220928064144-5f76a9d7ca8c // indirect
|
||||
github.com/oam-dev/cluster-register v1.0.4-0.20230424040021-147f7c1fefe5 // indirect
|
||||
github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 // indirect
|
||||
github.com/oam-dev/terraform-controller v0.7.10
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/gomega v1.27.5
|
||||
github.com/openkruise/kruise-api v1.3.0 // indirect
|
||||
github.com/oam-dev/terraform-controller v0.7.11
|
||||
github.com/onsi/gomega v1.27.8
|
||||
github.com/openkruise/kruise-api v1.4.0 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.14.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/client_golang v1.16.0 // indirect
|
||||
github.com/prometheus/client_model v0.4.0 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/tidwall/gjson v1.14.4
|
||||
github.com/wercker/stern v0.0.0-20190705090245-4fa46dd6987f // indirect
|
||||
github.com/wonderflow/cert-manager-api v1.0.4-0.20210304051430-e08aa76f6c5f // indirect
|
||||
github.com/xanzy/go-gitlab v0.83.0 // indirect
|
||||
github.com/xanzy/go-gitlab v0.86.0 // indirect
|
||||
github.com/xlab/treeprint v1.2.0 // indirect
|
||||
go.mongodb.org/mongo-driver v1.11.2
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.6.0
|
||||
golang.org/x/oauth2 v0.6.0
|
||||
golang.org/x/term v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
|
||||
golang.org/x/crypto v0.11.0
|
||||
golang.org/x/oauth2 v0.10.0
|
||||
golang.org/x/term v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gotest.tools v2.2.0+incompatible
|
||||
helm.sh/helm/v3 v3.11.2
|
||||
istio.io/client-go v1.13.4 // indirect
|
||||
k8s.io/api v0.26.3
|
||||
k8s.io/apiextensions-apiserver v0.26.3
|
||||
k8s.io/apimachinery v0.26.3
|
||||
|
@ -94,24 +86,52 @@ require (
|
|||
k8s.io/client-go v0.26.3
|
||||
k8s.io/component-base v0.26.3
|
||||
k8s.io/helm v2.17.0+incompatible // indirect
|
||||
k8s.io/klog/v2 v2.90.1
|
||||
k8s.io/klog/v2 v2.100.1
|
||||
k8s.io/kube-aggregator v0.26.3 // indirect
|
||||
k8s.io/kubectl v0.26.3 // indirect
|
||||
k8s.io/metrics v0.26.3 // indirect
|
||||
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
|
||||
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
|
||||
open-cluster-management.io/api v0.10.1 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.14.6
|
||||
sigs.k8s.io/gateway-api v0.4.3 // indirect
|
||||
sigs.k8s.io/kind v0.17.0 // indirect
|
||||
sigs.k8s.io/gateway-api v0.7.1 // indirect
|
||||
sigs.k8s.io/kind v0.20.0 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0
|
||||
)
|
||||
|
||||
require github.com/oam-dev/kubevela v1.9.0-alpha.1.0.20230421061936-dab1618eef7d
|
||||
|
||||
require (
|
||||
github.com/alibabacloud-go/cs-20151215/v3 v3.0.35
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.4
|
||||
github.com/alibabacloud-go/tea v1.2.0
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
|
||||
github.com/grafana/grafana v1.9.2-0.20230216173926-a0bea04a0274
|
||||
github.com/julienschmidt/httprouter v1.3.0
|
||||
github.com/kubevela/workflow v0.6.0
|
||||
github.com/oam-dev/kubevela v1.9.4
|
||||
github.com/onsi/ginkgo/v2 v2.11.0
|
||||
gorm.io/driver/postgres v1.5.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1 // indirect
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.1 // indirect
|
||||
github.com/alibabacloud-go/tea-xml v1.1.2 // indirect
|
||||
github.com/aliyun/credentials-go v1.1.2 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
||||
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.4.2 // indirect
|
||||
github.com/jellydator/ttlcache/v3 v3.0.1 // indirect
|
||||
github.com/perimeterx/marshmallow v1.1.4 // indirect
|
||||
github.com/tjfoc/gmsm v1.3.2 // indirect
|
||||
github.com/vbatts/tar-split v0.11.3 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -123,21 +143,13 @@ require (
|
|||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
|
||||
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
|
||||
github.com/Masterminds/squirrel v1.5.3 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.0 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 // indirect
|
||||
github.com/acomagu/bufpipe v1.0.4 // indirect
|
||||
github.com/agext/levenshtein v1.2.3 // indirect
|
||||
github.com/alessio/shellescape v1.4.1 // indirect
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect
|
||||
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
|
||||
github.com/alibabacloud-go/endpoint-util v1.1.1 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.4.5 // indirect
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.1 // indirect
|
||||
github.com/alibabacloud-go/tea-xml v1.1.2 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
|
||||
github.com/aliyun/credentials-go v1.1.2 // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
|
@ -145,15 +157,14 @@ require (
|
|||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chai2010/gettext-go v1.0.2 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
||||
github.com/cloudflare/circl v1.1.0 // indirect
|
||||
github.com/cloudflare/circl v1.3.3 // indirect
|
||||
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
|
||||
github.com/docker/cli v20.10.21+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/docker/docker v20.10.24+incompatible // indirect
|
||||
github.com/docker/cli v23.0.5+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.2+incompatible // indirect
|
||||
github.com/docker/docker v23.0.5+incompatible // indirect
|
||||
github.com/docker/docker-credential-helpers v0.7.0 // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-metrics v0.0.1 // indirect
|
||||
|
@ -164,7 +175,7 @@ require (
|
|||
github.com/fluxcd/pkg/apis/meta v1.0.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-errors/errors v1.0.1 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.4.1 // indirect
|
||||
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
|
@ -189,7 +200,7 @@ require (
|
|||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20191002090509-6af20e3a5340 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/huandu/xstrings v1.4.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
|
@ -198,7 +209,7 @@ require (
|
|||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/klauspost/compress v1.16.3 // indirect
|
||||
github.com/klauspost/compress v1.16.5 // indirect
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
|
@ -207,7 +218,7 @@ require (
|
|||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
|
@ -224,65 +235,60 @@ require (
|
|||
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
|
||||
github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 // indirect
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/pquerna/cachecontrol v0.1.0 // indirect
|
||||
github.com/prometheus/common v0.39.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/prometheus/common v0.42.0 // indirect
|
||||
github.com/prometheus/procfs v0.10.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.3 // indirect
|
||||
github.com/rubenv/sql-migrate v1.3.1 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/skeema/knownhosts v1.1.0 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/skeema/knownhosts v1.1.1 // indirect
|
||||
github.com/spf13/cast v1.5.0
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tjfoc/gmsm v1.3.2 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.1 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||
github.com/zclconf/go-cty v1.12.1 // indirect
|
||||
github.com/zclconf/go-cty v1.13.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 // indirect
|
||||
go.opentelemetry.io/otel v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.34.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.11.2 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.37.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.starlark.net v0.0.0-20221020143700-22309ac47eac // indirect
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
golang.org/x/mod v0.9.0 // indirect
|
||||
golang.org/x/net v0.8.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.7.0 // indirect
|
||||
golang.org/x/tools v0.11.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/grpc v1.51.0 // indirect
|
||||
google.golang.org/protobuf v1.29.1 // indirect
|
||||
google.golang.org/grpc v1.53.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // 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
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gorm.io/gorm v1.25.1
|
||||
istio.io/api v0.0.0-20220512212136-561ffec82582 // indirect
|
||||
istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e // indirect
|
||||
gorm.io/gorm v1.25.2
|
||||
k8s.io/klog v1.0.0 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
|
||||
oras.land/oras-go v1.2.2 // indirect
|
||||
|
@ -311,17 +317,17 @@ require (
|
|||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.1.0 // indirect
|
||||
github.com/openkruise/rollouts v0.1.1-0.20220622054609-149e5a48da5e // indirect
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.2 // indirect
|
||||
github.com/openkruise/rollouts v0.3.0 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/stoewer/go-strcase v1.2.0 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect
|
||||
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gorm.io/driver/mysql v1.5.1
|
||||
k8s.io/kms v0.26.3 // indirect
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
GOLANGCILINT_VERSION ?= 1.49.0
|
||||
GOLANGCILINT_VERSION ?= 1.59.1
|
||||
|
||||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||
ifeq (,$(shell go env GOBIN))
|
||||
|
@ -17,6 +17,7 @@ VELAUX_VERSION ?= main
|
|||
# Repo info
|
||||
GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
|
||||
GIT_COMMIT_LONG ?= $(shell git rev-parse HEAD)
|
||||
VELAUX_IMAGE ?= velaux:$(VELAUX_VERSION)
|
||||
VELAUX_VERSION_KEY := github.com/kubevela/velaux/version.VelaVersion
|
||||
VELAUX_GITVERSION_KEY := github.com/kubevela/velaux/version.GitRevision
|
||||
LDFLAGS ?= "-s -w -X $(VELAUX_VERSION_KEY)=$(VELAUX_VERSION) -X $(VELAUX_GITVERSION_KEY)=$(GIT_COMMIT)"
|
||||
|
|
|
@ -14,6 +14,8 @@ const HelmValueShow: React.FC<Props> = (props: Props) => {
|
|||
const [valueFile, setValueFile] = React.useState<string>('values.yaml');
|
||||
return (
|
||||
<Dialog
|
||||
style={{ width: '60vw' }}
|
||||
closeMode={["close", "mask"]}
|
||||
className={'helmValueDialog'}
|
||||
overflowScroll={true}
|
||||
visible={true}
|
||||
|
|
|
@ -192,9 +192,6 @@ class UISchema extends Component<Props, State> {
|
|||
if (condition.action == 'enable' || !condition.action) {
|
||||
enableConditionCount += 1;
|
||||
}
|
||||
if (value == undefined) {
|
||||
return;
|
||||
}
|
||||
switch (condition.op) {
|
||||
case 'in':
|
||||
if (Array.isArray(condition.value) && condition.value.includes(value)) {
|
||||
|
@ -976,7 +973,7 @@ class UISchema extends Component<Props, State> {
|
|||
};
|
||||
|
||||
const showAdvancedButton = couldBeDisabledParamCount != couldShowParamCount || requiredParamCount === 0;
|
||||
return (
|
||||
return (
|
||||
<Form field={this.form} className="ui-schema-container">
|
||||
<If condition={disableRenderRow}>{items}</If>
|
||||
<If condition={!disableRenderRow}>
|
||||
|
|
|
@ -57,7 +57,7 @@ class Group extends React.Component<Props, State> {
|
|||
|
||||
initSwitchState = () => {
|
||||
const { jsonKey = '', propertyValue = {}, alwaysShow = false, required, closed, initClose } = this.props;
|
||||
const findKey = Object.keys(propertyValue).find((item) => item === jsonKey);
|
||||
const findKey = propertyValue && Object.keys(propertyValue).find((item) => item === jsonKey);
|
||||
if (findKey || alwaysShow) {
|
||||
this.setState({ enable: true, closed: false || initClose, checked: true });
|
||||
} else if (required) {
|
||||
|
|
|
@ -109,7 +109,7 @@ class EditPlatFormUserDialog extends Component<Props, State> {
|
|||
{
|
||||
required: true,
|
||||
pattern: checkName,
|
||||
message: <Translation>You must input a valid name</Translation>,
|
||||
message: <Translation>You must input a valid name with alphanumeric character only</Translation>,
|
||||
},
|
||||
],
|
||||
})}
|
||||
|
@ -139,7 +139,7 @@ class EditPlatFormUserDialog extends Component<Props, State> {
|
|||
pattern: checkUserPassword,
|
||||
message: (
|
||||
<Translation>
|
||||
Password should be 8-16 bits and contain at least one number and one letter
|
||||
Password must be alphanumeric, contain at least one letter and one number, and be 8-16 characters long
|
||||
</Translation>
|
||||
),
|
||||
},
|
||||
|
|
|
@ -329,6 +329,7 @@
|
|||
"Only support github repo url(master branch)": "仅支持 GitHub repo(主分支) 链接",
|
||||
"Are you sure to delete?": "确认要删除吗?",
|
||||
"Please enter a valid name": "请输入一个有效的名称",
|
||||
"Please enter a valid name having alphanumeric characters only": "请输入仅包含字母数字字符的有效名称",
|
||||
"This addon is experimental, please don't use it in production": "本插件是试用性,请不要在生产环境中使用",
|
||||
"Dependencies": "依赖",
|
||||
"Enable the addon to obtain the following extension capabilities": "启用插件以使用如下扩展能力",
|
||||
|
@ -534,6 +535,7 @@
|
|||
"Environment binding deleted successfully": "成功移除环境绑定",
|
||||
"Retry": "重试",
|
||||
"Password should be 8-16 bits and contain at least one number and one letter": "密码应为8-16位, 并至少包含一个数字和一个字母",
|
||||
"Password must be alphanumeric, contain at least one letter and one number, and be 8-16 characters long": "密码必须是字母数字,至少包含一个字母和一个数字,长度为 8-16 个字符",
|
||||
"Please input a valid email": "请输入有效的电子邮件地址",
|
||||
"Please input a email": "请输入电子邮箱地址",
|
||||
"User updated successfully": "用户更新成功",
|
||||
|
@ -652,4 +654,4 @@
|
|||
"Click me to open the dex login page": "点击我打开 Dex 登录页面",
|
||||
"Setting the default projects for the dex login user": "设置 Dex 登录用户的默认项目",
|
||||
"Join Time": "加入时间"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -517,7 +517,7 @@ class AddonDetailDialog extends React.Component<Props, State> {
|
|||
schema
|
||||
? [
|
||||
<Button
|
||||
style={{ marginTop: '-12px', alignItems: 'center', display: 'flex' }}
|
||||
style={{ alignItems: 'center', display: 'flex' }}
|
||||
onClick={() => {
|
||||
if (propertiesMode === 'native') {
|
||||
this.setState({ propertiesMode: 'code' });
|
||||
|
|
|
@ -195,14 +195,28 @@ class TraitDialog extends React.Component<Props, State> {
|
|||
.then((re) => {
|
||||
if (re) {
|
||||
this.setState({ definitionDetail: re, definitionLoading: false });
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
this.setDefaultProperties(re)
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => this.setState({ definitionLoading: false }));
|
||||
};
|
||||
|
||||
setDefaultProperties = (definitionDetail: any) => {
|
||||
const properties = definitionDetail.schema?.properties;
|
||||
if (properties) {
|
||||
const defaultValues: Record<string, any> = {};
|
||||
for (const key in properties) {
|
||||
if (properties[key].default !== undefined) {
|
||||
defaultValues[key] = properties[key].default;
|
||||
}
|
||||
}
|
||||
this.field.setValues({ properties: defaultValues });
|
||||
}
|
||||
};
|
||||
|
||||
handleTypeChange = (value: string) => {
|
||||
this.removeProperties();
|
||||
this.field.setValues({ type: value });
|
||||
|
|
|
@ -55,7 +55,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
onClose = () => {
|
||||
this.props.onClose();
|
||||
this.resetField();
|
||||
|
@ -69,13 +69,13 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
}
|
||||
if (editMode) {
|
||||
updateCluster({
|
||||
name: cluster.name,
|
||||
name: cluster?.name,
|
||||
alias: values.alias,
|
||||
icon: cluster.icon,
|
||||
icon: cluster?.icon,
|
||||
description: values.description,
|
||||
dashboardURL: values.dashboardURL,
|
||||
kubeConfig: values.kubeConfig,
|
||||
labels: cluster.labels,
|
||||
labels: cluster?.labels,
|
||||
}).then((re: any) => {
|
||||
if (re) {
|
||||
Message.success(<Translation>cluster update success</Translation>);
|
||||
|
@ -140,7 +140,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
};
|
||||
const init = this.field.init;
|
||||
const values: { kubeConfig: string } = this.field.getValues();
|
||||
const valueInfo = cluster.kubeConfig || values.kubeConfig || '';
|
||||
const valueInfo = cluster?.kubeConfig || values.kubeConfig || '';
|
||||
return (
|
||||
<Dialog
|
||||
locale={locale().Dialog}
|
||||
|
@ -170,7 +170,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
name="name"
|
||||
disabled={editMode}
|
||||
{...init('name', {
|
||||
initValue: cluster.name,
|
||||
initValue: cluster?.name || editClusterName,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
|
@ -187,7 +187,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
<Input
|
||||
name="alias"
|
||||
{...init('alias', {
|
||||
initValue: cluster.alias,
|
||||
initValue: cluster?.alias,
|
||||
rules: [
|
||||
{
|
||||
minLength: 2,
|
||||
|
@ -204,10 +204,10 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
<Col span={12} style={{ padding: '0 8px' }}>
|
||||
<FormItem label={<Translation>Description</Translation>}>
|
||||
<Input
|
||||
defaultValue={cluster.description}
|
||||
defaultValue={cluster?.description}
|
||||
name="description"
|
||||
{...init('description', {
|
||||
initValue: cluster.description,
|
||||
initValue: cluster?.description,
|
||||
rules: [
|
||||
{
|
||||
maxLength: 256,
|
||||
|
@ -223,7 +223,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
<Input
|
||||
name="dashboardURL"
|
||||
{...init('dashboardURL', {
|
||||
initValue: cluster.dashboardURL,
|
||||
initValue: cluster?.dashboardURL,
|
||||
rules: [
|
||||
{
|
||||
required: false,
|
||||
|
@ -252,7 +252,7 @@ class AddClusterDialog extends React.Component<Props, State> {
|
|||
language={'yaml'}
|
||||
readOnly={false}
|
||||
{...init('kubeConfig', {
|
||||
initValue: cluster.kubeConfig,
|
||||
initValue: cluster?.kubeConfig,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
|
|
|
@ -101,7 +101,7 @@ class Cluster extends React.Component<Props, State> {
|
|||
(enableAddon || []).forEach((ele: { name: string; phase: boolean }) => {
|
||||
addonList.forEach((item: Addon) => {
|
||||
const isMatchName = ele.name === item.name;
|
||||
const deploy = item.deployTo || { runtimeCluster: false, runtime_cluster: false };
|
||||
const deploy = item.deployTo || { runtimeCluster: false };
|
||||
if (isMatchName && deploy.runtimeCluster) {
|
||||
addonMessage.push({ name: item.name, path: item.url || '' });
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ class CreateUser extends React.Component<Props, State> {
|
|||
{
|
||||
required: true,
|
||||
pattern: checkName,
|
||||
message: <Translation>Please enter a valid name</Translation>,
|
||||
message: <Translation>Please enter a valid name having alphanumeric characters only</Translation>,
|
||||
},
|
||||
],
|
||||
})}
|
||||
|
@ -209,7 +209,7 @@ class CreateUser extends React.Component<Props, State> {
|
|||
pattern: checkUserPassword,
|
||||
message: (
|
||||
<Translation>
|
||||
Password should be 8-16 bits and contain at least one number and one letter
|
||||
Password must be alphanumeric, contain at least one letter and one number, and be 8-16 characters long
|
||||
</Translation>
|
||||
),
|
||||
},
|
||||
|
|
|
@ -117,7 +117,7 @@ class ResetPassword extends React.Component<Props, State> {
|
|||
pattern: checkUserPassword,
|
||||
message: (
|
||||
<Translation>
|
||||
Password should be 8-16 bits and contain at least one number and one letter
|
||||
Password must be alphanumeric, contain at least one letter and one number, and be 8-16 characters long
|
||||
</Translation>
|
||||
),
|
||||
},
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
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 cloudprovider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
cs20151215 "github.com/alibabacloud-go/cs-20151215/v3/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
types "github.com/oam-dev/terraform-controller/api/types/crossplane-runtime"
|
||||
v1beta12 "github.com/oam-dev/terraform-controller/api/v1beta2"
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/pointer"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/utils/util"
|
||||
)
|
||||
|
||||
const (
|
||||
aliyunAPIEndpoint = "cs.cn-hangzhou.aliyuncs.com"
|
||||
)
|
||||
|
||||
// AliyunCloudProvider describes the cloud provider in aliyun
|
||||
type AliyunCloudProvider struct {
|
||||
*cs20151215.Client
|
||||
k8sClient client.Client
|
||||
accessKeyID string
|
||||
accessKeySecret string
|
||||
}
|
||||
|
||||
// NewAliyunCloudProvider create aliyun cloud provider
|
||||
func NewAliyunCloudProvider(accessKeyID string, accessKeySecret string, k8sClient client.Client) (*AliyunCloudProvider, error) {
|
||||
config := &openapi.Config{
|
||||
AccessKeyId: pointer.String(accessKeyID),
|
||||
AccessKeySecret: pointer.String(accessKeySecret),
|
||||
}
|
||||
config.Endpoint = tea.String(aliyunAPIEndpoint)
|
||||
c, err := cs20151215.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AliyunCloudProvider{Client: c, k8sClient: k8sClient, accessKeyID: accessKeyID, accessKeySecret: accessKeySecret}, nil
|
||||
}
|
||||
|
||||
// IsInvalidKey check if error is InvalidAccessKey or InvalidSecretKey
|
||||
func (provider *AliyunCloudProvider) IsInvalidKey(err error) bool {
|
||||
return strings.Contains(err.Error(), "InvalidAccessKeyId") || strings.Contains(err.Error(), "Code: SignatureDoesNotMatch")
|
||||
}
|
||||
|
||||
func (provider *AliyunCloudProvider) decodeClusterLabels(tags []*cs20151215.Tag) map[string]string {
|
||||
labels := map[string]string{}
|
||||
for _, tag := range tags {
|
||||
if tag != nil {
|
||||
labels[getString(tag.Key)] = getString(tag.Value)
|
||||
}
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
func (provider *AliyunCloudProvider) decodeClusterURL(masterURL string) (url struct {
|
||||
APIServerEndpoint string `json:"api_server_endpoint"`
|
||||
IntranetAPIServerEndpoint string `json:"intranet_api_server_endpoint"`
|
||||
}) {
|
||||
if err := json.Unmarshal([]byte(masterURL), &url); err != nil {
|
||||
klog.Info("failed to unmarshal masterUrl %s", masterURL)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (provider *AliyunCloudProvider) getDashboardURL(clusterID string) string {
|
||||
return fmt.Sprintf("https://cs.console.aliyun.com/#/k8s/cluster/%s/v2/info/overview", clusterID)
|
||||
}
|
||||
|
||||
func getString(s *string) string {
|
||||
if s == nil {
|
||||
return ""
|
||||
}
|
||||
return *s
|
||||
}
|
||||
|
||||
// ListCloudClusters list clusters with page info, return clusters, total count and error
|
||||
func (provider *AliyunCloudProvider) ListCloudClusters(pageNumber int, pageSize int) ([]*CloudCluster, int, error) {
|
||||
describeClustersV1Request := &cs20151215.DescribeClustersV1Request{
|
||||
PageSize: pointer.Int64(int64(pageSize)),
|
||||
PageNumber: pointer.Int64(int64(pageNumber)),
|
||||
}
|
||||
resp, err := provider.DescribeClustersV1(describeClustersV1Request)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
var clusters []*CloudCluster
|
||||
for _, cluster := range resp.Body.Clusters {
|
||||
if cluster == nil {
|
||||
continue
|
||||
}
|
||||
labels := provider.decodeClusterLabels(cluster.Tags)
|
||||
url := provider.decodeClusterURL(getString(cluster.MasterUrl))
|
||||
clusters = append(clusters, &CloudCluster{
|
||||
ID: getString(cluster.ClusterId),
|
||||
Name: getString(cluster.Name),
|
||||
Type: getString(cluster.ClusterType),
|
||||
Zone: getString(cluster.ZoneId),
|
||||
ZoneID: getString(cluster.ZoneId),
|
||||
RegionID: getString(cluster.RegionId),
|
||||
VpcID: getString(cluster.VpcId),
|
||||
Labels: labels,
|
||||
Status: getString(cluster.State),
|
||||
APIServerURL: url.APIServerEndpoint,
|
||||
DashBoardURL: provider.getDashboardURL(getString(cluster.ClusterId)),
|
||||
})
|
||||
}
|
||||
return clusters, int(*resp.Body.PageInfo.TotalCount), nil
|
||||
}
|
||||
|
||||
// GetClusterKubeConfig get cluster kubeconfig by clusterID
|
||||
func (provider *AliyunCloudProvider) GetClusterKubeConfig(clusterID string) (string, error) {
|
||||
req := &cs20151215.DescribeClusterUserKubeconfigRequest{}
|
||||
resp, err := provider.DescribeClusterUserKubeconfig(pointer.String(clusterID), req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return *resp.Body.Config, nil
|
||||
}
|
||||
|
||||
// GetClusterInfo retrieves cluster info by clusterID
|
||||
func (provider *AliyunCloudProvider) GetClusterInfo(clusterID string) (*CloudCluster, error) {
|
||||
resp, err := provider.DescribeClusterDetail(pointer.String(clusterID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cluster := resp.Body
|
||||
labels := provider.decodeClusterLabels(cluster.Tags)
|
||||
url := provider.decodeClusterURL(*cluster.MasterUrl)
|
||||
return &CloudCluster{
|
||||
Provider: ProviderAliyun,
|
||||
ID: *cluster.ClusterId,
|
||||
Name: *cluster.Name,
|
||||
Type: *cluster.ClusterType,
|
||||
Zone: *cluster.ZoneId,
|
||||
ZoneID: *cluster.ZoneId,
|
||||
RegionID: *cluster.RegionId,
|
||||
VpcID: *cluster.VpcId,
|
||||
Labels: labels,
|
||||
Status: *cluster.State,
|
||||
APIServerURL: url.APIServerEndpoint,
|
||||
DashBoardURL: provider.getDashboardURL(*cluster.ClusterId),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateCloudCluster create cloud cluster
|
||||
func (provider *AliyunCloudProvider) CreateCloudCluster(ctx context.Context, clusterName string, zone string, worker int, cpu int64, mem int64) (string, error) {
|
||||
name := GetCloudClusterFullName(ProviderAliyun, clusterName)
|
||||
ns := util.GetRuntimeNamespace()
|
||||
terraformProviderName, err := bootstrapTerraformProvider(ctx, provider.k8sClient, ns, ProviderAliyun, "alibaba", provider.accessKeyID, provider.accessKeySecret, "cn-hongkong")
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to bootstrap terraform provider")
|
||||
}
|
||||
properties := map[string]interface{}{
|
||||
"k8s_name_prefix": clusterName,
|
||||
}
|
||||
if zone != "" {
|
||||
properties["zone_id"] = zone
|
||||
}
|
||||
if cpu != 0 {
|
||||
properties["cpu_core_count"] = cpu
|
||||
}
|
||||
if mem != 0 {
|
||||
properties["memory_size"] = mem
|
||||
}
|
||||
if worker != 0 {
|
||||
properties["k8s_worker_number"] = worker
|
||||
}
|
||||
bs, err := json.Marshal(properties)
|
||||
if err != nil {
|
||||
return name, errors.Wrapf(err, "failed to marshal cloud cluster app properties")
|
||||
}
|
||||
|
||||
cfg := v1beta12.Configuration{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: ns,
|
||||
Labels: map[string]string{
|
||||
CloudClusterCreatorLabelKey: ProviderAliyun,
|
||||
},
|
||||
},
|
||||
Spec: v1beta12.ConfigurationSpec{
|
||||
ProviderReference: &types.Reference{
|
||||
Name: terraformProviderName,
|
||||
Namespace: ns,
|
||||
},
|
||||
Remote: "https://github.com/kubevela-contrib/terraform-modules.git",
|
||||
Variable: &runtime.RawExtension{Raw: bs},
|
||||
},
|
||||
}
|
||||
cfg.Spec.Path = "alibaba/cs/dedicated-kubernetes"
|
||||
cfg.Spec.WriteConnectionSecretToReference = &types.SecretReference{
|
||||
Name: name,
|
||||
Namespace: ns,
|
||||
}
|
||||
|
||||
if err = provider.k8sClient.Create(ctx, &cfg); err != nil {
|
||||
return name, errors.Wrapf(err, "failed to create cloud cluster terraform configuration")
|
||||
}
|
||||
|
||||
return name, nil
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
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 cloudprovider
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
const (
|
||||
// CloudClusterCreatorLabelKey labels the creator of cloud cluster
|
||||
CloudClusterCreatorLabelKey = "api.core.oam.dev/cloud-cluster-creator"
|
||||
)
|
||||
|
||||
// CloudClusterProvider abstracts the cloud provider to provide cluster access
|
||||
type CloudClusterProvider interface {
|
||||
IsInvalidKey(err error) bool
|
||||
ListCloudClusters(pageNumber int, pageSize int) ([]*CloudCluster, int, error)
|
||||
GetClusterKubeConfig(clusterID string) (string, error)
|
||||
GetClusterInfo(clusterID string) (*CloudCluster, error)
|
||||
CreateCloudCluster(ctx context.Context, clusterName string, zone string, worker int, cpu int64, mem int64) (string, error)
|
||||
}
|
||||
|
||||
// GetClusterProvider creates interface for getting cloud cluster provider
|
||||
func GetClusterProvider(provider string, accessKeyID string, accessKeySecret string, k8sClient client.Client) (CloudClusterProvider, error) {
|
||||
switch provider {
|
||||
case ProviderAliyun:
|
||||
return NewAliyunCloudProvider(accessKeyID, accessKeySecret, k8sClient)
|
||||
default:
|
||||
return nil, errors.Errorf("cluster provider %s is not implemented", provider)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
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 cloudprovider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
types "github.com/oam-dev/terraform-controller/api/types/crossplane-runtime"
|
||||
v1beta12 "github.com/oam-dev/terraform-controller/api/v1beta1"
|
||||
"github.com/pkg/errors"
|
||||
v12 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
func computeProviderHashKey(provider string, accessKeyID string, accessKeySecret string) string {
|
||||
return fmt.Sprintf("%x", sha256.Sum256([]byte(strings.Join([]string{provider, accessKeyID, accessKeySecret}, "::"))))[:8] // #nosec
|
||||
}
|
||||
|
||||
// GetCloudClusterFullName construct the full name of cloud cluster which will be used as the name of terraform configuration
|
||||
func GetCloudClusterFullName(provider string, clusterName string) string {
|
||||
return fmt.Sprintf("cloud-cluster-%s-%s", provider, clusterName)
|
||||
}
|
||||
|
||||
func bootstrapTerraformProvider(ctx context.Context, k8sClient client.Client, ns string, provider string, tfProvider string, accessKeyID string, accessKeySecret string, region string) (string, error) {
|
||||
hashKey := computeProviderHashKey(provider, accessKeyID, accessKeySecret)
|
||||
secretName := fmt.Sprintf("tf-provider-cred-%s-%s", provider, hashKey)
|
||||
terraformProviderName := fmt.Sprintf("tf-provider-%s-%s", provider, hashKey)
|
||||
secret := v12.Secret{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: secretName,
|
||||
Namespace: ns,
|
||||
},
|
||||
StringData: map[string]string{"credentials": fmt.Sprintf("accessKeyID: %s\naccessKeySecret: %s\nsecurityToken:\n", accessKeyID, accessKeySecret)},
|
||||
Type: v12.SecretTypeOpaque,
|
||||
}
|
||||
var err error
|
||||
if err = k8sClient.Get(ctx, client.ObjectKeyFromObject(&secret), &v12.Secret{}); err != nil {
|
||||
if kerrors.IsNotFound(err) {
|
||||
err = k8sClient.Create(ctx, &secret)
|
||||
}
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to upsert terraform provider secret")
|
||||
}
|
||||
}
|
||||
|
||||
terraformProvider := v1beta12.Provider{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: terraformProviderName,
|
||||
Namespace: ns,
|
||||
},
|
||||
Spec: v1beta12.ProviderSpec{
|
||||
Credentials: v1beta12.ProviderCredentials{
|
||||
SecretRef: &types.SecretKeySelector{
|
||||
Key: "credentials",
|
||||
SecretReference: types.SecretReference{
|
||||
Name: secretName,
|
||||
Namespace: ns,
|
||||
},
|
||||
},
|
||||
Source: types.CredentialsSourceSecret,
|
||||
},
|
||||
Provider: tfProvider,
|
||||
Region: region,
|
||||
},
|
||||
}
|
||||
if err = k8sClient.Get(ctx, client.ObjectKeyFromObject(&terraformProvider), &v1beta12.Provider{}); err != nil {
|
||||
if kerrors.IsNotFound(err) {
|
||||
err = k8sClient.Create(ctx, &terraformProvider)
|
||||
}
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to upsert terraform provider")
|
||||
}
|
||||
}
|
||||
return terraformProviderName, nil
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
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 cloudprovider
|
||||
|
||||
const (
|
||||
// ProviderAliyun cloud provider aliyun
|
||||
ProviderAliyun = "aliyun"
|
||||
)
|
||||
|
||||
// CloudCluster describes the interface that cloud provider should return
|
||||
type CloudCluster struct {
|
||||
Provider string `json:"provider"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Zone string `json:"zone"`
|
||||
ZoneID string `json:"zoneID"`
|
||||
RegionID string `json:"regionID"`
|
||||
VpcID string `json:"vpcID"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Status string `json:"status"`
|
||||
APIServerURL string `json:"apiServerURL"`
|
||||
DashBoardURL string `json:"dashboardURL"`
|
||||
}
|
|
@ -22,7 +22,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -46,7 +46,7 @@ var k8sClient client.Client
|
|||
var testEnv *envtest.Environment
|
||||
var testScheme = runtime.NewScheme()
|
||||
|
||||
var _ = BeforeSuite(func(done Done) {
|
||||
var _ = BeforeSuite(func(ctx SpecContext) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
By("bootstrapping test environment")
|
||||
|
||||
|
@ -74,8 +74,7 @@ var _ = BeforeSuite(func(done Done) {
|
|||
|
||||
Expect(k8sClient.Create(context.TODO(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: kubevelatypes.DefaultKubeVelaNS}})).Should(BeNil())
|
||||
|
||||
close(done)
|
||||
}, 240)
|
||||
}, NodeTimeout(time.Minute))
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
By("tearing down the test environment")
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
kubevelatypes "github.com/oam-dev/kubevela/apis/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/rbac/v1"
|
||||
|
|
|
@ -26,6 +26,6 @@ type staticServerProxy struct {
|
|||
plugin *types.Plugin
|
||||
}
|
||||
|
||||
func (k *staticServerProxy) Handler(req *http.Request, res http.ResponseWriter) {
|
||||
func (k *staticServerProxy) Handler(_ *http.Request, _ http.ResponseWriter) {
|
||||
// TODO:
|
||||
}
|
||||
|
|
|
@ -48,11 +48,18 @@ func newDefaultRouter(h Handle, plugin *types.Plugin) *defaultRouter {
|
|||
return &defaultRouter{h: h, plugin: plugin}
|
||||
}
|
||||
|
||||
// GenerateHTTPRouter create and return the plugin backend router
|
||||
func GenerateHTTPRouter(plugin *types.Plugin, pathPrefix string, h Handle) http.Handler {
|
||||
// GetPluginHandler get the plugin backend router, if not exist, will create and cache it
|
||||
func GetPluginHandler(plugin *types.Plugin, h Handle) http.Handler {
|
||||
if r, e := cachePluginRouter[plugin.PluginID()]; e {
|
||||
return r
|
||||
}
|
||||
router := GeneratePluginHandler(plugin, h)
|
||||
cachePluginRouter[plugin.PluginID()] = router
|
||||
return router
|
||||
}
|
||||
|
||||
// GeneratePluginHandler create and return the plugin backend router
|
||||
func GeneratePluginHandler(plugin *types.Plugin, h Handle) http.Handler {
|
||||
var router http.Handler
|
||||
if len(plugin.Routes) == 0 {
|
||||
klog.Warningf("plugin %s don't define the routes, will proxy all path requests and not check the permission.", plugin.PluginID())
|
||||
|
@ -60,7 +67,7 @@ func GenerateHTTPRouter(plugin *types.Plugin, pathPrefix string, h Handle) http.
|
|||
} else {
|
||||
r := httprouter.New()
|
||||
for _, route := range plugin.Routes {
|
||||
routePath := path.Join(pathPrefix+"/:"+DefaultPluginResourceKey, route.Path)
|
||||
routePath := path.Join(types.PluginProxyRoutePath+"/:"+DefaultPluginResourceKey, route.Path)
|
||||
method := route.Method
|
||||
if method == "" {
|
||||
method = "GET"
|
||||
|
@ -72,6 +79,5 @@ func GenerateHTTPRouter(plugin *types.Plugin, pathPrefix string, h Handle) http.
|
|||
}
|
||||
router = r
|
||||
}
|
||||
cachePluginRouter[plugin.PluginID()] = router
|
||||
return router
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ import (
|
|||
func TestDefaultGenerateHTTPRouter(t *testing.T) {
|
||||
var res = &httptest.ResponseRecorder{}
|
||||
var req = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/default-router/test", Host: "127.0.0.1"}}
|
||||
defaultRouter := GenerateHTTPRouter(&types.Plugin{
|
||||
defaultRouter := GetPluginHandler(&types.Plugin{
|
||||
JSONData: types.JSONData{
|
||||
ID: "default-router",
|
||||
},
|
||||
}, "/proxy/plugins", func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
|
||||
}, func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
|
||||
if r1.URL.Path == "/proxy/plugins/default-router/test" {
|
||||
w.WriteHeader(403)
|
||||
return
|
||||
|
@ -50,7 +50,7 @@ func TestRouteGenerateHTTPRouter(t *testing.T) {
|
|||
var req = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes/t", Host: "127.0.0.1"}}
|
||||
var reqMethodNotAllow = &http.Request{Method: "PUT", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes/t", Host: "127.0.0.1"}}
|
||||
var req404 = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes", Host: "127.0.0.1"}}
|
||||
router := GenerateHTTPRouter(&types.Plugin{
|
||||
router := GetPluginHandler(&types.Plugin{
|
||||
JSONData: types.JSONData{
|
||||
ID: "route-router",
|
||||
Routes: []*types.Route{
|
||||
|
@ -64,7 +64,7 @@ func TestRouteGenerateHTTPRouter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
}, "/proxy/plugins", func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
|
||||
}, func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
|
||||
assert.Equal(t, p1.ByName("node"), "t")
|
||||
assert.Equal(t, len(r2.ProxyHeaders), 1)
|
||||
assert.Equal(t, r2.ProxyHeaders[0].Name, "Authorization")
|
||||
|
|
|
@ -20,6 +20,9 @@ import (
|
|||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
)
|
||||
|
||||
// PluginProxyRoutePath the route prefix to request the plugin backend server.
|
||||
const PluginProxyRoutePath = "/proxy/plugins/"
|
||||
|
||||
// Plugin VelaUX plugin model
|
||||
type Plugin struct {
|
||||
JSONData
|
||||
|
@ -145,7 +148,7 @@ type KubernetesService struct {
|
|||
// If namespace is not specified, find the service from the vela system namespace
|
||||
Namespace string `json:"namespace"`
|
||||
// If port is not specified, find the first port from the service
|
||||
Port int32
|
||||
Port int32 `json:"port"`
|
||||
}
|
||||
|
||||
// KubernetesSecret define one kubernetes secret
|
||||
|
|
|
@ -20,9 +20,9 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/kubevela/pkg/util/profiling"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/infrastructure/datastore"
|
||||
)
|
||||
|
@ -52,15 +52,15 @@ type Config struct {
|
|||
// KubeQPS the QPS of kube client
|
||||
KubeQPS float64
|
||||
|
||||
// PprofAddr the address for pprof to use while exporting profiling results.
|
||||
PprofAddr string
|
||||
|
||||
// WorkflowVersion is the version of workflow
|
||||
WorkflowVersion string
|
||||
|
||||
PluginConfig PluginConfig
|
||||
|
||||
DexServerURL string
|
||||
|
||||
// ExitOnLostLeader will exit the process if this server lost the leader election, set this to true for debugging
|
||||
ExitOnLostLeader bool
|
||||
}
|
||||
|
||||
// PluginConfig the plugin directory config
|
||||
|
@ -92,14 +92,14 @@ func NewConfig() *Config {
|
|||
},
|
||||
AddonCacheTime: time.Minute * 10,
|
||||
DisableStatisticCronJob: false,
|
||||
PprofAddr: "",
|
||||
KubeQPS: 100,
|
||||
KubeBurst: 300,
|
||||
PluginConfig: PluginConfig{
|
||||
CorePluginPath: "core-plugins",
|
||||
CustomPluginPath: []string{"plugins"},
|
||||
},
|
||||
DexServerURL: "http://dex.vela-system:5556",
|
||||
DexServerURL: "http://dex.vela-system:5556",
|
||||
ExitOnLostLeader: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ func NewConfig() *Config {
|
|||
func (s *Config) Validate() []error {
|
||||
var errs []error
|
||||
|
||||
if s.Datastore.Type != "mongodb" && s.Datastore.Type != "kubeapi" {
|
||||
if s.Datastore.Type != "mongodb" && s.Datastore.Type != "kubeapi" && s.Datastore.Type != "postgres" {
|
||||
errs = append(errs, fmt.Errorf("not support datastore type %s", s.Datastore.Type))
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,11 @@ func (s *Config) AddFlags(fs *pflag.FlagSet, c *Config) {
|
|||
fs.DurationVar(&s.LeaderConfig.Duration, "duration", c.LeaderConfig.Duration, "the lease lock resource name")
|
||||
fs.DurationVar(&s.AddonCacheTime, "addon-cache-duration", c.AddonCacheTime, "how long between two addon cache operation")
|
||||
fs.BoolVar(&s.DisableStatisticCronJob, "disable-statistic-cronJob", c.DisableStatisticCronJob, "close the system statistic info calculating cronJob")
|
||||
fs.StringVar(&s.PprofAddr, "pprof-addr", c.PprofAddr, "The address for pprof to use while exporting profiling results. The default value is empty which means do not expose it. Set it to address like :6666 to expose it.")
|
||||
fs.Float64Var(&s.KubeQPS, "kube-api-qps", c.KubeQPS, "the qps for kube clients. Low qps may lead to low throughput. High qps may give stress to api-server.")
|
||||
fs.IntVar(&s.KubeBurst, "kube-api-burst", c.KubeBurst, "the burst for kube clients. Recommend setting it qps*3.")
|
||||
fs.StringVar(&s.WorkflowVersion, "workflow-version", c.WorkflowVersion, "the version of workflow to meet controller requirement.")
|
||||
fs.StringVar(&s.DexServerURL, "dex-server", c.DexServerURL, "the URL of the dex server.")
|
||||
fs.StringArrayVar(&s.PluginConfig.CustomPluginPath, "plugin-path", c.PluginConfig.CustomPluginPath, "the path of the plugin directory")
|
||||
fs.BoolVar(&s.ExitOnLostLeader, "exit-on-lost-leader", c.ExitOnLostLeader, "exit the process if this server lost the leader election")
|
||||
profiling.AddFlags(fs)
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ func init() {
|
|||
// Application application delivery model
|
||||
type Application struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Project string `json:"project"`
|
||||
Description string `json:"description"`
|
||||
Icon string `json:"icon"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty" gorm:"serializer:json"`
|
||||
Annotations map[string]string `json:"annotations,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
@ -117,27 +117,27 @@ type ComponentSelector struct {
|
|||
// ApplicationComponent component database model
|
||||
type ApplicationComponent struct {
|
||||
BaseModel
|
||||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey" gorm:"primaryKey"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty" gorm:"serializer:json"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Creator string `json:"creator"`
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Type string `json:"type"`
|
||||
Main bool `json:"main"`
|
||||
// ExternalRevision specified the component revisionName
|
||||
ExternalRevision string `json:"externalRevision,omitempty"`
|
||||
Properties *JSONStruct `json:"properties,omitempty"`
|
||||
DependsOn []string `json:"dependsOn,omitempty"`
|
||||
Inputs workflowv1alpha1.StepInputs `json:"inputs,omitempty"`
|
||||
Outputs workflowv1alpha1.StepOutputs `json:"outputs,omitempty"`
|
||||
Properties *JSONStruct `json:"properties,omitempty" gorm:"serializer:json"`
|
||||
DependsOn []string `json:"dependsOn,omitempty" gorm:"serializer:json"`
|
||||
Inputs workflowv1alpha1.StepInputs `json:"inputs,omitempty" gorm:"serializer:json"`
|
||||
Outputs workflowv1alpha1.StepOutputs `json:"outputs,omitempty" gorm:"serializer:json"`
|
||||
// Traits define the trait of one component, the type must be array to keep the order.
|
||||
Traits []ApplicationTrait `json:"traits,omitempty"`
|
||||
Traits []ApplicationTrait `json:"traits,omitempty" gorm:"serializer:json"`
|
||||
// scopes in ApplicationComponent defines the component-level scopes
|
||||
// the format is <scope-type:scope-instance-name> pairs, the key represents type of `ScopeDefinition` while the value represent the name of scope instance.
|
||||
Scopes map[string]string `json:"scopes,omitempty"`
|
||||
WorkloadType common.WorkloadTypeDescriptor `json:"workloadType,omitempty"`
|
||||
Scopes map[string]string `json:"scopes,omitempty" gorm:"serializer:json"`
|
||||
WorkloadType common.WorkloadTypeDescriptor `json:"workloadType,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
@ -176,13 +176,13 @@ func (a *ApplicationComponent) Index() map[string]interface{} {
|
|||
// ApplicationPolicy app policy
|
||||
type ApplicationPolicy struct {
|
||||
BaseModel
|
||||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
Name string `json:"name"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey" gorm:"primaryKey"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Creator string `json:"creator"`
|
||||
Properties *JSONStruct `json:"properties,omitempty"`
|
||||
Properties *JSONStruct `json:"properties,omitempty" gorm:"serializer:json"`
|
||||
// EnvName if it is not empty, the policy is only belong to this environment
|
||||
// For auto created policies, this field will be assigned a value
|
||||
EnvName string `json:"envName"`
|
||||
|
@ -226,7 +226,7 @@ type ApplicationTrait struct {
|
|||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Properties *JSONStruct `json:"properties,omitempty"`
|
||||
Properties *JSONStruct `json:"properties,omitempty" gorm:"serializer:json"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
}
|
||||
|
@ -255,8 +255,8 @@ var WorkflowStepPhaseStopped workflowv1alpha1.WorkflowStepPhase = "stopped"
|
|||
// ApplicationRevision be created when an application initiates deployment and describes the phased version of the application.
|
||||
type ApplicationRevision struct {
|
||||
BaseModel
|
||||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
Version string `json:"version"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey" gorm:"primaryKey"`
|
||||
Version string `json:"version" gorm:"primaryKey"`
|
||||
RollbackVersion string `json:"rollbackVersion,omitempty"`
|
||||
// ApplyAppConfig Stores the application configuration during the current deploy.
|
||||
ApplyAppConfig string `json:"applyAppConfig,omitempty"`
|
||||
|
@ -281,9 +281,9 @@ type ApplicationRevision struct {
|
|||
// EnvName is the env name of this application revision
|
||||
EnvName string `json:"envName"`
|
||||
// CodeInfo is the code info of this application revision
|
||||
CodeInfo *CodeInfo `json:"codeInfo,omitempty"`
|
||||
CodeInfo *CodeInfo `json:"codeInfo,omitempty" gorm:"serializer:json"`
|
||||
// ImageInfo is the image info of this application revision
|
||||
ImageInfo *ImageInfo `json:"imageInfo,omitempty"`
|
||||
ImageInfo *ImageInfo `json:"imageInfo,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// CodeInfo is the code info for webhook request
|
||||
|
@ -384,7 +384,7 @@ type ApplicationTrigger struct {
|
|||
Name string `json:"name"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Token string `json:"token"`
|
||||
Token string `json:"token" gorm:"primaryKey"`
|
||||
Type string `json:"type"`
|
||||
PayloadType string `json:"payloadType"`
|
||||
ComponentName string `json:"componentName"`
|
||||
|
|
|
@ -53,14 +53,14 @@ var (
|
|||
// Cluster describes the model of cluster in apiserver
|
||||
type Cluster struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
Icon string `json:"icon"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Labels map[string]string `json:"labels" gorm:"serializer:json"`
|
||||
Status string `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
Provider ProviderInfo `json:"provider"`
|
||||
Provider ProviderInfo `json:"provider" gorm:"serializer:json"`
|
||||
APIServerURL string `json:"apiServerURL"`
|
||||
DashboardURL string `json:"dashboardURL"`
|
||||
KubeConfig string `json:"kubeConfig"`
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
// Env models the data of env in database
|
||||
type Env struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
|
@ -34,7 +34,7 @@ type Env struct {
|
|||
|
||||
// Targets defines the name of delivery target that belongs to this env
|
||||
// In one project, a delivery target can only belong to one env.
|
||||
Targets []string `json:"targets,omitempty"`
|
||||
Targets []string `json:"targets,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
|
|
@ -25,10 +25,10 @@ func init() {
|
|||
// EnvBinding application env binding
|
||||
type EnvBinding struct {
|
||||
BaseModel
|
||||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey" gorm:"primaryKey"`
|
||||
AppDeployName string `json:"appDeployName"`
|
||||
Name string `json:"name"`
|
||||
ComponentsPatch []ComponentPatch `json:"componentsPatchs"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
ComponentsPatch []ComponentPatch `json:"componentsPatchs" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// ComponentPatch Define differential patches for components in the environment.
|
||||
|
|
|
@ -38,11 +38,11 @@ type WorkflowSpec struct {
|
|||
// Pipeline is the model of pipeline
|
||||
type Pipeline struct {
|
||||
BaseModel
|
||||
Spec WorkflowSpec
|
||||
Name string `json:"name"`
|
||||
Project string `json:"project"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
Spec WorkflowSpec `gorm:"serializer:json"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Project string `json:"project" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// PrimaryKey return custom primary key
|
||||
|
@ -81,9 +81,9 @@ type Value struct {
|
|||
// PipelineContext is pipeline's context groups
|
||||
type PipelineContext struct {
|
||||
BaseModel
|
||||
PipelineName string `json:"pipelineName"`
|
||||
ProjectName string `json:"projectName"`
|
||||
Contexts map[string][]Value `json:"contexts"`
|
||||
PipelineName string `json:"pipelineName" gorm:"primaryKey"`
|
||||
ProjectName string `json:"projectName" gorm:"primaryKey"`
|
||||
Contexts map[string][]Value `json:"contexts" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
|
|
@ -23,10 +23,10 @@ func init() {
|
|||
// PluginSetting save the setting data of the plugin
|
||||
type PluginSetting struct {
|
||||
BaseModel
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Enabled bool `json:"enabled"`
|
||||
JSONData map[string]interface{} `json:"jsonData"`
|
||||
SecureJSONData map[string]interface{} `json:"secureJsonData"`
|
||||
JSONData map[string]interface{} `json:"jsonData" gorm:"serializer:json"`
|
||||
SecureJSONData map[string]interface{} `json:"secureJsonData" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// PrimaryKey return custom primary key
|
||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
|||
// Project basic model
|
||||
type Project struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Owner string `json:"owner"`
|
||||
Description string `json:"description,omitempty"`
|
||||
|
|
|
@ -33,12 +33,12 @@ const (
|
|||
type SystemInfo struct {
|
||||
BaseModel
|
||||
SignedKey string `json:"signedKey"`
|
||||
InstallID string `json:"installID"`
|
||||
InstallID string `json:"installID" gorm:"primaryKey"`
|
||||
EnableCollection bool `json:"enableCollection"`
|
||||
StatisticInfo StatisticInfo `json:"statisticInfo,omitempty"`
|
||||
StatisticInfo StatisticInfo `json:"statisticInfo,omitempty" gorm:"serializer:json"`
|
||||
LoginType string `json:"loginType"`
|
||||
DexUserDefaultProjects []ProjectRef `json:"projects"`
|
||||
DexUserDefaultPlatformRoles []string `json:"dexUserDefaultPlatformRoles"`
|
||||
DexUserDefaultProjects []ProjectRef `json:"projects" gorm:"serializer:json"`
|
||||
DexUserDefaultPlatformRoles []string `json:"dexUserDefaultPlatformRoles" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// ProjectRef set the project name and roles
|
||||
|
|
|
@ -24,12 +24,12 @@ func init() {
|
|||
// It includes kubernetes clusters or cloud service providers
|
||||
type Target struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Project string `json:"project"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Cluster *ClusterTarget `json:"cluster,omitempty"`
|
||||
Variable map[string]interface{} `json:"variable,omitempty"`
|
||||
Cluster *ClusterTarget `json:"cluster,omitempty" gorm:"serializer:json"`
|
||||
Variable map[string]interface{} `json:"variable,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
|
|
@ -40,14 +40,14 @@ const RoleAdmin = "admin"
|
|||
// User is the model of user
|
||||
type User struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Email string `json:"email"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Disabled bool `json:"disabled"`
|
||||
LastLoginTime time.Time `json:"lastLoginTime,omitempty"`
|
||||
LastLoginTime time.Time `json:"lastLoginTime,omitempty" gorm:"default:'2020-01-01'"`
|
||||
// UserRoles binding the platform level roles
|
||||
UserRoles []string `json:"userRoles"`
|
||||
UserRoles []string `json:"userRoles" gorm:"serializer:json"`
|
||||
DexSub string `json:"dexSub,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -94,10 +94,10 @@ func (u *User) IsAdmin() bool {
|
|||
// ProjectUser is the model of user in project
|
||||
type ProjectUser struct {
|
||||
BaseModel
|
||||
Username string `json:"username"`
|
||||
ProjectName string `json:"projectName"`
|
||||
Username string `json:"username" gorm:"primaryKey"`
|
||||
ProjectName string `json:"projectName" gorm:"primaryKey"`
|
||||
// UserRoles binding the project level roles
|
||||
UserRoles []string `json:"userRoles"`
|
||||
UserRoles []string `json:"userRoles" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
@ -137,24 +137,24 @@ type CustomClaims struct {
|
|||
// Role is a model for a new RBAC mode.
|
||||
type Role struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Project string `json:"project,omitempty"`
|
||||
Permissions []string `json:"permissions"`
|
||||
Permissions []string `json:"permissions" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// Permission is a model for a new RBAC mode.
|
||||
type Permission struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Project string `json:"project,omitempty"`
|
||||
Resources []string `json:"resources"`
|
||||
Actions []string `json:"actions"`
|
||||
Project string `json:"project,omitempty" gorm:"primaryKey"`
|
||||
Resources []string `json:"resources" gorm:"serializer:json"`
|
||||
Actions []string `json:"actions" gorm:"serializer:json"`
|
||||
// Effect option values: Allow,Deny
|
||||
Effect string `json:"effect"`
|
||||
Principal *Principal `json:"principal,omitempty"`
|
||||
Condition *Condition `json:"condition,omitempty"`
|
||||
Principal *Principal `json:"principal,omitempty" gorm:"serializer:json"`
|
||||
Condition *Condition `json:"condition,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// Principal is a model for a new RBAC mode.
|
||||
|
@ -234,14 +234,14 @@ func (p *Permission) Index() map[string]interface{} {
|
|||
// PermissionTemplate is a model for a new RBAC mode.
|
||||
type PermissionTemplate struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
// Scope options: project or platform
|
||||
Scope string `json:"scope"`
|
||||
Resources []string `json:"resources"`
|
||||
Actions []string `json:"actions"`
|
||||
Resources []string `json:"resources" gorm:"serializer:json"`
|
||||
Actions []string `json:"actions" gorm:"serializer:json"`
|
||||
Effect string `json:"effect"`
|
||||
Condition *Condition `json:"condition,omitempty"`
|
||||
Condition *Condition `json:"condition,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// TableName return custom table name
|
||||
|
|
|
@ -37,15 +37,15 @@ const UnFinished = "false"
|
|||
// Workflow application delivery database model
|
||||
type Workflow struct {
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Alias string `json:"alias"`
|
||||
Description string `json:"description"`
|
||||
// Workflow used by the default
|
||||
Default *bool `json:"default"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
AppPrimaryKey string `json:"appPrimaryKey" gorm:"primaryKey"`
|
||||
EnvName string `json:"envName"`
|
||||
Mode workflowv1alpha1.WorkflowExecuteMode `json:"mode,omitempty"`
|
||||
Steps []WorkflowStep `json:"steps,omitempty"`
|
||||
Mode workflowv1alpha1.WorkflowExecuteMode `json:"mode,omitempty" gorm:"serializer:json"`
|
||||
Steps []WorkflowStep `json:"steps,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// WorkflowStep defines how to execute a workflow step.
|
||||
|
@ -114,16 +114,16 @@ type WorkflowRecord struct {
|
|||
AppPrimaryKey string `json:"appPrimaryKey"`
|
||||
// RevisionPrimaryKey: should be assigned the version(PublishVersion)
|
||||
RevisionPrimaryKey string `json:"revisionPrimaryKey"`
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" gorm:"primaryKey"`
|
||||
Namespace string `json:"namespace"`
|
||||
StartTime time.Time `json:"startTime,omitempty"`
|
||||
EndTime time.Time `json:"endTime,omitempty"`
|
||||
StartTime time.Time `json:"startTime,omitempty" gorm:"default:'2020-01-01'"`
|
||||
EndTime time.Time `json:"endTime,omitempty" gorm:"default:'2020-01-01'"`
|
||||
Finished string `json:"finished"`
|
||||
Steps []WorkflowStepStatus `json:"steps,omitempty"`
|
||||
Steps []WorkflowStepStatus `json:"steps,omitempty" gorm:"serializer:json"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Mode string `json:"mode"`
|
||||
ContextValue map[string]string `json:"contextValue,omitempty"`
|
||||
ContextValue map[string]string `json:"contextValue,omitempty" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
// WorkflowStepStatus is the workflow step status database model
|
||||
|
|
|
@ -63,10 +63,7 @@ func CreateEnv(ctx context.Context, kubeClient client.Client, ds datastore.DataS
|
|||
klog.Errorf("update namespace label failure %s", err.Error())
|
||||
return bcode.ErrEnvNamespaceFail
|
||||
}
|
||||
if err = ds.Add(ctx, env); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ds.Add(ctx, env)
|
||||
}
|
||||
|
||||
// GetEnv get the environment
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
@ -52,7 +52,7 @@ func TestService(t *testing.T) {
|
|||
RunSpecs(t, "Service Suite")
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func(done Done) {
|
||||
var _ = BeforeSuite(func(ctx SpecContext) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
By("bootstrapping test environment")
|
||||
|
||||
|
@ -90,8 +90,8 @@ var _ = BeforeSuite(func(done Done) {
|
|||
} else {
|
||||
Expect(err).Should(BeNil())
|
||||
}
|
||||
close(done)
|
||||
}, 240)
|
||||
|
||||
}, NodeTimeout(time.Minute))
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
By("tearing down the test environment")
|
||||
|
|
|
@ -44,7 +44,7 @@ func CreateTargetNamespace(ctx context.Context, k8sClient client.Client, cluster
|
|||
}
|
||||
|
||||
// DeleteTargetNamespace delete the namespace of the target
|
||||
func DeleteTargetNamespace(ctx context.Context, k8sClient client.Client, clusterName, namespace, targetName string) error {
|
||||
func DeleteTargetNamespace(ctx context.Context, k8sClient client.Client, clusterName, namespace string) error {
|
||||
err := utils.UpdateNamespace(multicluster.ContextWithClusterName(ctx, clusterName), k8sClient, namespace,
|
||||
utils.MergeOverrideLabels(map[string]string{
|
||||
oam.LabelRuntimeNamespaceUsage: "",
|
||||
|
|
|
@ -19,7 +19,7 @@ package repository
|
|||
import (
|
||||
"context"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/domain/model"
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/utils"
|
||||
|
||||
workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
|
||||
k8stypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog/v2"
|
||||
|
@ -289,7 +291,7 @@ func compareWorkflowSteps(old, new steps) steps {
|
|||
}
|
||||
}
|
||||
|
||||
_, needDeleted, needAdded := pkgUtils.ThreeWaySliceCompare(oldTargets, newTargets)
|
||||
_, needDeleted, needAdded := utils.ThreeWaySliceCompare(oldTargets, newTargets)
|
||||
var workflowSteps []*workflowStep
|
||||
|
||||
var deployCloudResourcePolicyExist = false
|
||||
|
@ -298,7 +300,7 @@ func compareWorkflowSteps(old, new steps) steps {
|
|||
var deletedPolicyCount = 0
|
||||
for i := range oldStep.policies {
|
||||
p := oldStep.policies[i]
|
||||
if pkgUtils.SliceIncludeSlice(needDeleted, cacheTarget(oldStep.stepType, p.targets)) {
|
||||
if utils.SliceIncludeSlice(needDeleted, cacheTarget(oldStep.stepType, p.targets)) {
|
||||
p.state = deleteState
|
||||
deletedPolicyCount++
|
||||
}
|
||||
|
@ -317,7 +319,7 @@ func compareWorkflowSteps(old, new steps) steps {
|
|||
newStep := new[j]
|
||||
for i := range newStep.policies {
|
||||
p := newStep.policies[i]
|
||||
if pkgUtils.SliceIncludeSlice(needAdded, cacheTarget(newStep.stepType, p.targets)) {
|
||||
if utils.SliceIncludeSlice(needAdded, cacheTarget(newStep.stepType, p.targets)) {
|
||||
if p.policyType == v1alpha1.EnvBindingPolicyType && deployCloudResourcePolicyExist {
|
||||
p.state = updateState
|
||||
} else {
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/assert"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/oam-dev/kubevela/pkg/oam/util"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/schema"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/kubevela/pkg/util/slices"
|
||||
workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
@ -42,9 +43,8 @@ import (
|
|||
"github.com/oam-dev/kubevela/pkg/appfile"
|
||||
"github.com/oam-dev/kubevela/pkg/appfile/dryrun"
|
||||
"github.com/oam-dev/kubevela/pkg/oam"
|
||||
"github.com/oam-dev/kubevela/pkg/oam/discoverymapper"
|
||||
pkgUtils "github.com/oam-dev/kubevela/pkg/utils"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/app"
|
||||
appUtil "github.com/oam-dev/kubevela/pkg/utils/app"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/apply"
|
||||
commonutil "github.com/oam-dev/kubevela/pkg/utils/common"
|
||||
|
||||
|
@ -211,7 +211,7 @@ func (c *applicationServiceImpl) ListApplications(ctx context.Context, listOptio
|
|||
return []*apisv1.ApplicationBase{}, nil
|
||||
}
|
||||
if len(listOptions.Projects) > 0 {
|
||||
if !pkgUtils.SliceIncludeSlice(availableProjectNames, listOptions.Projects) {
|
||||
if !utils.SliceIncludeSlice(availableProjectNames, listOptions.Projects) {
|
||||
return []*apisv1.ApplicationBase{}, nil
|
||||
}
|
||||
}
|
||||
|
@ -389,8 +389,8 @@ func (c *applicationServiceImpl) GetApplicationCR(ctx context.Context, appModel
|
|||
return apps, nil
|
||||
}
|
||||
|
||||
// PublishApplicationTemplate publish app template
|
||||
func (c *applicationServiceImpl) PublishApplicationTemplate(ctx context.Context, app *model.Application) (*apisv1.ApplicationTemplateBase, error) {
|
||||
// PublishApplicationTemplate publish appUtil template
|
||||
func (c *applicationServiceImpl) PublishApplicationTemplate(_ context.Context, _ *model.Application) (*apisv1.ApplicationTemplateBase, error) {
|
||||
// TODO:
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ func (c *applicationServiceImpl) CreateApplication(ctx context.Context, req apis
|
|||
Icon: req.Icon,
|
||||
Labels: req.Labels,
|
||||
}
|
||||
// check app name.
|
||||
// check appUtil name.
|
||||
exist, err := c.Store.IsExist(ctx, &application)
|
||||
if err != nil {
|
||||
klog.Errorf("check application name is exist failure %s", err.Error())
|
||||
|
@ -450,7 +450,7 @@ func (c *applicationServiceImpl) CreateApplication(ctx context.Context, req apis
|
|||
}
|
||||
return nil, err
|
||||
}
|
||||
// render app base info.
|
||||
// render appUtil base info.
|
||||
base := assembler.ConvertAppModelToBase(&application, []*apisv1.ProjectBase{project})
|
||||
return base, nil
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ func (c *applicationServiceImpl) DeleteApplicationTrigger(ctx context.Context, a
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return bcode.ErrApplicationTriggerNotExist
|
||||
}
|
||||
klog.Warningf("delete app trigger failure %s", err.Error())
|
||||
klog.Warningf("delete appUtil trigger failure %s", err.Error())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -515,7 +515,7 @@ func (c *applicationServiceImpl) UpdateApplicationTrigger(ctx context.Context, a
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return nil, bcode.ErrApplicationTriggerNotExist
|
||||
}
|
||||
klog.Warningf("get app trigger failure %s", err.Error())
|
||||
klog.Warningf("get appUtil trigger failure %s", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
// checking the workflow
|
||||
|
@ -655,7 +655,7 @@ func (c *applicationServiceImpl) ListRecords(ctx context.Context, appName string
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (c *applicationServiceImpl) ListComponents(ctx context.Context, app *model.Application, op apisv1.ListApplicationComponentOptions) ([]*apisv1.ComponentBase, error) {
|
||||
func (c *applicationServiceImpl) ListComponents(ctx context.Context, app *model.Application, _ apisv1.ListApplicationComponentOptions) ([]*apisv1.ComponentBase, error) {
|
||||
var component = model.ApplicationComponent{
|
||||
AppPrimaryKey: app.PrimaryKey(),
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ func (c *applicationServiceImpl) ListComponents(ctx context.Context, app *model.
|
|||
return list, nil
|
||||
}
|
||||
|
||||
// DetailComponent detail app component
|
||||
// DetailComponent detail appUtil component
|
||||
func (c *applicationServiceImpl) DetailComponent(ctx context.Context, app *model.Application, compName string) (*apisv1.DetailComponentResponse, error) {
|
||||
var component = model.ApplicationComponent{
|
||||
AppPrimaryKey: app.PrimaryKey(),
|
||||
|
@ -716,7 +716,7 @@ func (c *applicationServiceImpl) ListPolicies(ctx context.Context, app *model.Ap
|
|||
return list, nil
|
||||
}
|
||||
|
||||
// DetailPolicy detail app policy
|
||||
// DetailPolicy detail appUtil policy
|
||||
func (c *applicationServiceImpl) DetailPolicy(ctx context.Context, app *model.Application, policyName string) (*apisv1.DetailPolicyResponse, error) {
|
||||
var policy = model.ApplicationPolicy{
|
||||
AppPrimaryKey: app.PrimaryKey(),
|
||||
|
@ -736,7 +736,7 @@ func (c *applicationServiceImpl) DetailPolicy(ctx context.Context, app *model.Ap
|
|||
}, nil
|
||||
}
|
||||
|
||||
// Deploy deploys app to cluster
|
||||
// Deploy deploys appUtil to cluster
|
||||
// means to render oam application config and apply to cluster.
|
||||
// An event record is generated for each deploy.
|
||||
func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error) {
|
||||
|
@ -770,7 +770,7 @@ func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Applicat
|
|||
list, err := c.Store.List(ctx, &lastVersion, &datastore.ListOptions{
|
||||
PageSize: 1, Page: 1, SortBy: []datastore.SortOption{{Key: "createTime", Order: datastore.SortOrderDescending}}})
|
||||
if err != nil && !errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
klog.Errorf("query app latest revision failure %s", err.Error())
|
||||
klog.Errorf("query appUtil latest revision failure %s", err.Error())
|
||||
return nil, bcode.ErrDeployConflict
|
||||
}
|
||||
if len(list) > 0 {
|
||||
|
@ -788,7 +788,7 @@ func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Applicat
|
|||
status = revision.Status
|
||||
}
|
||||
if status != model.RevisionStatusComplete && status != model.RevisionStatusTerminated && status != model.RevisionStatusFail {
|
||||
klog.Warningf("last app revision can not complete %s/%s,the current status is %s", list[0].(*model.ApplicationRevision).AppPrimaryKey, list[0].(*model.ApplicationRevision).Version, status)
|
||||
klog.Warningf("last appUtil revision can not complete %s/%s,the current status is %s", list[0].(*model.ApplicationRevision).AppPrimaryKey, list[0].(*model.ApplicationRevision).Version, status)
|
||||
return nil, bcode.ErrDeployConflict
|
||||
}
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Applicat
|
|||
klog.Warningf("update deploy event failure %s", err.Error())
|
||||
}
|
||||
|
||||
klog.Errorf("deploy app %s failure %s", app.PrimaryKey(), err.Error())
|
||||
klog.Errorf("deploy appUtil %s failure %s", app.PrimaryKey(), err.Error())
|
||||
return nil, bcode.ErrDeployApplyFail
|
||||
}
|
||||
|
||||
|
@ -840,10 +840,10 @@ func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Applicat
|
|||
klog.Warningf("create workflow record failure %s", err.Error())
|
||||
}
|
||||
|
||||
// step6: update app revision status
|
||||
// step6: update appUtil revision status
|
||||
appRevision.Status = model.RevisionStatusRunning
|
||||
if err := c.Store.Put(ctx, appRevision); err != nil {
|
||||
klog.Warningf("update app revision failure %s", err.Error())
|
||||
klog.Warningf("update appUtil revision failure %s", err.Error())
|
||||
}
|
||||
|
||||
// step7: change the source of trust
|
||||
|
@ -852,7 +852,7 @@ func (c *applicationServiceImpl) Deploy(ctx context.Context, app *model.Applicat
|
|||
}
|
||||
app.Labels[velatypes.LabelSourceOfTruth] = velatypes.FromUX
|
||||
if err := c.Store.Put(ctx, app); err != nil {
|
||||
klog.Warningf("failed to update app %s", err.Error())
|
||||
klog.Warningf("failed to update appUtil %s", err.Error())
|
||||
}
|
||||
|
||||
res := &apisv1.ApplicationDeployResponse{
|
||||
|
@ -906,7 +906,7 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
if deployAppName == "" {
|
||||
deployAppName = appModel.Name
|
||||
}
|
||||
var app = &v1beta1.Application{
|
||||
var application = &v1beta1.Application{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Application",
|
||||
APIVersion: "core.oam.dev/v1beta1",
|
||||
|
@ -926,8 +926,8 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
}
|
||||
|
||||
for key, value := range appModel.Annotations {
|
||||
if _, exists := app.ObjectMeta.Annotations[key]; !exists {
|
||||
app.ObjectMeta.Annotations[key] = value
|
||||
if _, exists := application.ObjectMeta.Annotations[key]; !exists {
|
||||
application.ObjectMeta.Annotations[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -936,7 +936,7 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
Name: appModel.Name,
|
||||
Namespace: env.Namespace,
|
||||
}, originalApp); err == nil {
|
||||
app.ResourceVersion = originalApp.ResourceVersion
|
||||
application.ResourceVersion = originalApp.ResourceVersion
|
||||
}
|
||||
|
||||
var component = model.ApplicationComponent{
|
||||
|
@ -987,7 +987,7 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
if component.Properties != nil {
|
||||
bc.Properties = component.Properties.RawExtension()
|
||||
}
|
||||
app.Spec.Components = append(app.Spec.Components, bc)
|
||||
application.Spec.Components = append(application.Spec.Components, bc)
|
||||
}
|
||||
|
||||
for _, policy := range policies {
|
||||
|
@ -998,10 +998,10 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
if policy.Properties != nil {
|
||||
appPolicy.Properties = policy.Properties.RawExtension()
|
||||
}
|
||||
app.Spec.Policies = append(app.Spec.Policies, appPolicy)
|
||||
application.Spec.Policies = append(application.Spec.Policies, appPolicy)
|
||||
}
|
||||
if workflow != nil {
|
||||
app.Annotations[oam.AnnotationWorkflowName] = workflow.Name
|
||||
application.Annotations[oam.AnnotationWorkflowName] = workflow.Name
|
||||
var steps []workflowv1alpha1.WorkflowStep
|
||||
for _, step := range workflow.Steps {
|
||||
workflowStep := workflowv1alpha1.WorkflowStep{
|
||||
|
@ -1013,12 +1013,12 @@ func (c *applicationServiceImpl) renderOAMApplication(ctx context.Context, appMo
|
|||
}
|
||||
steps = append(steps, workflowStep)
|
||||
}
|
||||
app.Spec.Workflow = &v1beta1.Workflow{
|
||||
application.Spec.Workflow = &v1beta1.Workflow{
|
||||
Steps: steps,
|
||||
Mode: &workflow.Mode,
|
||||
}
|
||||
}
|
||||
return app, nil
|
||||
return application, nil
|
||||
}
|
||||
|
||||
func convertWorkflowModel2WorkflowSpec(step model.WorkflowStepBase) workflowv1alpha1.WorkflowStepBase {
|
||||
|
@ -1089,32 +1089,32 @@ func (c *applicationServiceImpl) DeleteApplication(ctx context.Context, app *mod
|
|||
for _, component := range components {
|
||||
err := c.Store.Delete(ctx, &model.ApplicationComponent{AppPrimaryKey: app.PrimaryKey(), Name: component.Name})
|
||||
if err != nil && !errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
klog.Errorf("delete component %s in app %s failure %s", component.Name, app.Name, err.Error())
|
||||
klog.Errorf("delete component %s in appUtil %s failure %s", component.Name, app.Name, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
for _, policy := range policies {
|
||||
err := c.Store.Delete(ctx, &model.ApplicationPolicy{AppPrimaryKey: app.PrimaryKey(), Name: policy.Name})
|
||||
if err != nil && errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
klog.Errorf("delete policy %s in app %s failure %s", policy.Name, app.Name, err.Error())
|
||||
klog.Errorf("delete policy %s in appUtil %s failure %s", policy.Name, app.Name, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
for _, entity := range revisions {
|
||||
revision := entity.(*model.ApplicationRevision)
|
||||
if err := c.Store.Delete(ctx, &model.ApplicationRevision{AppPrimaryKey: app.PrimaryKey(), Version: revision.Version}); err != nil {
|
||||
klog.Errorf("delete revision %s in app %s failure %s", revision.Version, app.Name, err.Error())
|
||||
klog.Errorf("delete revision %s in appUtil %s failure %s", revision.Version, app.Name, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
for _, trigger := range triggers {
|
||||
if err := c.Store.Delete(ctx, &model.ApplicationTrigger{AppPrimaryKey: app.PrimaryKey(), Name: trigger.Name, Token: trigger.Token}); err != nil {
|
||||
klog.Errorf("delete trigger %s in app %s failure %s", trigger.Name, app.Name, err.Error())
|
||||
klog.Errorf("delete trigger %s in appUtil %s failure %s", trigger.Name, app.Name, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.EnvBindingService.BatchDeleteEnvBinding(ctx, app); err != nil {
|
||||
klog.Errorf("delete envbindings in app %s failure %s", app.Name, err.Error())
|
||||
klog.Errorf("delete envbindings in appUtil %s failure %s", app.Name, err.Error())
|
||||
}
|
||||
|
||||
return c.Store.Delete(ctx, app)
|
||||
|
@ -1135,7 +1135,7 @@ func (c *applicationServiceImpl) GetApplicationComponent(ctx context.Context, ap
|
|||
return &component, nil
|
||||
}
|
||||
|
||||
func (c *applicationServiceImpl) UpdateComponent(ctx context.Context, app *model.Application, component *model.ApplicationComponent, req apisv1.UpdateApplicationComponentRequest) (*apisv1.ComponentBase, error) {
|
||||
func (c *applicationServiceImpl) UpdateComponent(ctx context.Context, _ *model.Application, component *model.ApplicationComponent, req apisv1.UpdateApplicationComponentRequest) (*apisv1.ComponentBase, error) {
|
||||
if req.Alias != nil {
|
||||
component.Alias = *req.Alias
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ func (c *applicationServiceImpl) createComponent(ctx context.Context, app *model
|
|||
if errors.Is(err, datastore.ErrRecordExist) {
|
||||
return nil, bcode.ErrApplicationComponentExist
|
||||
}
|
||||
klog.Warningf("add component for app %s failure %s", pkgUtils.Sanitize(app.PrimaryKey()), err.Error())
|
||||
klog.Warningf("add component for appUtil %s failure %s", pkgUtils.Sanitize(app.PrimaryKey()), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
// update the env workflow, the automatically generated workflow is determined by the component type.
|
||||
|
@ -1264,7 +1264,7 @@ func (c *applicationServiceImpl) DeleteComponent(ctx context.Context, app *model
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return bcode.ErrApplicationComponentNotExist
|
||||
}
|
||||
klog.Warningf("delete app component %s failure %s", app.PrimaryKey(), err.Error())
|
||||
klog.Warningf("delete appUtil component %s failure %s", app.PrimaryKey(), err.Error())
|
||||
return err
|
||||
}
|
||||
if err := repository.UpdateAppEnvWorkflow(ctx, c.KubeClient, c.Store, app); err != nil {
|
||||
|
@ -1293,7 +1293,7 @@ func (c *applicationServiceImpl) CreatePolicy(ctx context.Context, app *model.Ap
|
|||
if errors.Is(err, datastore.ErrRecordExist) {
|
||||
return nil, bcode.ErrApplicationPolicyExist
|
||||
}
|
||||
klog.Warningf("add policy for app %s failure %s", app.PrimaryKey(), err.Error())
|
||||
klog.Warningf("add policy for appUtil %s failure %s", app.PrimaryKey(), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
if err = c.handlePolicyBindingWorkflowStep(ctx, app, createPolicy.Name, createPolicy.WorkflowPolicyBindings); err != nil {
|
||||
|
@ -1320,7 +1320,7 @@ func (c *applicationServiceImpl) DeletePolicy(ctx context.Context, app *model.Ap
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return bcode.ErrApplicationPolicyNotExist
|
||||
}
|
||||
klog.Warningf("delete app policy %s failure %s", app.PrimaryKey(), err.Error())
|
||||
klog.Warningf("delete appUtil policy %s failure %s", app.PrimaryKey(), err.Error())
|
||||
return err
|
||||
}
|
||||
return c.handlePolicyBindingWorkflowStep(ctx, app, policyName, nil)
|
||||
|
@ -1336,7 +1336,7 @@ func (c *applicationServiceImpl) UpdatePolicy(ctx context.Context, app *model.Ap
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
return nil, bcode.ErrApplicationPolicyNotExist
|
||||
}
|
||||
klog.Warningf("update app policy %s failure %s", app.PrimaryKey(), err.Error())
|
||||
klog.Warningf("update appUtil policy %s failure %s", app.PrimaryKey(), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
policy.Type = policyUpdate.Type
|
||||
|
@ -1397,10 +1397,7 @@ func (c *applicationServiceImpl) DeleteApplicationTrait(ctx context.Context, app
|
|||
for i, trait := range comp.Traits {
|
||||
if trait.Type == traitType {
|
||||
comp.Traits = append(comp.Traits[:i], comp.Traits[i+1:]...)
|
||||
if err := c.Store.Put(ctx, &comp); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return c.Store.Put(ctx, &comp)
|
||||
}
|
||||
}
|
||||
return bcode.ErrTraitNotExist
|
||||
|
@ -1501,7 +1498,7 @@ func (c *applicationServiceImpl) Statistics(ctx context.Context, app *model.Appl
|
|||
var targetMap = make(map[string]int)
|
||||
envbinding, err := c.EnvBindingService.GetEnvBindings(ctx, app)
|
||||
if err != nil {
|
||||
klog.Errorf("query app envbinding failure %s", err.Error())
|
||||
klog.Errorf("query appUtil envbinding failure %s", err.Error())
|
||||
}
|
||||
for _, env := range envbinding {
|
||||
for _, target := range env.TargetNames {
|
||||
|
@ -1558,7 +1555,7 @@ func (c *applicationServiceImpl) CompareApp(ctx context.Context, appModel *model
|
|||
}
|
||||
base, envNameByRevision, err = c.getAppModelFromRevision(ctx, appModel.Name, revision)
|
||||
if err != nil {
|
||||
klog.Errorf("failed to get the app model from the revision %s", err.Error())
|
||||
klog.Errorf("failed to get the appUtil model from the revision %s", err.Error())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -1611,7 +1608,7 @@ func (c *applicationServiceImpl) CompareApp(ctx context.Context, appModel *model
|
|||
args.SetClient(c.KubeClient)
|
||||
diffResult, buff, err := compare(ctx, args, compareTarget, base)
|
||||
if err != nil {
|
||||
klog.Errorf("fail to compare the app %s", err.Error())
|
||||
klog.Errorf("fail to compare the appUtil %s", err.Error())
|
||||
compareResponse.IsDiff = false
|
||||
return compareResponse, nil
|
||||
}
|
||||
|
@ -1620,7 +1617,7 @@ func (c *applicationServiceImpl) CompareApp(ctx context.Context, appModel *model
|
|||
return compareResponse, nil
|
||||
}
|
||||
|
||||
// ResetAppToLatestRevision reset app's component to last revision
|
||||
// ResetAppToLatestRevision reset appUtil's component to last revision
|
||||
func (c *applicationServiceImpl) ResetAppToLatestRevision(ctx context.Context, appName string) (*apisv1.AppResetResponse, error) {
|
||||
targetApp, _, err := c.getAppModelFromRevision(ctx, appName, "")
|
||||
if err != nil {
|
||||
|
@ -1672,12 +1669,13 @@ func (c *applicationServiceImpl) DryRunAppOrRevision(ctx context.Context, appMod
|
|||
}
|
||||
|
||||
func genWebhookToken() string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
source := rand.NewSource(time.Now().UnixNano()) //nolint:gosec
|
||||
rng := rand.New(source) //nolint:gosec
|
||||
runes := []rune("abcdefghijklmnopqrstuvwxyz0123456789")
|
||||
|
||||
b := make([]rune, defaultTokenLen)
|
||||
for i := range b {
|
||||
b[i] = runes[rand.Intn(len(runes))] // #nosec
|
||||
b[i] = runes[rng.Intn(len(runes))] //nolint:gosec
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
@ -1714,9 +1712,9 @@ func (c *applicationServiceImpl) resetApp(ctx context.Context, targetApp *v1beta
|
|||
targetCompNames = append(targetCompNames, comp.Name)
|
||||
}
|
||||
|
||||
readyToUpdate, readyToDelete, readyToAdd := pkgUtils.ThreeWaySliceCompare(originCompNames, targetCompNames)
|
||||
readyToUpdate, readyToDelete, readyToAdd := utils.ThreeWaySliceCompare(originCompNames, targetCompNames)
|
||||
|
||||
// delete new app's components
|
||||
// delete new appUtil's components
|
||||
for _, compName := range readyToDelete {
|
||||
var component = model.ApplicationComponent{
|
||||
AppPrimaryKey: appPrimaryKey,
|
||||
|
@ -1726,13 +1724,13 @@ func (c *applicationServiceImpl) resetApp(ctx context.Context, targetApp *v1beta
|
|||
if errors.Is(err, datastore.ErrRecordNotExist) {
|
||||
continue
|
||||
}
|
||||
klog.Warningf("delete app %s comp %s failure %s", appPrimaryKey, compName, err.Error())
|
||||
klog.Warningf("delete appUtil %s comp %s failure %s", appPrimaryKey, compName, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
for _, comp := range targetComps {
|
||||
// add or update new app's components from old app
|
||||
if pkgUtils.StringsContain(readyToAdd, comp.Name) || pkgUtils.StringsContain(readyToUpdate, comp.Name) {
|
||||
// add or update new appUtil's components from old appUtil
|
||||
if slices.Contains(readyToAdd, comp.Name) || slices.Contains(readyToUpdate, comp.Name) {
|
||||
compModel, err := convert.FromCRComponent(appPrimaryKey, comp)
|
||||
if err != nil {
|
||||
return &apisv1.AppResetResponse{}, bcode.ErrInvalidProperties
|
||||
|
@ -1746,11 +1744,11 @@ func (c *applicationServiceImpl) resetApp(ctx context.Context, targetApp *v1beta
|
|||
if errors.Is(err, datastore.ErrRecordExist) {
|
||||
err := c.Store.Put(ctx, &compModel)
|
||||
if err != nil {
|
||||
klog.Warningf("update comp %s for app %s failure %s", comp.Name, pkgUtils.Sanitize(appPrimaryKey), err.Error())
|
||||
klog.Warningf("update comp %s for appUtil %s failure %s", comp.Name, pkgUtils.Sanitize(appPrimaryKey), err.Error())
|
||||
}
|
||||
return &apisv1.AppResetResponse{IsReset: true}, err
|
||||
}
|
||||
klog.Warningf("add comp %s for app %s failure %s", comp.Name, pkgUtils.Sanitize(appPrimaryKey), err.Error())
|
||||
klog.Warningf("add comp %s for appUtil %s failure %s", comp.Name, pkgUtils.Sanitize(appPrimaryKey), err.Error())
|
||||
return &apisv1.AppResetResponse{}, err
|
||||
}
|
||||
}
|
||||
|
@ -1782,12 +1780,12 @@ func (c *applicationServiceImpl) RollbackWithRevision(ctx context.Context, appli
|
|||
if err := c.Store.Put(ctx, &revision); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, appCR, err := app.RollbackApplicationWithRevision(context.WithValue(ctx, &app.RevisionContextKey, utils.WithProject(ctx, "")), c.KubeClient, appCR.Name, appCR.Namespace, revision.RevisionCRName, publishVersion)
|
||||
_, appCR, err := appUtil.RollbackApplicationWithRevision(context.WithValue(ctx, &appUtil.RevisionContextKey, utils.WithProject(ctx, "")), c.KubeClient, appCR.Name, appCR.Namespace, revision.RevisionCRName, publishVersion)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, app.ErrNotMatchRevision):
|
||||
case errors.Is(err, appUtil.ErrNotMatchRevision):
|
||||
noRevision = true
|
||||
case errors.Is(err, app.ErrRevisionNotChange):
|
||||
case errors.Is(err, appUtil.ErrRevisionNotChange):
|
||||
return nil, bcode.ErrApplicationRevisionConflict
|
||||
default:
|
||||
revision.RevisionCRName = revisionCRName
|
||||
|
@ -1815,7 +1813,7 @@ func (c *applicationServiceImpl) RollbackWithRevision(ctx context.Context, appli
|
|||
}
|
||||
err = c.Apply.Apply(ctx, rollBackApp)
|
||||
if err != nil {
|
||||
klog.Errorf("rollback the app %s failure %s", application.PrimaryKey(), err.Error())
|
||||
klog.Errorf("rollback the appUtil %s failure %s", application.PrimaryKey(), err.Error())
|
||||
return nil, err
|
||||
}
|
||||
rollbackApplication = rollBackApp
|
||||
|
@ -1845,7 +1843,7 @@ func dryRunApplication(ctx context.Context, c commonutil.Args, app *v1beta1.Appl
|
|||
}
|
||||
result, err := yaml.Marshal(app)
|
||||
if err != nil {
|
||||
return buff, fmt.Errorf("marshal app: %w", err)
|
||||
return buff, fmt.Errorf("marshal appUtil: %w", err)
|
||||
}
|
||||
buff.Write(result)
|
||||
|
||||
|
@ -1862,11 +1860,7 @@ func dryRunApplication(ctx context.Context, c commonutil.Args, app *v1beta1.Appl
|
|||
if err != nil {
|
||||
return buff, err
|
||||
}
|
||||
dm, err := discoverymapper.New(config)
|
||||
if err != nil {
|
||||
return buff, err
|
||||
}
|
||||
dryRunOpt := dryrun.NewDryRunOption(newClient, config, dm, pd, objects, true)
|
||||
dryRunOpt := dryrun.NewDryRunOption(newClient, config, pd, objects, true)
|
||||
dryRunOpt.GenerateAppFile = func(ctx context.Context, app *v1beta1.Application) (*appfile.Appfile, error) {
|
||||
generateCtx := utils.WithProject(ctx, "")
|
||||
return dryRunOpt.Parser.GenerateAppFileFromApp(generateCtx, app)
|
||||
|
@ -1881,7 +1875,7 @@ func dryRunApplication(ctx context.Context, c commonutil.Args, app *v1beta1.Appl
|
|||
return buff, nil
|
||||
}
|
||||
|
||||
// ignoreSomeParams ignore some parameters before comparing the app changes.
|
||||
// ignoreSomeParams ignore some parameters before comparing the appUtil changes.
|
||||
// ignore the workflow spec
|
||||
func ignoreSomeParams(o *v1beta1.Application) {
|
||||
var defaultApplication = v1beta1.Application{}
|
||||
|
@ -1912,16 +1906,12 @@ func compare(ctx context.Context, c commonutil.Args, targetApp *v1beta1.Applicat
|
|||
if err != nil {
|
||||
return nil, buff, err
|
||||
}
|
||||
dm, err := discoverymapper.New(config)
|
||||
if err != nil {
|
||||
return nil, buff, err
|
||||
}
|
||||
var objs []oam.Object
|
||||
client, err := c.GetClient()
|
||||
if err != nil {
|
||||
return nil, buff, err
|
||||
}
|
||||
liveDiffOption := dryrun.NewLiveDiffOption(client, config, dm, pd, objs)
|
||||
liveDiffOption := dryrun.NewLiveDiffOption(client, config, pd, objs)
|
||||
diffResult, err := liveDiffOption.DiffApps(ctx, baseApp, targetApp)
|
||||
if err != nil {
|
||||
return nil, buff, err
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
|
||||
wfTypes "github.com/kubevela/workflow/pkg/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -211,7 +211,7 @@ func (a *authenticationServiceImpl) generateJWTToken(username, grantType string,
|
|||
return token.SignedString([]byte(signedKey))
|
||||
}
|
||||
|
||||
func (a *authenticationServiceImpl) RefreshToken(ctx context.Context, refreshToken string) (*apisv1.RefreshTokenResponse, error) {
|
||||
func (a *authenticationServiceImpl) RefreshToken(_ context.Context, refreshToken string) (*apisv1.RefreshTokenResponse, error) {
|
||||
claim, err := ParseToken(refreshToken)
|
||||
if err != nil {
|
||||
if errors.Is(err, bcode.ErrTokenExpired) {
|
||||
|
@ -235,7 +235,7 @@ func (a *authenticationServiceImpl) RefreshToken(ctx context.Context, refreshTok
|
|||
|
||||
// ParseToken parses and verifies a token
|
||||
func ParseToken(tokenString string) (*model.CustomClaims, error) {
|
||||
token, err := jwt.ParseWithClaims(tokenString, &model.CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
token, err := jwt.ParseWithClaims(tokenString, &model.CustomClaims{}, func(token *jwt.Token) (interface{}, error) { //nolint:revive,unused
|
||||
return []byte(signedKey), nil
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -449,6 +449,14 @@ func (a *authenticationServiceImpl) GetLoginType(ctx context.Context) (*apisv1.G
|
|||
}, nil
|
||||
}
|
||||
|
||||
func getUserName(sub string) string {
|
||||
username := strings.ToLower(sub)
|
||||
if len(sub) > datastore.PrimaryKeyMaxLength {
|
||||
return sub[:datastore.PrimaryKeyMaxLength]
|
||||
}
|
||||
return username
|
||||
}
|
||||
|
||||
func (d *dexHandlerImpl) login(ctx context.Context) (*apisv1.UserBase, error) {
|
||||
var claims struct {
|
||||
Email string `json:"email"`
|
||||
|
@ -492,14 +500,8 @@ func (d *dexHandlerImpl) login(ctx context.Context) (*apisv1.UserBase, error) {
|
|||
klog.Errorf("failed to get the system info %s", err.Error())
|
||||
}
|
||||
user := &model.User{
|
||||
Email: claims.Email,
|
||||
Name: func() string {
|
||||
sub := strings.ToLower(claims.Sub)
|
||||
if len(sub) > datastore.PrimaryKeyMaxLength {
|
||||
return sub[:datastore.PrimaryKeyMaxLength]
|
||||
}
|
||||
return sub
|
||||
}(),
|
||||
Email: claims.Email,
|
||||
Name: getUserName(claims.Sub),
|
||||
DexSub: claims.Sub,
|
||||
Alias: claims.Name,
|
||||
LastLoginTime: time.Now(),
|
||||
|
@ -514,7 +516,7 @@ func (d *dexHandlerImpl) login(ctx context.Context) (*apisv1.UserBase, error) {
|
|||
if systemInfo != nil {
|
||||
for _, project := range systemInfo.DexUserDefaultProjects {
|
||||
_, err := d.projectService.AddProjectUser(ctx, project.Name, apisv1.AddProjectUserRequest{
|
||||
UserName: strings.ToLower(claims.Sub),
|
||||
UserName: getUserName(claims.Sub),
|
||||
UserRoles: project.Roles,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/oam-dev/kubevela/pkg/multicluster"
|
||||
"github.com/oam-dev/kubevela/pkg/oam"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -26,6 +26,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/kubevela/pkg/util/slices"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/infrastructure/datastore"
|
||||
|
||||
"github.com/cloudtty/cloudtty/pkg/apis/cloudshell/v1alpha1"
|
||||
|
@ -43,7 +45,6 @@ import (
|
|||
|
||||
kubevelatypes "github.com/oam-dev/kubevela/apis/types"
|
||||
"github.com/oam-dev/kubevela/pkg/auth"
|
||||
pkgutils "github.com/oam-dev/kubevela/pkg/utils"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/domain/model"
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
|
@ -134,11 +135,11 @@ func (c *cloudShellServiceImpl) Prepare(ctx context.Context) (*apisv1.CloudShell
|
|||
if err := c.prepareKubeConfig(ctx); err != nil {
|
||||
return res, fmt.Errorf("failed to prepare the kubeconfig for the user: %w", err)
|
||||
}
|
||||
new, err := c.newCloudShell(ctx)
|
||||
newCS, err := c.newCloudShell(ctx)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if err := c.KubeClient.Create(ctx, new); err != nil {
|
||||
if err := c.KubeClient.Create(ctx, newCS); err != nil {
|
||||
if meta.IsNoMatchError(err) {
|
||||
return nil, bcode.ErrCloudShellAddonNotEnabled
|
||||
}
|
||||
|
@ -263,7 +264,7 @@ func (c *cloudShellServiceImpl) prepareKubeConfig(ctx context.Context) error {
|
|||
}
|
||||
groups = append(groups, utils.TemplateReaderGroup)
|
||||
|
||||
if pkgutils.StringsContain(user.UserRoles, model.RoleAdmin) {
|
||||
if slices.Contains(user.UserRoles, model.RoleAdmin) {
|
||||
groups = append(groups, utils.KubeVelaAdminGroupPrefix+"admin")
|
||||
}
|
||||
|
||||
|
@ -380,7 +381,7 @@ func (c *cloudShellServiceImpl) newCloudShell(ctx context.Context) (*v1alpha1.Cl
|
|||
|
||||
func checkReadOnly(projectName string, permissions []*model.Permission) bool {
|
||||
ra := &RequestResourceAction{}
|
||||
ra.SetResourceWithName("project:{projectName}/application:*", func(name string) string {
|
||||
ra.SetResourceWithName("project:{projectName}/application:*", func(name string) string { //nolint:revive,unused
|
||||
return projectName
|
||||
})
|
||||
ra.SetActions([]string{"deploy"})
|
||||
|
|
|
@ -22,11 +22,13 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/kubevela/pkg/util/slices"
|
||||
|
||||
"k8s.io/client-go/kubernetes"
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
|
||||
v1alpha1 "github.com/cloudtty/cloudtty/pkg/apis/cloudshell/v1alpha1"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
|
@ -36,7 +38,6 @@ import (
|
|||
|
||||
kubevelatypes "github.com/oam-dev/kubevela/apis/types"
|
||||
"github.com/oam-dev/kubevela/pkg/auth"
|
||||
pkgutils "github.com/oam-dev/kubevela/pkg/utils"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/server/domain/model"
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
|
@ -131,8 +132,8 @@ var _ = Describe("Test cloudshell service function", func() {
|
|||
var identity auth.Identity
|
||||
err = yaml.Unmarshal([]byte(cm.Data["identity"]), &identity)
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(pkgutils.StringsContain(identity.Groups, utils.KubeVelaAdminGroupPrefix+"admin")).Should(BeTrue())
|
||||
Expect(pkgutils.StringsContain(identity.Groups, utils.TemplateReaderGroup)).Should(BeTrue())
|
||||
Expect(slices.Contains(identity.Groups, utils.KubeVelaAdminGroupPrefix+"admin")).Should(BeTrue())
|
||||
Expect(slices.Contains(identity.Groups, utils.TemplateReaderGroup)).Should(BeTrue())
|
||||
}
|
||||
|
||||
checkConfig()
|
||||
|
|
|
@ -37,11 +37,11 @@ import (
|
|||
"github.com/oam-dev/terraform-controller/api/types"
|
||||
"github.com/oam-dev/terraform-controller/api/v1beta1"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/cloudprovider"
|
||||
"github.com/oam-dev/kubevela/pkg/multicluster"
|
||||
"github.com/oam-dev/kubevela/pkg/utils"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/util"
|
||||
|
||||
"github.com/kubevela/velaux/pkg/cloudprovider"
|
||||
"github.com/kubevela/velaux/pkg/server/domain/model"
|
||||
"github.com/kubevela/velaux/pkg/server/infrastructure/clients"
|
||||
"github.com/kubevela/velaux/pkg/server/infrastructure/datastore"
|
||||
|
@ -492,7 +492,7 @@ func (c *clusterServiceImpl) getClusterResourceInfoFromK8s(ctx context.Context,
|
|||
return clusterResourceInfo, nil
|
||||
}
|
||||
|
||||
func (c *clusterServiceImpl) ListCloudClusters(ctx context.Context, provider string, req apis.AccessKeyRequest, pageNumber int, pageSize int) (*apis.ListCloudClusterResponse, error) {
|
||||
func (c *clusterServiceImpl) ListCloudClusters(_ context.Context, provider string, req apis.AccessKeyRequest, pageNumber int, pageSize int) (*apis.ListCloudClusterResponse, error) {
|
||||
p, err := cloudprovider.GetClusterProvider(provider, req.AccessKeyID, req.AccessKeySecret, c.K8sClient)
|
||||
if err != nil {
|
||||
klog.Errorf("failed to get cluster provider: %s", err.Error())
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -48,6 +48,17 @@ type ConfigService interface {
|
|||
ListConfigDistributions(ctx context.Context, project string) ([]*config.Distribution, error)
|
||||
}
|
||||
|
||||
var (
|
||||
// GlobalConfigNamespace is the namespace for global config, global config should be seen by all projects
|
||||
GlobalConfigNamespace = types.DefaultKubeVelaNS
|
||||
// NoProject is the project name to pass when query global config
|
||||
NoProject = ""
|
||||
)
|
||||
|
||||
func isGlobal(project string) bool {
|
||||
return project == NoProject
|
||||
}
|
||||
|
||||
// NewConfigService returns a config use case
|
||||
func NewConfigService() ConfigService {
|
||||
return &configServiceImpl{}
|
||||
|
@ -62,8 +73,8 @@ type configServiceImpl struct {
|
|||
|
||||
// ListTemplates list the config templates
|
||||
func (u *configServiceImpl) ListTemplates(ctx context.Context, project, scope string) ([]*apis.ConfigTemplate, error) {
|
||||
listCtx := utils.WithProject(ctx, "")
|
||||
queryTemplates, err := u.Factory.ListTemplates(listCtx, types.DefaultKubeVelaNS, scope)
|
||||
listCtx := utils.WithProject(ctx, NoProject)
|
||||
queryTemplates, err := u.Factory.ListTemplates(listCtx, GlobalConfigNamespace, scope)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -99,9 +110,9 @@ func (u *configServiceImpl) ListTemplates(ctx context.Context, project, scope st
|
|||
// GetTemplate detail a template
|
||||
func (u *configServiceImpl) GetTemplate(ctx context.Context, tem config.NamespacedName) (*apis.ConfigTemplateDetail, error) {
|
||||
if tem.Namespace == "" {
|
||||
tem.Namespace = types.DefaultKubeVelaNS
|
||||
tem.Namespace = GlobalConfigNamespace
|
||||
}
|
||||
getCtx := utils.WithProject(ctx, "")
|
||||
getCtx := utils.WithProject(ctx, NoProject)
|
||||
template, err := u.Factory.LoadTemplate(getCtx, tem.Name, tem.Namespace)
|
||||
if err != nil {
|
||||
if errors.Is(err, config.ErrTemplateNotFound) {
|
||||
|
@ -128,8 +139,8 @@ func (u *configServiceImpl) GetTemplate(ctx context.Context, tem config.Namespac
|
|||
}
|
||||
|
||||
func (u *configServiceImpl) CreateConfig(ctx context.Context, project string, req apis.CreateConfigRequest) (*apis.Config, error) {
|
||||
ns := types.DefaultKubeVelaNS
|
||||
if project != "" {
|
||||
ns := GlobalConfigNamespace
|
||||
if !isGlobal(project) {
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -138,7 +149,7 @@ func (u *configServiceImpl) CreateConfig(ctx context.Context, project string, re
|
|||
}
|
||||
exist, err := u.Factory.IsExist(ctx, ns, req.Name)
|
||||
if err != nil {
|
||||
klog.Errorf("check config name is exist failure %s", err.Error())
|
||||
klog.Errorf("check config name exist fail %s", err.Error())
|
||||
return nil, bcode.ErrConfigExist
|
||||
}
|
||||
if exist {
|
||||
|
@ -149,7 +160,7 @@ func (u *configServiceImpl) CreateConfig(ctx context.Context, project string, re
|
|||
return nil, err
|
||||
}
|
||||
if req.Template.Namespace == "" {
|
||||
req.Template.Namespace = types.DefaultKubeVelaNS
|
||||
req.Template.Namespace = GlobalConfigNamespace
|
||||
}
|
||||
configItem, err := u.Factory.ParseConfig(ctx, config.NamespacedName(req.Template), config.Metadata{
|
||||
NamespacedName: config.NamespacedName{Name: req.Name, Namespace: ns},
|
||||
|
@ -169,8 +180,8 @@ func (u *configServiceImpl) CreateConfig(ctx context.Context, project string, re
|
|||
}
|
||||
|
||||
func (u *configServiceImpl) UpdateConfig(ctx context.Context, project string, name string, req apis.UpdateConfigRequest) (*apis.Config, error) {
|
||||
ns := types.DefaultKubeVelaNS
|
||||
if project != "" {
|
||||
ns := GlobalConfigNamespace
|
||||
if !isGlobal(project) {
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -217,8 +228,8 @@ func (u *configServiceImpl) ListConfigs(ctx context.Context, project string, tem
|
|||
var list []*apis.Config
|
||||
scope := ""
|
||||
var projectNamespace string
|
||||
listCtx := utils.WithProject(ctx, "")
|
||||
if project != "" {
|
||||
listCtx := utils.WithProject(ctx, NoProject)
|
||||
if !isGlobal(project) {
|
||||
scope = "project"
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
|
@ -235,7 +246,7 @@ func (u *configServiceImpl) ListConfigs(ctx context.Context, project string, tem
|
|||
}
|
||||
}
|
||||
|
||||
configs, err := u.Factory.ListConfigs(listCtx, types.DefaultKubeVelaNS, template, scope, true)
|
||||
configs, err := u.Factory.ListConfigs(listCtx, GlobalConfigNamespace, template, scope, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -283,7 +294,7 @@ func (u *configServiceImpl) CreateConfigDistribution(ctx context.Context, projec
|
|||
})
|
||||
}
|
||||
|
||||
// ListDistributeConfigs list the all distributions
|
||||
// ListConfigDistributions list the all distributions
|
||||
func (u *configServiceImpl) ListConfigDistributions(ctx context.Context, project string) ([]*config.Distribution, error) {
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
|
@ -324,8 +335,8 @@ func convertConfig(project string, config config.Config) *apis.Config {
|
|||
}
|
||||
|
||||
func (u *configServiceImpl) GetConfig(ctx context.Context, project, name string) (*apis.Config, error) {
|
||||
ns := types.DefaultKubeVelaNS
|
||||
if project != "" {
|
||||
ns := GlobalConfigNamespace
|
||||
if !isGlobal(project) {
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -335,21 +346,25 @@ func (u *configServiceImpl) GetConfig(ctx context.Context, project, name string)
|
|||
|
||||
it, err := u.Factory.GetConfig(ctx, ns, name, true)
|
||||
if err != nil {
|
||||
if errors.Is(err, config.ErrSensitiveConfig) {
|
||||
switch {
|
||||
case errors.Is(err, config.ErrSensitiveConfig):
|
||||
return nil, bcode.ErrSensitiveConfig
|
||||
}
|
||||
if errors.Is(err, config.ErrConfigNotFound) {
|
||||
case errors.Is(err, config.ErrConfigNotFound):
|
||||
if !isGlobal(project) {
|
||||
// Try to get global config if the config is not found in the project scope.
|
||||
return u.GetConfig(ctx, NoProject, name)
|
||||
}
|
||||
return nil, bcode.ErrConfigNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return convertConfig(project, *it), nil
|
||||
}
|
||||
|
||||
func (u *configServiceImpl) DeleteConfig(ctx context.Context, project, name string) error {
|
||||
ns := types.DefaultKubeVelaNS
|
||||
if project != "" {
|
||||
ns := GlobalConfigNamespace
|
||||
if !isGlobal(project) {
|
||||
pro, err := u.ProjectService.GetProject(ctx, project)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"errors"
|
||||
|
||||
terraformapi "github.com/oam-dev/terraform-controller/api/v1beta1"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
apitypes "k8s.io/apimachinery/pkg/types"
|
||||
|
||||
|
@ -101,6 +101,69 @@ template: {
|
|||
}
|
||||
}
|
||||
`
|
||||
var (
|
||||
helmTemplateName = "helm-repository"
|
||||
helmTemplate = `
|
||||
import (
|
||||
"vela/config"
|
||||
)
|
||||
|
||||
metadata: {
|
||||
name: "helm-repository"
|
||||
alias: "Helm Repository"
|
||||
description: "Config information to authenticate helm chart repository"
|
||||
sensitive: false
|
||||
scope: "project"
|
||||
}
|
||||
|
||||
template: {
|
||||
output: {
|
||||
apiVersion: "v1"
|
||||
kind: "Secret"
|
||||
metadata: {
|
||||
name: context.name
|
||||
namespace: context.namespace
|
||||
labels: {
|
||||
"config.oam.dev/catalog": "velacore-config"
|
||||
"config.oam.dev/type": "helm-repository"
|
||||
"config.oam.dev/multi-cluster": "true"
|
||||
"config.oam.dev/sub-type": "helm"
|
||||
}
|
||||
}
|
||||
type: "Opaque"
|
||||
stringData: {
|
||||
url: parameter.url
|
||||
if parameter.username != _|_ {
|
||||
username: parameter.username
|
||||
}
|
||||
if parameter.password != _|_ {
|
||||
password: parameter.password
|
||||
}
|
||||
|
||||
}
|
||||
data: {
|
||||
if parameter.caFile != _|_ {
|
||||
caFile: parameter.caFile
|
||||
}
|
||||
}
|
||||
}
|
||||
// skip the validation here for config.#HelmRepository requires the repository actually exists which can be flaky in unit test
|
||||
//validation: config.#HelmRepository & {
|
||||
// $params: parameter
|
||||
//}
|
||||
|
||||
parameter: {
|
||||
// +usage=The public url of the helm chart repository.
|
||||
url: string
|
||||
// +usage=The username of basic auth repo.
|
||||
username?: string
|
||||
// +usage=The password of basic auth repo.
|
||||
password?: string
|
||||
// +usage=The ca certificate of helm repository. Please encode this data with base64.
|
||||
caFile?: string
|
||||
}
|
||||
}`
|
||||
)
|
||||
|
||||
var _ = Describe("Test config service", func() {
|
||||
var factory config.Factory
|
||||
|
@ -180,9 +243,42 @@ var _ = Describe("Test config service", func() {
|
|||
Expect(len(list)).To(Equal(0))
|
||||
})
|
||||
|
||||
It("Test detail a config", func() {
|
||||
_, err := configService.GetConfig(context.TODO(), "", "alibaba-test")
|
||||
Expect(err).To(Equal(bcode.ErrSensitiveConfig))
|
||||
Context("Test get config", func() {
|
||||
It("Simple get", func() {
|
||||
_, err := configService.GetConfig(context.TODO(), "", "alibaba-test")
|
||||
Expect(err).To(Equal(bcode.ErrSensitiveConfig))
|
||||
})
|
||||
|
||||
It("Get config in project and fall back to get global config", func() {
|
||||
By("apply helm template")
|
||||
tem, err := factory.ParseTemplate(helmTemplateName, []byte(helmTemplate))
|
||||
Expect(err).To(BeNil())
|
||||
Expect(factory.CreateOrUpdateConfigTemplate(context.Background(), types.DefaultKubeVelaNS, tem)).To(BeNil())
|
||||
|
||||
By("create a project")
|
||||
_, err = projectService.CreateProject(context.TODO(), v1.CreateProjectRequest{Name: "some-project"})
|
||||
Expect(err).To(BeNil())
|
||||
defer func() {
|
||||
Expect(projectService.DeleteProject(context.Background(), "some-project")).To(BeNil())
|
||||
}()
|
||||
By("create a common global config")
|
||||
_, err = configService.CreateConfig(context.TODO(), NoProject, v1.CreateConfigRequest{
|
||||
Name: "helm-test",
|
||||
Template: v1.NamespacedName{
|
||||
Name: helmTemplateName,
|
||||
},
|
||||
Properties: `{"username":"test","password":"test","url":"https://helm.kubevela.com/charts"}`,
|
||||
})
|
||||
Expect(err).To(BeNil())
|
||||
defer func() {
|
||||
Expect(configService.DeleteConfig(context.Background(), NoProject, "helm-test")).To(BeNil())
|
||||
}()
|
||||
By("try to get the config in project, should success")
|
||||
config, err := configService.GetConfig(context.TODO(), "some-project", "helm-test")
|
||||
Expect(err).To(BeNil())
|
||||
Expect(config.Name).To(Equal("helm-test"))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
It("Test delete a config", func() {
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/kubevela/pkg/util/stringtools"
|
||||
|
||||
"github.com/oam-dev/kubevela/pkg/utils/addon"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/filters"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/schema"
|
||||
|
@ -38,9 +40,9 @@ import (
|
|||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/kubevela/pkg/util/slices"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
"github.com/oam-dev/kubevela/apis/types"
|
||||
"github.com/oam-dev/kubevela/pkg/utils"
|
||||
|
||||
apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
|
||||
"github.com/kubevela/velaux/pkg/server/utils/bcode"
|
||||
|
@ -85,6 +87,9 @@ const (
|
|||
kindTraitDefinition = "TraitDefinition"
|
||||
kindWorkflowStepDefinition = "WorkflowStepDefinition"
|
||||
kindPolicyDefinition = "PolicyDefinition"
|
||||
|
||||
// LabelDefinitionScope is the label key for definition scope, with this key, we know if the definition is for Application or WorkflowRun
|
||||
LabelDefinitionScope = "custom.definition.oam.dev/scope"
|
||||
)
|
||||
|
||||
// NewDefinitionService new definition service
|
||||
|
@ -120,7 +125,7 @@ func (d *definitionServiceImpl) listDefinitions(ctx context.Context, list *unstr
|
|||
filterScope = "Application"
|
||||
}
|
||||
matchLabels.MatchExpressions = append(matchLabels.MatchExpressions, metav1.LabelSelectorRequirement{
|
||||
Key: types.LabelDefinitionScope,
|
||||
Key: LabelDefinitionScope,
|
||||
Operator: metav1.LabelSelectorOpNotIn,
|
||||
Values: []string{filterScope},
|
||||
})
|
||||
|
@ -441,7 +446,7 @@ func renderDefaultUISchema(apiSchema *openapi3.Schema) []*schema.UIParameter {
|
|||
var params []*schema.UIParameter
|
||||
for key, property := range apiSchema.Properties {
|
||||
if property.Value != nil {
|
||||
param := renderUIParameter(key, schema.FirstUpper(key), property, apiSchema.Required)
|
||||
param := renderUIParameter(key, stringtools.Capitalize(key), property, apiSchema.Required)
|
||||
params = append(params, param)
|
||||
}
|
||||
}
|
||||
|
@ -490,17 +495,18 @@ func renderUIParameter(key, label string, property *openapi3.SchemaRef, required
|
|||
if property.Value.Properties != nil {
|
||||
parameter.SubParameters = renderDefaultUISchema(property.Value)
|
||||
}
|
||||
if property.Value.AdditionalProperties != nil {
|
||||
parameter.SubParameters = renderDefaultUISchema(property.Value.AdditionalProperties.Value)
|
||||
var ap = property.Value.AdditionalProperties
|
||||
if ap.Schema != nil && ap.Schema.Value != nil {
|
||||
value := ap.Schema.Value
|
||||
parameter.SubParameters = renderDefaultUISchema(value)
|
||||
var enable = true
|
||||
value := property.Value.AdditionalProperties.Value
|
||||
parameter.AdditionalParameter = renderUIParameter(value.Title, schema.FirstUpper(value.Title), property.Value.AdditionalProperties, value.Required)
|
||||
parameter.AdditionalParameter = renderUIParameter(value.Title, stringtools.Capitalize(value.Title), property.Value.AdditionalProperties.Schema, value.Required)
|
||||
parameter.Additional = &enable
|
||||
}
|
||||
parameter.Validate = &schema.Validate{}
|
||||
parameter.Validate.DefaultValue = property.Value.Default
|
||||
for _, enum := range property.Value.Enum {
|
||||
parameter.Validate.Options = append(parameter.Validate.Options, schema.Option{Label: schema.RenderLabel(enum), Value: enum})
|
||||
parameter.Validate.Options = append(parameter.Validate.Options, schema.Option{Label: RenderLabel(enum), Value: enum})
|
||||
}
|
||||
parameter.JSONKey = key
|
||||
parameter.Description = property.Value.Description
|
||||
|
@ -511,7 +517,19 @@ func renderUIParameter(key, label string, property *openapi3.SchemaRef, required
|
|||
parameter.Validate.Min = property.Value.Min
|
||||
parameter.Validate.MinLength = property.Value.MinLength
|
||||
parameter.Validate.Pattern = property.Value.Pattern
|
||||
parameter.Validate.Required = utils.StringsContain(required, property.Value.Title)
|
||||
parameter.Validate.Required = slices.Contains(required, property.Value.Title)
|
||||
parameter.Sort = 100
|
||||
return ¶meter
|
||||
}
|
||||
|
||||
// RenderLabel render option label
|
||||
func RenderLabel(source interface{}) string {
|
||||
switch v := source.(type) {
|
||||
case int:
|
||||
return fmt.Sprintf("%d", v)
|
||||
case string:
|
||||
return stringtools.Capitalize(v)
|
||||
default:
|
||||
return stringtools.Capitalize(fmt.Sprintf("%v", v))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/assert"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/kubevela/pkg/util/slices"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
"github.com/oam-dev/kubevela/apis/types"
|
||||
"github.com/oam-dev/kubevela/pkg/auth"
|
||||
|
@ -96,11 +97,7 @@ func (p *envServiceImpl) DeleteEnv(ctx context.Context, envName string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := managePrivilegesForEnvironment(ctx, p.KubeClient, env, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return managePrivilegesForEnvironment(ctx, p.KubeClient, env, true)
|
||||
}
|
||||
|
||||
// ListEnvs list envs
|
||||
|
@ -123,7 +120,7 @@ func (p *envServiceImpl) ListEnvs(ctx context.Context, page, pageSize int, listO
|
|||
return &apisv1.ListEnvResponse{Envs: []*apisv1.Env{}, Total: 0}, nil
|
||||
}
|
||||
if listOption.Project != "" {
|
||||
if !util.StringsContain(availableProjectNames, listOption.Project) {
|
||||
if !slices.Contains(availableProjectNames, listOption.Project) {
|
||||
return &apisv1.ListEnvResponse{Envs: []*apisv1.Env{}, Total: 0}, nil
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +205,7 @@ func (p *envServiceImpl) UpdateEnv(ctx context.Context, name string, req apisv1.
|
|||
}
|
||||
var targets []*model.Target
|
||||
if len(req.Targets) > 0 {
|
||||
_, _, deleted := util.ThreeWaySliceCompare(req.Targets, env.Targets)
|
||||
_, _, deleted := utils.ThreeWaySliceCompare(req.Targets, env.Targets)
|
||||
if len(deleted) > 0 {
|
||||
count, err := p.GetAppCountInEnv(ctx, env)
|
||||
if err != nil {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue