├── .gitignore ├── sync.sh ├── .github ├── CODEOWNERS └── workflows │ └── go.yml ├── README.md ├── apis ├── apis.go ├── core.oam.dev │ ├── common │ │ ├── register.go │ │ ├── doc.go │ │ └── types_test.go │ ├── condition │ │ ├── doc.go │ │ └── zz_generated.deepcopy.go │ ├── v1beta1 │ │ ├── conversion.go │ │ ├── doc.go │ │ ├── definitionrevision_types.go │ │ ├── workflow_step_definition.go │ │ ├── policy_definition.go │ │ ├── applicationrevision_types_test.go │ │ └── register_test.go │ ├── v1alpha1 │ │ ├── doc.go │ │ ├── readonly_policy_types.go │ │ ├── takeover_policy_types.go │ │ ├── sharedresource_policy_types.go │ │ ├── external_types.go │ │ ├── register.go │ │ ├── sharedresource_policy_types_test.go │ │ ├── resource_update_policy_types.go │ │ ├── policy_types.go │ │ ├── applyonce_policy_types.go │ │ ├── resource_policy_types.go │ │ └── component_types.go │ └── groupversion_info.go ├── types │ ├── componentmanifest.go │ ├── event.go │ └── multicluster.go └── generate.go ├── pkg ├── generated │ └── client │ │ ├── clientset │ │ └── versioned │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── register.go │ │ │ └── clientset_generated.go │ │ │ ├── scheme │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ └── typed │ │ │ └── core.oam.dev │ │ │ ├── v1alpha1 │ │ │ ├── generated_expansion.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ └── fake_core.oam.dev_client.go │ │ │ ├── doc.go │ │ │ ├── policy.go │ │ │ └── core.oam.dev_client.go │ │ │ └── v1beta1 │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ └── fake_core.oam.dev_client.go │ │ │ ├── doc.go │ │ │ ├── generated_expansion.go │ │ │ ├── resourcetracker.go │ │ │ ├── application.go │ │ │ ├── definitionrevision.go │ │ │ ├── traitdefinition.go │ │ │ ├── policydefinition.go │ │ │ ├── workloaddefinition.go │ │ │ ├── applicationrevision.go │ │ │ ├── componentdefinition.go │ │ │ └── workflowstepdefinition.go │ │ ├── listers │ │ └── core.oam.dev │ │ │ ├── v1alpha1 │ │ │ ├── expansion_generated.go │ │ │ └── policy.go │ │ │ └── v1beta1 │ │ │ ├── application.go │ │ │ ├── resourcetracker.go │ │ │ ├── traitdefinition.go │ │ │ ├── policydefinition.go │ │ │ ├── definitionrevision.go │ │ │ ├── workloaddefinition.go │ │ │ ├── applicationrevision.go │ │ │ ├── componentdefinition.go │ │ │ ├── workflowstepdefinition.go │ │ │ └── expansion_generated.go │ │ └── informers │ │ └── externalversions │ │ ├── internalinterfaces │ │ └── factory_interfaces.go │ │ ├── core.oam.dev │ │ ├── v1alpha1 │ │ │ ├── interface.go │ │ │ └── policy.go │ │ ├── interface.go │ │ └── v1beta1 │ │ │ ├── application.go │ │ │ ├── resourcetracker.go │ │ │ ├── traitdefinition.go │ │ │ └── policydefinition.go │ │ └── generic.go ├── utils │ └── errors │ │ ├── resourcetracker.go │ │ ├── resourcetracker_test.go │ │ ├── crd.go │ │ ├── reason.go │ │ ├── list.go │ │ ├── crd_test.go │ │ ├── list_test.go │ │ └── reason_test.go └── oam │ ├── var.go │ ├── util │ ├── version.go │ └── version_test.go │ ├── testutil │ └── helper.go │ ├── types.go │ ├── mock │ └── client.go │ └── auxiliary.go ├── Makefile └── test └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | main 3 | test/testapi 4 | -------------------------------------------------------------------------------- /sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -r apis 4 | cp -r ../kubevela/apis . 5 | 6 | rm -r pkg/oam 7 | cp -r ../kubevela/pkg/oam pkg/ 8 | 9 | find . -type f -name "*.go" -print0 | xargs -0 sed -i '' 's|github.com/oam-dev/kubevela/|github.com/oam-dev/kubevela-core-api/|g' 10 | 11 | go build test/main.go -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file is a github code protect rule follow the codeowners https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners#example-of-a-codeowners-file 2 | 3 | * @wonderflow @barnettZQG @FogDong @anoop2811 @briankane @jguionnet 4 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | env: 10 | # Common versions 11 | GO_VERSION: "1.23.8" 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - name: Set up Go 20 | uses: actions/setup-go@v5 21 | with: 22 | go-version: ${{ env.GO_VERSION }} 23 | 24 | - name: Build 25 | run: go build -v ./... 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KubeVela Core API 2 | 3 | API types that work for KubeVela Core CRDs. 4 | 5 | ## Purpose 6 | 7 | This library is the canonical location of the KubeVela Core API definition. 8 | 9 | The code is synced from [kubevela/apis](https://github.com/oam-dev/kubevela/tree/master/apis) every release. 10 | 11 | You can use this separated package if you want: 12 | 13 | * use it as SDK and build your own user interface. 14 | * avoid conflicts of `go.mod` by reducing dependency from KubeVela. 15 | 16 | ## Usage 17 | 18 | Refer to [test/main.go](test/main.go) as example. -------------------------------------------------------------------------------- /apis/apis.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package apis contains all api types of KubeVela 18 | package apis 19 | -------------------------------------------------------------------------------- /apis/core.oam.dev/common/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | const ( 20 | // Group api group name 21 | Group = "core.oam.dev" 22 | ) 23 | -------------------------------------------------------------------------------- /apis/core.oam.dev/condition/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package condition contains condition types 18 | // +kubebuilder:object:generate=true 19 | package condition 20 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | // Hub marks this type as a conversion hub. 20 | func (*Application) Hub() {} 21 | -------------------------------------------------------------------------------- /apis/core.oam.dev/common/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package common contains types required for both v1alpha2 and v1beta1 18 | // +kubebuilder:object:generate=true 19 | package common 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // This package has the automatically generated fake clientset. 19 | package fake 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/scheme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // This package contains the scheme of the automatically generated clientset. 19 | package scheme 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | type PolicyExpansion interface{} 21 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // Package fake has the automatically generated clients. 19 | package fake 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/fake/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // Package fake has the automatically generated clients. 19 | package fake 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // This package has the automatically generated typed clients. 19 | package v1alpha1 20 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | // This package has the automatically generated typed clients. 19 | package v1beta1 20 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1beta1 contains resources relating to the Open Application Model. 18 | // See https://github.com/oam-dev/spec for more details. 19 | // +kubebuilder:object:generate=true 20 | // +groupName=core.oam.dev 21 | // +versionName=v1beta1 22 | package v1beta1 23 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1alpha1 contains resources relating to the Open Application Model. 18 | // See https://github.com/oam-dev/spec for more details. 19 | // +kubebuilder:object:generate=true 20 | // +groupName=core.oam.dev 21 | // +versionName=v1alpha1 22 | package v1alpha1 23 | -------------------------------------------------------------------------------- /pkg/utils/errors/resourcetracker.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | // ManagedResourceHasNoDataError identifies error caused by no data in maanged resource 20 | type ManagedResourceHasNoDataError struct{} 21 | 22 | func (err ManagedResourceHasNoDataError) Error() string { 23 | return "ManagedResource has no data" 24 | } 25 | -------------------------------------------------------------------------------- /pkg/oam/var.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package oam 18 | 19 | var ( 20 | // SystemDefinitionNamespace global value for controller and webhook system-level namespace 21 | SystemDefinitionNamespace = "vela-system" 22 | 23 | // ApplicationControllerName means the controller is application 24 | ApplicationControllerName = "vela-core" 25 | ) 26 | -------------------------------------------------------------------------------- /pkg/utils/errors/resourcetracker_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestManagedResourceHasNoDataError(t *testing.T) { 26 | err := ManagedResourceHasNoDataError{} 27 | assert.EqualError(t, err, "ManagedResource has no data") 28 | } 29 | -------------------------------------------------------------------------------- /pkg/utils/errors/crd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "github.com/pkg/errors" 21 | "k8s.io/apimachinery/pkg/api/meta" 22 | ) 23 | 24 | // IsCRDNotExists check if error is crd not exists 25 | func IsCRDNotExists(err error) bool { 26 | var noKindMatchErr *meta.NoKindMatchError 27 | return errors.As(err, &noKindMatchErr) 28 | } 29 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1alpha1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | // PolicyListerExpansion allows custom methods to be added to 21 | // PolicyLister. 22 | type PolicyListerExpansion interface{} 23 | 24 | // PolicyNamespaceListerExpansion allows custom methods to be added to 25 | // PolicyNamespaceLister. 26 | type PolicyNamespaceListerExpansion interface{} 27 | -------------------------------------------------------------------------------- /pkg/oam/util/version.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "fmt" 21 | "time" 22 | 23 | "cuelang.org/go/pkg/strings" 24 | ) 25 | 26 | // GenerateVersion Generate version numbers by time 27 | func GenerateVersion(pre string) string { 28 | timeStr := time.Now().Format("20060102150405.000") 29 | timeStr = strings.Replace(timeStr, ".", "", 1) 30 | if pre != "" { 31 | return fmt.Sprintf("%s-%s", pre, timeStr) 32 | } 33 | return timeStr 34 | } 35 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Repo info 2 | GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD) 3 | 4 | ERR = echo ${TIME} ${RED}[FAIL]${CNone} 5 | OK = echo ${TIME} ${GREEN}[ OK ]${CNone} 6 | 7 | PROJECT_VERSION_VAR := github.com/oam-dev/velacp/pkg/version.Version 8 | PROJECT_GITVERSION_VAR := github.com/oam-dev/velacp/pkg/version.GitRevision 9 | LDFLAGS ?= "-X $(PROJECT_VERSION_VAR)=$(PROJECT_VERSION) -X $(PROJECT_GITVERSION_VAR)=$(GIT_COMMIT)" 10 | 11 | TARGETS := darwin/amd64 linux/amd64 windows/amd64 12 | DIST_DIRS := find * -name "*-*" -type d -exec 13 | 14 | # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) 15 | ifeq (,$(shell go env GOBIN)) 16 | GOBIN=$(shell go env GOPATH)/bin 17 | else 18 | GOBIN=$(shell go env GOBIN) 19 | endif 20 | 21 | build: reviewable 22 | go build -o test/testapi ./test/main.go 23 | 24 | # Run go fmt against code 25 | fmt: 26 | go fmt ./pkg/... ./test/... ./apis/... 27 | 28 | # Run go vet against code 29 | vet: 30 | go vet ./pkg/... ./test/... ./apis/... 31 | 32 | reviewable: fmt vet 33 | go mod tidy 34 | 35 | 36 | -------------------------------------------------------------------------------- /pkg/oam/util/version_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "strings" 21 | 22 | "github.com/google/go-cmp/cmp" 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | ) 26 | 27 | var _ = Describe("Test version utils", func() { 28 | It("Test New version function", func() { 29 | s := GenerateVersion("") 30 | Expect(s).ShouldNot(BeNil()) 31 | 32 | s2 := GenerateVersion("pre") 33 | Expect(cmp.Diff(strings.HasPrefix(s2, "pre-"), true)).ShouldNot(BeNil()) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | type ApplicationExpansion interface{} 21 | 22 | type ApplicationRevisionExpansion interface{} 23 | 24 | type ComponentDefinitionExpansion interface{} 25 | 26 | type DefinitionRevisionExpansion interface{} 27 | 28 | type PolicyDefinitionExpansion interface{} 29 | 30 | type ResourceTrackerExpansion interface{} 31 | 32 | type TraitDefinitionExpansion interface{} 33 | 34 | type WorkflowStepDefinitionExpansion interface{} 35 | 36 | type WorkloadDefinitionExpansion interface{} 37 | -------------------------------------------------------------------------------- /apis/types/componentmanifest.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | ) 22 | 23 | // ComponentManifest contains resources rendered from an application component. 24 | type ComponentManifest struct { 25 | Name string 26 | Namespace string 27 | RevisionName string 28 | RevisionHash string 29 | // ComponentOutput contains K8s resource generated from "output" block of ComponentDefinition 30 | ComponentOutput *unstructured.Unstructured 31 | // ComponentOutputsAndTraits contains both resources generated from "outputs" block of ComponentDefinition and resources generated from TraitDefinition 32 | ComponentOutputsAndTraits []*unstructured.Unstructured 33 | } 34 | -------------------------------------------------------------------------------- /apis/generate.go: -------------------------------------------------------------------------------- 1 | //go:build generate 2 | // +build generate 3 | 4 | /* 5 | Copyright 2021 The KubeVela Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // See the below link for details on what is happening here. 21 | // https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module 22 | 23 | // NOTE(@wonderflow) We don't remove existing CRDs here, because the crd folders contain not only auto generated. 24 | 25 | // Generate deepcopy methodsets and CRD manifests 26 | //go:generate go run -tags generate sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile=../hack/boilerplate.go.txt paths=./... crd:crdVersions=v1,generateEmbeddedObjectMeta=true output:artifacts:config=../config/crd/base 27 | 28 | package apis 29 | 30 | import ( 31 | _ "sigs.k8s.io/controller-tools/cmd/controller-gen" //nolint:typecheck 32 | ) 33 | -------------------------------------------------------------------------------- /pkg/utils/errors/reason.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "strings" 21 | ) 22 | 23 | const ( 24 | // LabelConflict defines the conflict label error string 25 | LabelConflict = "LabelConflict" 26 | ) 27 | 28 | // IsLabelConflict checks if the error is Label Conflict error 29 | func IsLabelConflict(err error) bool { 30 | if err == nil { 31 | return false 32 | } 33 | if strings.Contains(err.Error(), LabelConflict) { 34 | return true 35 | } 36 | return false 37 | } 38 | 39 | // IsCuePathNotFound checks if the error is cue path not found error 40 | func IsCuePathNotFound(err error) bool { 41 | if err == nil { 42 | return false 43 | } 44 | return strings.Contains(err.Error(), "failed to lookup value") && strings.Contains(err.Error(), "not exist") 45 | } 46 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/fake/fake_core.oam.dev_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package fake 19 | 20 | import ( 21 | v1alpha1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1" 22 | rest "k8s.io/client-go/rest" 23 | testing "k8s.io/client-go/testing" 24 | ) 25 | 26 | type FakeCoreV1alpha1 struct { 27 | *testing.Fake 28 | } 29 | 30 | func (c *FakeCoreV1alpha1) Policies(namespace string) v1alpha1.PolicyInterface { 31 | return &FakePolicies{c, namespace} 32 | } 33 | 34 | // RESTClient returns a RESTClient that is used to communicate 35 | // with API server by this client implementation. 36 | func (c *FakeCoreV1alpha1) RESTClient() rest.Interface { 37 | var ret *rest.RESTClient 38 | return ret 39 | } 40 | -------------------------------------------------------------------------------- /apis/core.oam.dev/groupversion_info.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package core_oam_dev contains API Schema definitions for the core.oam.dev v1alpha2 API group 18 | package core_oam_dev 19 | 20 | import ( 21 | "k8s.io/apimachinery/pkg/runtime" 22 | 23 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 24 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | ) 26 | 27 | func init() { 28 | // Register the types with the Scheme so the resources can map objects to GroupVersionKinds and back 29 | AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme, v1beta1.SchemeBuilder.AddToScheme) 30 | } 31 | 32 | // AddToSchemes may be used to add all resources defined in the project to a Scheme 33 | var AddToSchemes runtime.SchemeBuilder 34 | 35 | // AddToScheme adds all Resources to the Scheme 36 | func AddToScheme(s *runtime.Scheme) error { 37 | return AddToSchemes.AddToScheme(s) 38 | } 39 | -------------------------------------------------------------------------------- /apis/types/event.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | // reason for Application 20 | const ( 21 | ReasonParsed = "Parsed" 22 | ReasonRendered = "Rendered" 23 | ReasonPolicyGenerated = "PolicyGenerated" 24 | ReasonRevisoned = "Revisioned" 25 | ReasonApplied = "Applied" 26 | ReasonDeployed = "Deployed" 27 | 28 | ReasonFailedParse = "FailedParse" 29 | ReasonFailedRevision = "FailedRevision" 30 | ReasonFailedWorkflow = "FailedWorkflow" 31 | ReasonFailedApply = "FailedApply" 32 | ReasonFailedStateKeep = "FailedStateKeep" 33 | ReasonFailedGC = "FailedGC" 34 | ) 35 | 36 | // event message for Application 37 | const ( 38 | MessageParsed = "Parsed successfully" 39 | MessageRendered = "Rendered successfully" 40 | MessagePolicyGenerated = "Policy generated successfully" 41 | MessageRevisioned = "Revisioned successfully" 42 | MessageWorkflowFinished = "Workflow finished" 43 | MessageDeployed = "Deployed successfully" 44 | ) 45 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/readonly_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 20 | 21 | const ( 22 | // ReadOnlyPolicyType refers to the type of read-only policy 23 | ReadOnlyPolicyType = "read-only" 24 | ) 25 | 26 | // ReadOnlyPolicySpec defines the spec of read-only policy 27 | type ReadOnlyPolicySpec struct { 28 | Rules []ReadOnlyPolicyRule `json:"rules"` 29 | } 30 | 31 | // Type the type name of the policy 32 | func (in *ReadOnlyPolicySpec) Type() string { 33 | return ReadOnlyPolicyType 34 | } 35 | 36 | // ReadOnlyPolicyRule defines the rule for read-only resources 37 | type ReadOnlyPolicyRule struct { 38 | Selector ResourcePolicyRuleSelector `json:"selector"` 39 | } 40 | 41 | // FindStrategy return if the target resource is read-only 42 | func (in *ReadOnlyPolicySpec) FindStrategy(manifest *unstructured.Unstructured) bool { 43 | for _, rule := range in.Rules { 44 | if rule.Selector.Match(manifest) { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/takeover_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 20 | 21 | const ( 22 | // TakeOverPolicyType refers to the type of take-over policy 23 | TakeOverPolicyType = "take-over" 24 | ) 25 | 26 | // TakeOverPolicySpec defines the spec of take-over policy 27 | type TakeOverPolicySpec struct { 28 | Rules []TakeOverPolicyRule `json:"rules"` 29 | } 30 | 31 | // Type the type name of the policy 32 | func (in *TakeOverPolicySpec) Type() string { 33 | return TakeOverPolicyType 34 | } 35 | 36 | // TakeOverPolicyRule defines the rule for taking over resources 37 | type TakeOverPolicyRule struct { 38 | Selector ResourcePolicyRuleSelector `json:"selector"` 39 | } 40 | 41 | // FindStrategy return if the target resource should be taken over 42 | func (in *TakeOverPolicySpec) FindStrategy(manifest *unstructured.Unstructured) bool { 43 | for _, rule := range in.Rules { 44 | if rule.Selector.Match(manifest) { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/internalinterfaces/factory_interfaces.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package internalinterfaces 19 | 20 | import ( 21 | time "time" 22 | 23 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 24 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | runtime "k8s.io/apimachinery/pkg/runtime" 26 | cache "k8s.io/client-go/tools/cache" 27 | ) 28 | 29 | // NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. 30 | type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer 31 | 32 | // SharedInformerFactory a small interface to allow for adding an informer without an import cycle 33 | type SharedInformerFactory interface { 34 | Start(stopCh <-chan struct{}) 35 | InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer 36 | } 37 | 38 | // TweakListOptionsFunc is a function that transforms a v1.ListOptions. 39 | type TweakListOptionsFunc func(*v1.ListOptions) 40 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/sharedresource_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 20 | 21 | const ( 22 | // SharedResourcePolicyType refers to the type of shared resource policy 23 | SharedResourcePolicyType = "shared-resource" 24 | ) 25 | 26 | // SharedResourcePolicySpec defines the spec of shared-resource policy 27 | type SharedResourcePolicySpec struct { 28 | Rules []SharedResourcePolicyRule `json:"rules"` 29 | } 30 | 31 | // Type the type name of the policy 32 | func (in *SharedResourcePolicySpec) Type() string { 33 | return SharedResourcePolicyType 34 | } 35 | 36 | // SharedResourcePolicyRule defines the rule for sharing resources 37 | type SharedResourcePolicyRule struct { 38 | Selector ResourcePolicyRuleSelector `json:"selector"` 39 | } 40 | 41 | // FindStrategy return if the target resource should be shared 42 | func (in *SharedResourcePolicySpec) FindStrategy(manifest *unstructured.Unstructured) bool { 43 | for _, rule := range in.Rules { 44 | if rule.Selector.Match(manifest) { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | -------------------------------------------------------------------------------- /pkg/utils/errors/list.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "fmt" 21 | "strings" 22 | ) 23 | 24 | // ErrorList wraps a list of errors, it also fit for an Error interface 25 | type ErrorList []error 26 | 27 | // Error implement error interface 28 | func (e ErrorList) Error() string { 29 | if !e.HasError() { 30 | // it reports an empty string if error is nil 31 | return "" 32 | } 33 | errMessages := make([]string, len(e)) 34 | for i, err := range e { 35 | errMessages[i] = err.Error() 36 | } 37 | return fmt.Sprintf("Found %d errors. [(%s)]", len(e), strings.Join(errMessages, "), (")) 38 | } 39 | 40 | // HasError check if any error exists in list 41 | func (e ErrorList) HasError() bool { 42 | if e == nil { 43 | return false 44 | } 45 | return len(e) > 0 46 | } 47 | 48 | // AggregateErrors aggregate errors into ErrorList and filter nil, if no error found, return nil 49 | func AggregateErrors(errs []error) error { 50 | var es ErrorList 51 | for _, err := range errs { 52 | if err != nil { 53 | es = append(es, err) 54 | } 55 | } 56 | if es.HasError() { 57 | return es 58 | } 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/external_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | ) 23 | 24 | // +kubebuilder:object:root=true 25 | 26 | // Policy is the Schema for the policy API 27 | // +kubebuilder:storageversion 28 | // +kubebuilder:resource:categories={oam} 29 | // +kubebuilder:printcolumn:name="TYPE",type=string,JSONPath=`.type` 30 | // +genclient 31 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 32 | type Policy struct { 33 | metav1.TypeMeta `json:",inline"` 34 | metav1.ObjectMeta `json:"metadata,omitempty"` 35 | 36 | Type string `json:"type"` 37 | // +kubebuilder:pruning:PreserveUnknownFields 38 | Properties *runtime.RawExtension `json:"properties,omitempty"` 39 | } 40 | 41 | // +kubebuilder:object:root=true 42 | 43 | // PolicyList contains a list of Policy 44 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 45 | type PolicyList struct { 46 | metav1.TypeMeta `json:",inline"` 47 | metav1.ListMeta `json:"metadata,omitempty"` 48 | Items []Policy `json:"items"` 49 | } 50 | -------------------------------------------------------------------------------- /pkg/oam/testutil/helper.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testutil 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "time" 23 | 24 | "github.com/onsi/gomega" 25 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 26 | ) 27 | 28 | // ReconcileRetry will reconcile with retry 29 | func ReconcileRetry(r reconcile.Reconciler, req reconcile.Request) { 30 | gomega.Eventually(func() error { 31 | if _, err := r.Reconcile(context.TODO(), req); err != nil { 32 | return err 33 | } 34 | return nil 35 | }, 15*time.Second, time.Second).Should(gomega.BeNil()) 36 | } 37 | 38 | // ReconcileOnce will just reconcile once 39 | func ReconcileOnce(r reconcile.Reconciler, req reconcile.Request) { 40 | if _, err := r.Reconcile(context.TODO(), req); err != nil { 41 | fmt.Println(err.Error()) 42 | } 43 | } 44 | 45 | // ReconcileOnceAfterFinalizer will reconcile for finalizer 46 | func ReconcileOnceAfterFinalizer(r reconcile.Reconciler, req reconcile.Request) (reconcile.Result, error) { 47 | // 1st and 2nd time reconcile to add finalizer 48 | if result, err := r.Reconcile(context.TODO(), req); err != nil { 49 | return result, err 50 | } 51 | 52 | return r.Reconcile(context.TODO(), req) 53 | } 54 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1alpha1/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | import ( 21 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 22 | ) 23 | 24 | // Interface provides access to all the informers in this group version. 25 | type Interface interface { 26 | // Policies returns a PolicyInformer. 27 | Policies() PolicyInformer 28 | } 29 | 30 | type version struct { 31 | factory internalinterfaces.SharedInformerFactory 32 | namespace string 33 | tweakListOptions internalinterfaces.TweakListOptionsFunc 34 | } 35 | 36 | // New returns a new Interface. 37 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 38 | return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 39 | } 40 | 41 | // Policies returns a PolicyInformer. 42 | func (v *version) Policies() PolicyInformer { 43 | return &policyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} 44 | } 45 | -------------------------------------------------------------------------------- /pkg/utils/errors/crd_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | "github.com/pkg/errors" 24 | "github.com/stretchr/testify/assert" 25 | "k8s.io/apimachinery/pkg/api/meta" 26 | "k8s.io/apimachinery/pkg/runtime/schema" 27 | ) 28 | 29 | func TestIsCRDNotExists(t *testing.T) { 30 | noKindMatchErr := &meta.NoKindMatchError{ 31 | GroupKind: schema.GroupKind{Group: "testgroup", Kind: "testkind"}, 32 | } 33 | wrappedErr := errors.Wrap(noKindMatchErr, "wrapped") 34 | otherErr := fmt.Errorf("some other error") 35 | 36 | testCases := []struct { 37 | name string 38 | err error 39 | expected bool 40 | }{ 41 | { 42 | name: "is a NoKindMatchError", 43 | err: noKindMatchErr, 44 | expected: true, 45 | }, 46 | { 47 | name: "is a wrapped NoKindMatchError", 48 | err: wrappedErr, 49 | expected: true, 50 | }, 51 | { 52 | name: "is another error", 53 | err: otherErr, 54 | expected: false, 55 | }, 56 | { 57 | name: "is nil", 58 | err: nil, 59 | expected: false, 60 | }, 61 | } 62 | 63 | for _, tc := range testCases { 64 | t.Run(tc.name, func(t *testing.T) { 65 | result := IsCRDNotExists(tc.err) 66 | assert.Equal(t, tc.expected, result) 67 | }) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /apis/core.oam.dev/condition/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright 2023 The KubeVela Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package condition 22 | 23 | import () 24 | 25 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 26 | func (in *Condition) DeepCopyInto(out *Condition) { 27 | *out = *in 28 | in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) 29 | } 30 | 31 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. 32 | func (in *Condition) DeepCopy() *Condition { 33 | if in == nil { 34 | return nil 35 | } 36 | out := new(Condition) 37 | in.DeepCopyInto(out) 38 | return out 39 | } 40 | 41 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 42 | func (in *ConditionedStatus) DeepCopyInto(out *ConditionedStatus) { 43 | *out = *in 44 | if in.Conditions != nil { 45 | in, out := &in.Conditions, &out.Conditions 46 | *out = make([]Condition, len(*in)) 47 | for i := range *in { 48 | (*in)[i].DeepCopyInto(&(*out)[i]) 49 | } 50 | } 51 | } 52 | 53 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionedStatus. 54 | func (in *ConditionedStatus) DeepCopy() *ConditionedStatus { 55 | if in == nil { 56 | return nil 57 | } 58 | out := new(ConditionedStatus) 59 | in.DeepCopyInto(out) 60 | return out 61 | } 62 | -------------------------------------------------------------------------------- /apis/types/multicluster.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package types 18 | 19 | import ( 20 | "github.com/oam-dev/cluster-gateway/pkg/apis/cluster/v1alpha1" 21 | "github.com/oam-dev/cluster-gateway/pkg/config" 22 | ) 23 | 24 | const ( 25 | // ClusterLocalName the name for the hub cluster 26 | ClusterLocalName = "local" 27 | 28 | // CredentialTypeInternal identifies the virtual cluster from internal kubevela system 29 | CredentialTypeInternal v1alpha1.CredentialType = "Internal" 30 | // CredentialTypeOCMManagedCluster identifies the virtual cluster from ocm 31 | CredentialTypeOCMManagedCluster v1alpha1.CredentialType = "ManagedCluster" 32 | // ClusterBlankEndpoint identifies the endpoint of a cluster as blank (not available) 33 | ClusterBlankEndpoint = "-" 34 | 35 | // ClustersArg indicates the argument for specific clusters to install addon 36 | ClustersArg = "clusters" 37 | ) 38 | 39 | var ( 40 | // AnnotationClusterVersion the annotation key for cluster version 41 | AnnotationClusterVersion = config.MetaApiGroupName + "/cluster-version" 42 | ) 43 | 44 | // ClusterVersion defines the Version info of managed clusters. 45 | type ClusterVersion struct { 46 | Major string `json:"major"` 47 | Minor string `json:"minor"` 48 | GitVersion string `json:"gitVersion,omitempty"` 49 | Platform string `json:"platform,omitempty"` 50 | } 51 | 52 | // ControlPlaneClusterVersion will be the default value of cluster info if managed cluster version get error, it will have value when vela-core started. 53 | var ControlPlaneClusterVersion ClusterVersion 54 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/fake/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package fake 19 | 20 | import ( 21 | corev1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 22 | corev1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var scheme = runtime.NewScheme() 31 | var codecs = serializer.NewCodecFactory(scheme) 32 | 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | corev1alpha1.AddToScheme, 35 | corev1beta1.AddToScheme, 36 | } 37 | 38 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 39 | // of clientsets, like in: 40 | // 41 | // import ( 42 | // "k8s.io/client-go/kubernetes" 43 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 44 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 45 | // ) 46 | // 47 | // kclientset, _ := kubernetes.NewForConfig(c) 48 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 49 | // 50 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 51 | // correctly. 52 | var AddToScheme = localSchemeBuilder.AddToScheme 53 | 54 | func init() { 55 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 56 | utilruntime.Must(AddToScheme(scheme)) 57 | } 58 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/scheme/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package scheme 19 | 20 | import ( 21 | corev1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 22 | corev1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var Scheme = runtime.NewScheme() 31 | var Codecs = serializer.NewCodecFactory(Scheme) 32 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | corev1alpha1.AddToScheme, 35 | corev1beta1.AddToScheme, 36 | } 37 | 38 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 39 | // of clientsets, like in: 40 | // 41 | // import ( 42 | // "k8s.io/client-go/kubernetes" 43 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 44 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 45 | // ) 46 | // 47 | // kclientset, _ := kubernetes.NewForConfig(c) 48 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 49 | // 50 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 51 | // correctly. 52 | var AddToScheme = localSchemeBuilder.AddToScheme 53 | 54 | func init() { 55 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 56 | utilruntime.Must(AddToScheme(Scheme)) 57 | } 58 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/interface.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package core 19 | 20 | import ( 21 | v1alpha1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/core.oam.dev/v1alpha1" 22 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1" 23 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 24 | ) 25 | 26 | // Interface provides access to each of this group's versions. 27 | type Interface interface { 28 | // V1alpha1 provides access to shared informers for resources in V1alpha1. 29 | V1alpha1() v1alpha1.Interface 30 | // V1beta1 provides access to shared informers for resources in V1beta1. 31 | V1beta1() v1beta1.Interface 32 | } 33 | 34 | type group struct { 35 | factory internalinterfaces.SharedInformerFactory 36 | namespace string 37 | tweakListOptions internalinterfaces.TweakListOptionsFunc 38 | } 39 | 40 | // New returns a new Interface. 41 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 42 | return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 43 | } 44 | 45 | // V1alpha1 returns a new v1alpha1.Interface. 46 | func (g *group) V1alpha1() v1alpha1.Interface { 47 | return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) 48 | } 49 | 50 | // V1beta1 returns a new v1beta1.Interface. 51 | func (g *group) V1beta1() v1beta1.Interface { 52 | return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) 53 | } 54 | -------------------------------------------------------------------------------- /apis/core.oam.dev/common/types_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package common 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/require" 23 | v1 "k8s.io/api/core/v1" 24 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 25 | ) 26 | 27 | func TestOAMObjectReference(t *testing.T) { 28 | r := require.New(t) 29 | o1 := OAMObjectReference{ 30 | Component: "component", 31 | Trait: "trait", 32 | } 33 | obj := &unstructured.Unstructured{} 34 | o2 := NewOAMObjectReferenceFromObject(obj) 35 | r.False(o2.Equal(o1)) 36 | o1.AddLabelsToObject(obj) 37 | r.Equal(2, len(obj.GetLabels())) 38 | o3 := NewOAMObjectReferenceFromObject(obj) 39 | r.True(o1.Equal(o3)) 40 | o3.Component = "comp" 41 | r.False(o3.Equal(o1)) 42 | 43 | r.True(o1.Equal(*o1.DeepCopy())) 44 | o4 := OAMObjectReference{} 45 | o1.DeepCopyInto(&o4) 46 | r.True(o4.Equal(o1)) 47 | } 48 | 49 | func TestClusterObjectReference(t *testing.T) { 50 | r := require.New(t) 51 | o1 := ClusterObjectReference{ 52 | Cluster: "cluster", 53 | ObjectReference: v1.ObjectReference{Kind: "kind"}, 54 | } 55 | o2 := *o1.DeepCopy() 56 | r.True(o1.Equal(o2)) 57 | o2.Cluster = "c" 58 | r.False(o2.Equal(o1)) 59 | } 60 | 61 | func TestContainerStateToString(t *testing.T) { 62 | r := require.New(t) 63 | r.Equal("Waiting", ContainerStateToString(v1.ContainerState{ 64 | Waiting: &v1.ContainerStateWaiting{}, 65 | })) 66 | r.Equal("Running", ContainerStateToString(v1.ContainerState{ 67 | Running: &v1.ContainerStateRunning{}, 68 | })) 69 | r.Equal("Terminated", ContainerStateToString(v1.ContainerState{ 70 | Terminated: &v1.ContainerStateTerminated{}, 71 | })) 72 | r.Equal("Unknown", ContainerStateToString(v1.ContainerState{})) 73 | } 74 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime/schema" 21 | k8sscheme "k8s.io/client-go/kubernetes/scheme" 22 | "sigs.k8s.io/controller-runtime/pkg/scheme" 23 | 24 | workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1" 25 | 26 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 27 | ) 28 | 29 | // Package type metadata. 30 | const ( 31 | Group = common.Group 32 | Version = "v1alpha1" 33 | ) 34 | 35 | var ( 36 | // SchemeGroupVersion is group version used to register these objects 37 | SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} 38 | 39 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme 40 | SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} 41 | 42 | // AddToScheme is a global function that registers this API group & version to a scheme 43 | AddToScheme = SchemeBuilder.AddToScheme 44 | ) 45 | 46 | // Policy meta 47 | var ( 48 | PolicyKind = "Policy" 49 | PolicyGroupVersionKind = SchemeGroupVersion.WithKind(PolicyKind) 50 | ) 51 | 52 | // Workflow meta 53 | var ( 54 | WorkflowKind = "Workflow" 55 | WorkflowGroupVersionKind = SchemeGroupVersion.WithKind(WorkflowKind) 56 | ) 57 | 58 | func init() { 59 | SchemeBuilder.Register(&Policy{}, &PolicyList{}) 60 | SchemeBuilder.Register(&workflowv1alpha1.Workflow{}, &workflowv1alpha1.WorkflowList{}) 61 | _ = SchemeBuilder.AddToScheme(k8sscheme.Scheme) 62 | } 63 | 64 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 65 | func Resource(resource string) schema.GroupResource { 66 | return SchemeGroupVersion.WithResource(resource).GroupResource() 67 | } 68 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/sharedresource_policy_types_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/require" 23 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 24 | ) 25 | 26 | func TestSharedResourcePolicySpec_FindStrategy(t *testing.T) { 27 | testCases := map[string]struct { 28 | rules []SharedResourcePolicyRule 29 | input *unstructured.Unstructured 30 | matched bool 31 | }{ 32 | "shared resource rule resourceName match": { 33 | rules: []SharedResourcePolicyRule{{ 34 | Selector: ResourcePolicyRuleSelector{ResourceNames: []string{"example"}}, 35 | }}, 36 | input: &unstructured.Unstructured{Object: map[string]interface{}{ 37 | "metadata": map[string]interface{}{ 38 | "name": "example", 39 | }, 40 | }}, 41 | matched: true, 42 | }, 43 | "shared resource rule resourceType match": { 44 | rules: []SharedResourcePolicyRule{{ 45 | Selector: ResourcePolicyRuleSelector{ResourceTypes: []string{"ConfigMap", "Namespace"}}, 46 | }}, 47 | input: &unstructured.Unstructured{Object: map[string]interface{}{ 48 | "kind": "Namespace", 49 | }}, 50 | matched: true, 51 | }, 52 | "shared resource rule mismatch": { 53 | rules: []SharedResourcePolicyRule{{ 54 | Selector: ResourcePolicyRuleSelector{ResourceNames: []string{"mismatch"}}, 55 | }}, 56 | input: &unstructured.Unstructured{Object: map[string]interface{}{ 57 | "kind": "Namespace", 58 | }}, 59 | matched: false, 60 | }, 61 | } 62 | for name, tc := range testCases { 63 | t.Run(name, func(t *testing.T) { 64 | r := require.New(t) 65 | spec := SharedResourcePolicySpec{Rules: tc.rules} 66 | r.Equal(tc.matched, spec.FindStrategy(tc.input)) 67 | }) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /pkg/oam/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The Crossplane Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package oam contains miscellaneous OAM helper types. 18 | package oam 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 24 | 25 | corev1 "k8s.io/api/core/v1" 26 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 27 | "k8s.io/apimachinery/pkg/runtime" 28 | "k8s.io/apimachinery/pkg/runtime/schema" 29 | ) 30 | 31 | // TraitKind contains the type metadata for a kind of an OAM trait resource. 32 | type TraitKind schema.GroupVersionKind 33 | 34 | // WorkloadKind contains the type metadata for a kind of an OAM workload resource. 35 | type WorkloadKind schema.GroupVersionKind 36 | 37 | // A Conditioned may have conditions set or retrieved. Conditions are typically 38 | // indicate the status of both a resource and its reconciliation process. 39 | type Conditioned interface { 40 | SetConditions(c ...condition.Condition) 41 | GetCondition(condition.ConditionType) condition.Condition 42 | } 43 | 44 | // A WorkloadReferencer may reference an OAM workload. 45 | type WorkloadReferencer interface { 46 | GetWorkloadReference() corev1.ObjectReference 47 | SetWorkloadReference(corev1.ObjectReference) 48 | } 49 | 50 | // A WorkloadsReferencer may reference an OAM workload. 51 | type WorkloadsReferencer interface { 52 | GetWorkloadReferences() []corev1.ObjectReference 53 | AddWorkloadReference(corev1.ObjectReference) 54 | } 55 | 56 | // A Finalizer manages the finalizers on the resource. 57 | type Finalizer interface { 58 | AddFinalizer(ctx context.Context, obj Object) error 59 | RemoveFinalizer(ctx context.Context, obj Object) error 60 | } 61 | 62 | // An Object is a Kubernetes object. 63 | type Object interface { 64 | metav1.Object 65 | runtime.Object 66 | } 67 | 68 | // A Trait is a type of OAM trait. 69 | type Trait interface { 70 | Object 71 | 72 | Conditioned 73 | WorkloadReferencer 74 | } 75 | 76 | // A Workload is a type of OAM workload. 77 | type Workload interface { 78 | Object 79 | 80 | Conditioned 81 | } 82 | -------------------------------------------------------------------------------- /pkg/utils/errors/list_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestErrorList(t *testing.T) { 27 | t.Run("HasError", func(t *testing.T) { 28 | var nilList ErrorList 29 | assert.False(t, nilList.HasError()) 30 | 31 | emptyList := ErrorList{} 32 | assert.False(t, emptyList.HasError()) 33 | 34 | listWithErr := ErrorList{fmt.Errorf("err1")} 35 | assert.True(t, listWithErr.HasError()) 36 | }) 37 | 38 | t.Run("Error", func(t *testing.T) { 39 | var nilList ErrorList 40 | assert.Equal(t, "", nilList.Error()) 41 | 42 | emptyList := ErrorList{} 43 | assert.Equal(t, "", emptyList.Error()) 44 | 45 | listWithOneErr := ErrorList{fmt.Errorf("err1")} 46 | assert.Equal(t, "Found 1 errors. [(err1)]", listWithOneErr.Error()) 47 | 48 | listWithTwoErrs := ErrorList{fmt.Errorf("err1"), fmt.Errorf("err2")} 49 | assert.Equal(t, "Found 2 errors. [(err1), (err2)]", listWithTwoErrs.Error()) 50 | }) 51 | } 52 | 53 | func TestAggregateErrors(t *testing.T) { 54 | err1 := fmt.Errorf("err1") 55 | err2 := fmt.Errorf("err2") 56 | 57 | testCases := []struct { 58 | name string 59 | errs []error 60 | expected error 61 | }{ 62 | { 63 | name: "multiple non-nil errors", 64 | errs: []error{err1, err2}, 65 | expected: ErrorList{err1, err2}, 66 | }, 67 | { 68 | name: "some nil errors", 69 | errs: []error{nil, err1, nil, err2, nil}, 70 | expected: ErrorList{err1, err2}, 71 | }, 72 | { 73 | name: "only nil errors", 74 | errs: []error{nil, nil, nil}, 75 | expected: nil, 76 | }, 77 | { 78 | name: "empty slice", 79 | errs: []error{}, 80 | expected: nil, 81 | }, 82 | { 83 | name: "nil slice", 84 | errs: nil, 85 | expected: nil, 86 | }, 87 | } 88 | 89 | for _, tc := range testCases { 90 | t.Run(tc.name, func(t *testing.T) { 91 | result := AggregateErrors(tc.errs) 92 | assert.Equal(t, tc.expected, result) 93 | }) 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/resource_update_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 20 | 21 | const ( 22 | // ResourceUpdatePolicyType refers to the type of resource-update policy 23 | ResourceUpdatePolicyType = "resource-update" 24 | ) 25 | 26 | // ResourceUpdatePolicySpec defines the spec of resource-update policy 27 | type ResourceUpdatePolicySpec struct { 28 | Rules []ResourceUpdatePolicyRule `json:"rules"` 29 | } 30 | 31 | // Type the type name of the policy 32 | func (in *ResourceUpdatePolicySpec) Type() string { 33 | return ResourceUpdatePolicyType 34 | } 35 | 36 | // ResourceUpdatePolicyRule defines the rule for resource-update resources 37 | type ResourceUpdatePolicyRule struct { 38 | // Selector picks which resources should be affected 39 | Selector ResourcePolicyRuleSelector `json:"selector"` 40 | // Strategy the strategy for updating resources 41 | Strategy ResourceUpdateStrategy `json:"strategy,omitempty"` 42 | } 43 | 44 | // ResourceUpdateStrategy the update strategy for resource 45 | type ResourceUpdateStrategy struct { 46 | // Op the update op for selected resources 47 | Op ResourceUpdateOp `json:"op,omitempty"` 48 | // RecreateFields the field path which will trigger recreate if changed 49 | RecreateFields []string `json:"recreateFields,omitempty"` 50 | } 51 | 52 | // ResourceUpdateOp update op for resource 53 | type ResourceUpdateOp string 54 | 55 | const ( 56 | // ResourceUpdateStrategyPatch patch the target resource (three-way patch) 57 | ResourceUpdateStrategyPatch ResourceUpdateOp = "patch" 58 | // ResourceUpdateStrategyReplace update the target resource 59 | ResourceUpdateStrategyReplace ResourceUpdateOp = "replace" 60 | ) 61 | 62 | // FindStrategy return if the target resource is read-only 63 | func (in *ResourceUpdatePolicySpec) FindStrategy(manifest *unstructured.Unstructured) *ResourceUpdateStrategy { 64 | for _, rule := range in.Rules { 65 | if rule.Selector.Match(manifest) { 66 | return &rule.Strategy 67 | } 68 | } 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /pkg/oam/mock/client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package mock 18 | 19 | import ( 20 | "strings" 21 | 22 | "k8s.io/apimachinery/pkg/api/meta" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | "sigs.k8s.io/controller-runtime/pkg/client" 25 | "sigs.k8s.io/controller-runtime/pkg/client/fake" 26 | ) 27 | 28 | // NewClient new client with given mappings 29 | func NewClient(c client.Client, mappings map[schema.GroupVersionResource][]schema.GroupVersionKind) client.Client { 30 | if c == nil { 31 | c = fake.NewClientBuilder().Build() 32 | } 33 | return &Client{Client: c, mappings: mappings} 34 | } 35 | 36 | // Client fake client 37 | type Client struct { 38 | client.Client 39 | mappings map[schema.GroupVersionResource][]schema.GroupVersionKind 40 | } 41 | 42 | // RESTMapper override default mapper 43 | func (in *Client) RESTMapper() meta.RESTMapper { 44 | mapper := in.Client.RESTMapper() 45 | if mapper == nil { 46 | mapper = fake.NewClientBuilder().Build().RESTMapper() 47 | } 48 | return &RESTMapper{RESTMapper: mapper, mappings: in.mappings} 49 | } 50 | 51 | // RESTMapper test mapper 52 | type RESTMapper struct { 53 | meta.RESTMapper 54 | mappings map[schema.GroupVersionResource][]schema.GroupVersionKind 55 | } 56 | 57 | // KindsFor get kinds 58 | func (in *RESTMapper) KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error) { 59 | if gvks, found := in.mappings[resource]; found { 60 | return gvks, nil 61 | } 62 | return in.RESTMapper.KindsFor(resource) 63 | } 64 | 65 | // RESTMapping get mapping 66 | func (in *RESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error) { 67 | version := "v1" 68 | if len(versions) > 0 { 69 | version = versions[0] 70 | } 71 | return &meta.RESTMapping{ 72 | Resource: schema.GroupVersionResource{Group: gk.Group, Version: versions[0], Resource: strings.ToLower(gk.Kind) + "s"}, 73 | GroupVersionKind: gk.WithVersion(version), 74 | Scope: scope(meta.RESTScopeNameNamespace), 75 | }, nil 76 | } 77 | 78 | type scope meta.RESTScopeName 79 | 80 | func (in scope) Name() meta.RESTScopeName { 81 | return meta.RESTScopeName(in) 82 | } 83 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/fake/fake_core.oam.dev_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package fake 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1" 22 | rest "k8s.io/client-go/rest" 23 | testing "k8s.io/client-go/testing" 24 | ) 25 | 26 | type FakeCoreV1beta1 struct { 27 | *testing.Fake 28 | } 29 | 30 | func (c *FakeCoreV1beta1) Applications(namespace string) v1beta1.ApplicationInterface { 31 | return &FakeApplications{c, namespace} 32 | } 33 | 34 | func (c *FakeCoreV1beta1) ApplicationRevisions(namespace string) v1beta1.ApplicationRevisionInterface { 35 | return &FakeApplicationRevisions{c, namespace} 36 | } 37 | 38 | func (c *FakeCoreV1beta1) ComponentDefinitions(namespace string) v1beta1.ComponentDefinitionInterface { 39 | return &FakeComponentDefinitions{c, namespace} 40 | } 41 | 42 | func (c *FakeCoreV1beta1) DefinitionRevisions(namespace string) v1beta1.DefinitionRevisionInterface { 43 | return &FakeDefinitionRevisions{c, namespace} 44 | } 45 | 46 | func (c *FakeCoreV1beta1) PolicyDefinitions(namespace string) v1beta1.PolicyDefinitionInterface { 47 | return &FakePolicyDefinitions{c, namespace} 48 | } 49 | 50 | func (c *FakeCoreV1beta1) ResourceTrackers(namespace string) v1beta1.ResourceTrackerInterface { 51 | return &FakeResourceTrackers{c, namespace} 52 | } 53 | 54 | func (c *FakeCoreV1beta1) TraitDefinitions(namespace string) v1beta1.TraitDefinitionInterface { 55 | return &FakeTraitDefinitions{c, namespace} 56 | } 57 | 58 | func (c *FakeCoreV1beta1) WorkflowStepDefinitions(namespace string) v1beta1.WorkflowStepDefinitionInterface { 59 | return &FakeWorkflowStepDefinitions{c, namespace} 60 | } 61 | 62 | func (c *FakeCoreV1beta1) WorkloadDefinitions(namespace string) v1beta1.WorkloadDefinitionInterface { 63 | return &FakeWorkloadDefinitions{c, namespace} 64 | } 65 | 66 | // RESTClient returns a RESTClient that is used to communicate 67 | // with API server by this client implementation. 68 | func (c *FakeCoreV1beta1) RESTClient() rest.Interface { 69 | var ret *rest.RESTClient 70 | return ret 71 | } 72 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1alpha1/policy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | import ( 21 | v1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // PolicyLister helps list Policies. 28 | // All objects returned here must be treated as read-only. 29 | type PolicyLister interface { 30 | // List lists all Policies in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1alpha1.Policy, err error) 33 | // Policies returns an object that can list and get Policies. 34 | Policies(namespace string) PolicyNamespaceLister 35 | PolicyListerExpansion 36 | } 37 | 38 | // policyLister implements the PolicyLister interface. 39 | type policyLister struct { 40 | listers.ResourceIndexer[*v1alpha1.Policy] 41 | } 42 | 43 | // NewPolicyLister returns a new PolicyLister. 44 | func NewPolicyLister(indexer cache.Indexer) PolicyLister { 45 | return &policyLister{listers.New[*v1alpha1.Policy](indexer, v1alpha1.Resource("policy"))} 46 | } 47 | 48 | // Policies returns an object that can list and get Policies. 49 | func (s *policyLister) Policies(namespace string) PolicyNamespaceLister { 50 | return policyNamespaceLister{listers.NewNamespaced[*v1alpha1.Policy](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // PolicyNamespaceLister helps list and get Policies. 54 | // All objects returned here must be treated as read-only. 55 | type PolicyNamespaceLister interface { 56 | // List lists all Policies in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1alpha1.Policy, err error) 59 | // Get retrieves the Policy from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1alpha1.Policy, error) 62 | PolicyNamespaceListerExpansion 63 | } 64 | 65 | // policyNamespaceLister implements the PolicyNamespaceLister 66 | // interface. 67 | type policyNamespaceLister struct { 68 | listers.ResourceIndexer[*v1alpha1.Policy] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/utils/errors/reason_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "errors" 21 | "fmt" 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | ) 26 | 27 | func TestIsLabelConflict(t *testing.T) { 28 | testCases := []struct { 29 | name string 30 | err error 31 | expected bool 32 | }{ 33 | { 34 | name: "error contains LabelConflict", 35 | err: fmt.Errorf("this is a LabelConflict error"), 36 | expected: true, 37 | }, 38 | { 39 | name: "error is exactly LabelConflict", 40 | err: errors.New(LabelConflict), 41 | expected: true, 42 | }, 43 | { 44 | name: "error does not contain LabelConflict", 45 | err: fmt.Errorf("some other error"), 46 | expected: false, 47 | }, 48 | { 49 | name: "error is nil", 50 | err: nil, 51 | expected: false, 52 | }, 53 | } 54 | 55 | for _, tc := range testCases { 56 | t.Run(tc.name, func(t *testing.T) { 57 | result := IsLabelConflict(tc.err) 58 | assert.Equal(t, tc.expected, result) 59 | }) 60 | } 61 | } 62 | 63 | func TestIsCuePathNotFound(t *testing.T) { 64 | testCases := []struct { 65 | name string 66 | err error 67 | expected bool 68 | }{ 69 | { 70 | name: "error contains both substrings", 71 | err: fmt.Errorf("failed to lookup value: the path a.b.c does not exist"), 72 | expected: true, 73 | }, 74 | { 75 | name: "error contains only first substring", 76 | err: fmt.Errorf("failed to lookup value"), 77 | expected: false, 78 | }, 79 | { 80 | name: "error contains only second substring", 81 | err: fmt.Errorf("the path does not exist"), 82 | expected: false, 83 | }, 84 | { 85 | name: "error contains neither substring", 86 | err: fmt.Errorf("some other error"), 87 | expected: false, 88 | }, 89 | { 90 | name: "is nil", 91 | err: nil, 92 | expected: false, 93 | }, 94 | } 95 | 96 | for _, tc := range testCases { 97 | t.Run(tc.name, func(t *testing.T) { 98 | result := IsCuePathNotFound(tc.err) 99 | assert.Equal(t, tc.expected, result) 100 | }) 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | const ( 20 | // TopologyPolicyType refers to the type of topology policy 21 | TopologyPolicyType = "topology" 22 | // OverridePolicyType refers to the type of override policy 23 | OverridePolicyType = "override" 24 | // DebugPolicyType refers to the type of debug policy 25 | DebugPolicyType = "debug" 26 | // ReplicationPolicyType refers to the type of replication policy 27 | ReplicationPolicyType = "replication" 28 | ) 29 | 30 | // TopologyPolicySpec defines the spec of topology policy 31 | type TopologyPolicySpec struct { 32 | // Placement embeds the selectors for choosing cluster 33 | Placement `json:",inline"` 34 | // Namespace is the target namespace to deploy in the selected clusters. 35 | // +optional 36 | Namespace string `json:"namespace,omitempty"` 37 | } 38 | 39 | // Placement describes which clusters to be selected in this topology 40 | type Placement struct { 41 | // Clusters is the names of the clusters to select. 42 | Clusters []string `json:"clusters,omitempty"` 43 | 44 | // ClusterLabelSelector is the label selector for clusters. 45 | // Exclusive to "clusters" 46 | ClusterLabelSelector map[string]string `json:"clusterLabelSelector,omitempty"` 47 | 48 | // AllowEmpty ignore empty cluster error when no cluster returned for label 49 | // selector 50 | AllowEmpty bool `json:"allowEmpty,omitempty"` 51 | 52 | // DeprecatedClusterSelector is a depreciated alias for ClusterLabelSelector. 53 | // Deprecated: Use clusterLabelSelector instead. 54 | DeprecatedClusterSelector map[string]string `json:"clusterSelector,omitempty"` 55 | } 56 | 57 | // OverridePolicySpec defines the spec of override policy 58 | type OverridePolicySpec struct { 59 | Components []EnvComponentPatch `json:"components,omitempty"` 60 | Selector []string `json:"selector,omitempty"` 61 | } 62 | 63 | // ReplicationPolicySpec defines the spec of replication policy 64 | // Override policy should be used together with replication policy to select the deployment target components 65 | type ReplicationPolicySpec struct { 66 | Keys []string `json:"keys,omitempty"` 67 | // Selector is the subset of selected components which will be replicated. 68 | Selector []string `json:"selector,omitempty"` 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/policy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | import ( 21 | "context" 22 | 23 | v1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // PoliciesGetter has a method to return a PolicyInterface. 32 | // A group's client should implement this interface. 33 | type PoliciesGetter interface { 34 | Policies(namespace string) PolicyInterface 35 | } 36 | 37 | // PolicyInterface has methods to work with Policy resources. 38 | type PolicyInterface interface { 39 | Create(ctx context.Context, policy *v1alpha1.Policy, opts v1.CreateOptions) (*v1alpha1.Policy, error) 40 | Update(ctx context.Context, policy *v1alpha1.Policy, opts v1.UpdateOptions) (*v1alpha1.Policy, error) 41 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 42 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 43 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Policy, error) 44 | List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PolicyList, error) 45 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 46 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Policy, err error) 47 | PolicyExpansion 48 | } 49 | 50 | // policies implements PolicyInterface 51 | type policies struct { 52 | *gentype.ClientWithList[*v1alpha1.Policy, *v1alpha1.PolicyList] 53 | } 54 | 55 | // newPolicies returns a Policies 56 | func newPolicies(c *CoreV1alpha1Client, namespace string) *policies { 57 | return &policies{ 58 | gentype.NewClientWithList[*v1alpha1.Policy, *v1alpha1.PolicyList]( 59 | "policies", 60 | c.RESTClient(), 61 | scheme.ParameterCodec, 62 | namespace, 63 | func() *v1alpha1.Policy { return &v1alpha1.Policy{} }, 64 | func() *v1alpha1.PolicyList { return &v1alpha1.PolicyList{} }), 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/applyonce_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | ) 22 | 23 | const ( 24 | // ApplyOncePolicyType refers to the type of configuration drift policy 25 | ApplyOncePolicyType = "apply-once" 26 | // ApplyOnceStrategyOnAppUpdate policy takes effect on application updating 27 | ApplyOnceStrategyOnAppUpdate ApplyOnceAffectStrategy = "onUpdate" 28 | // ApplyOnceStrategyOnAppStateKeep policy takes effect on application state keep 29 | ApplyOnceStrategyOnAppStateKeep ApplyOnceAffectStrategy = "onStateKeep" 30 | // ApplyOnceStrategyAlways policy takes effect always 31 | ApplyOnceStrategyAlways ApplyOnceAffectStrategy = "always" 32 | ) 33 | 34 | // ApplyOnceAffectStrategy is a string that mark the policy effective stage 35 | type ApplyOnceAffectStrategy string 36 | 37 | // ApplyOncePolicySpec defines the spec of preventing configuration drift 38 | type ApplyOncePolicySpec struct { 39 | Enable bool `json:"enable"` 40 | // +optional 41 | Rules []ApplyOncePolicyRule `json:"rules,omitempty"` 42 | } 43 | 44 | // ApplyOncePolicyRule defines a single apply-once policy rule 45 | type ApplyOncePolicyRule struct { 46 | // +optional 47 | Selector ResourcePolicyRuleSelector `json:"selector,omitempty"` 48 | // +optional 49 | Strategy *ApplyOnceStrategy `json:"strategy,omitempty"` 50 | } 51 | 52 | // ApplyOnceStrategy the strategy for resource path to allow configuration drift 53 | type ApplyOnceStrategy struct { 54 | // Path the specified path that allow configuration drift 55 | // like 'spec.template.spec.containers[0].resources' and '*' means the whole target allow configuration drift 56 | Path []string `json:"path"` 57 | // ApplyOnceAffectStrategy Decide when the strategy will take effect 58 | // like affect:onUpdate/onStateKeep/always 59 | ApplyOnceAffectStrategy ApplyOnceAffectStrategy `json:"affect"` 60 | } 61 | 62 | // Type the type name of the policy 63 | func (in *ApplyOncePolicySpec) Type() string { 64 | return ApplyOncePolicyType 65 | } 66 | 67 | // FindStrategy find apply-once strategy for target resource 68 | func (in *ApplyOncePolicySpec) FindStrategy(manifest *unstructured.Unstructured) *ApplyOnceStrategy { 69 | if !in.Enable { 70 | return nil 71 | } 72 | for _, rule := range in.Rules { 73 | if rule.Selector.Match(manifest) { 74 | return rule.Strategy 75 | } 76 | } 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/resource_policy_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/utils/ptr" 22 | stringslices "k8s.io/utils/strings/slices" 23 | 24 | "github.com/oam-dev/kubevela-core-api/pkg/oam" 25 | ) 26 | 27 | // ResourcePolicyRuleSelector select the targets of the rule 28 | // if multiple conditions are specified, combination logic is AND 29 | type ResourcePolicyRuleSelector struct { 30 | CompNames []string `json:"componentNames,omitempty"` 31 | CompTypes []string `json:"componentTypes,omitempty"` 32 | OAMResourceTypes []string `json:"oamTypes,omitempty"` 33 | TraitTypes []string `json:"traitTypes,omitempty"` 34 | ResourceTypes []string `json:"resourceTypes,omitempty"` 35 | ResourceNames []string `json:"resourceNames,omitempty"` 36 | } 37 | 38 | // Match check if current rule selector match the target resource 39 | // If at least one condition is matched and no other condition failed (could be empty), return true 40 | // Otherwise, return false 41 | func (in *ResourcePolicyRuleSelector) Match(manifest *unstructured.Unstructured) bool { 42 | var compName, compType, oamType, traitType, resourceType, resourceName string 43 | if labels := manifest.GetLabels(); labels != nil { 44 | compName = labels[oam.LabelAppComponent] 45 | compType = labels[oam.WorkloadTypeLabel] 46 | oamType = labels[oam.LabelOAMResourceType] 47 | traitType = labels[oam.TraitTypeLabel] 48 | } 49 | resourceType = manifest.GetKind() 50 | resourceName = manifest.GetName() 51 | match := func(src []string, val string) (found *bool) { 52 | if len(src) == 0 { 53 | return nil 54 | } 55 | return ptr.To(val != "" && stringslices.Contains(src, val)) 56 | } 57 | conditions := []*bool{ 58 | match(in.CompNames, compName), 59 | match(in.CompTypes, compType), 60 | match(in.OAMResourceTypes, oamType), 61 | match(in.TraitTypes, traitType), 62 | match(in.ResourceTypes, resourceType), 63 | match(in.ResourceNames, resourceName), 64 | } 65 | hasMatched := false 66 | for _, cond := range conditions { 67 | // if any non-empty condition failed, return false 68 | if cond != nil && !*cond { 69 | return false 70 | } 71 | // if condition succeed, record it 72 | if cond != nil && *cond { 73 | hasMatched = true 74 | } 75 | } 76 | // if at least one condition is met, return true 77 | return hasMatched 78 | } 79 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/application.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // ApplicationLister helps list Applications. 28 | // All objects returned here must be treated as read-only. 29 | type ApplicationLister interface { 30 | // List lists all Applications in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.Application, err error) 33 | // Applications returns an object that can list and get Applications. 34 | Applications(namespace string) ApplicationNamespaceLister 35 | ApplicationListerExpansion 36 | } 37 | 38 | // applicationLister implements the ApplicationLister interface. 39 | type applicationLister struct { 40 | listers.ResourceIndexer[*v1beta1.Application] 41 | } 42 | 43 | // NewApplicationLister returns a new ApplicationLister. 44 | func NewApplicationLister(indexer cache.Indexer) ApplicationLister { 45 | return &applicationLister{listers.New[*v1beta1.Application](indexer, v1beta1.Resource("application"))} 46 | } 47 | 48 | // Applications returns an object that can list and get Applications. 49 | func (s *applicationLister) Applications(namespace string) ApplicationNamespaceLister { 50 | return applicationNamespaceLister{listers.NewNamespaced[*v1beta1.Application](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // ApplicationNamespaceLister helps list and get Applications. 54 | // All objects returned here must be treated as read-only. 55 | type ApplicationNamespaceLister interface { 56 | // List lists all Applications in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.Application, err error) 59 | // Get retrieves the Application from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.Application, error) 62 | ApplicationNamespaceListerExpansion 63 | } 64 | 65 | // applicationNamespaceLister implements the ApplicationNamespaceLister 66 | // interface. 67 | type applicationNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.Application] 69 | } 70 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/definitionrevision_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | 22 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 23 | ) 24 | 25 | // DefinitionRevisionSpec is the spec of DefinitionRevision 26 | type DefinitionRevisionSpec struct { 27 | // Revision record revision number of DefinitionRevision 28 | Revision int64 `json:"revision"` 29 | 30 | // RevisionHash record the hash value of the spec of DefinitionRevision object. 31 | RevisionHash string `json:"revisionHash"` 32 | 33 | // DefinitionType 34 | DefinitionType common.DefinitionType `json:"definitionType"` 35 | 36 | // ComponentDefinition records the snapshot of the created/modified ComponentDefinition 37 | ComponentDefinition ComponentDefinition `json:"componentDefinition,omitempty"` 38 | 39 | // TraitDefinition records the snapshot of the created/modified TraitDefinition 40 | TraitDefinition TraitDefinition `json:"traitDefinition,omitempty"` 41 | 42 | // PolicyDefinition records the snapshot of the created/modified PolicyDefinition 43 | PolicyDefinition PolicyDefinition `json:"policyDefinition,omitempty"` 44 | 45 | // WorkflowStepDefinition records the snapshot of the created/modified WorkflowStepDefinition 46 | WorkflowStepDefinition WorkflowStepDefinition `json:"workflowStepDefinition,omitempty"` 47 | } 48 | 49 | // +kubebuilder:object:root=true 50 | 51 | // DefinitionRevision is the Schema for the DefinitionRevision API 52 | // +kubebuilder:resource:scope=Namespaced,categories={oam},shortName=defrev 53 | // +kubebuilder:printcolumn:name="REVISION",type=integer,JSONPath=".spec.revision" 54 | // +kubebuilder:printcolumn:name="HASH",type=string,JSONPath=".spec.revisionHash" 55 | // +kubebuilder:printcolumn:name="TYPE",type=string,JSONPath=".spec.definitionType" 56 | // +genclient 57 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 58 | type DefinitionRevision struct { 59 | metav1.TypeMeta `json:",inline"` 60 | metav1.ObjectMeta `json:"metadata,omitempty"` 61 | 62 | Spec DefinitionRevisionSpec `json:"spec,omitempty"` 63 | } 64 | 65 | // +kubebuilder:object:root=true 66 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 67 | 68 | // DefinitionRevisionList contains a list of DefinitionRevision 69 | type DefinitionRevisionList struct { 70 | metav1.TypeMeta `json:",inline"` 71 | metav1.ListMeta `json:"metadata,omitempty"` 72 | Items []DefinitionRevision `json:"items"` 73 | } 74 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/resourcetracker.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // ResourceTrackerLister helps list ResourceTrackers. 28 | // All objects returned here must be treated as read-only. 29 | type ResourceTrackerLister interface { 30 | // List lists all ResourceTrackers in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.ResourceTracker, err error) 33 | // ResourceTrackers returns an object that can list and get ResourceTrackers. 34 | ResourceTrackers(namespace string) ResourceTrackerNamespaceLister 35 | ResourceTrackerListerExpansion 36 | } 37 | 38 | // resourceTrackerLister implements the ResourceTrackerLister interface. 39 | type resourceTrackerLister struct { 40 | listers.ResourceIndexer[*v1beta1.ResourceTracker] 41 | } 42 | 43 | // NewResourceTrackerLister returns a new ResourceTrackerLister. 44 | func NewResourceTrackerLister(indexer cache.Indexer) ResourceTrackerLister { 45 | return &resourceTrackerLister{listers.New[*v1beta1.ResourceTracker](indexer, v1beta1.Resource("resourcetracker"))} 46 | } 47 | 48 | // ResourceTrackers returns an object that can list and get ResourceTrackers. 49 | func (s *resourceTrackerLister) ResourceTrackers(namespace string) ResourceTrackerNamespaceLister { 50 | return resourceTrackerNamespaceLister{listers.NewNamespaced[*v1beta1.ResourceTracker](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // ResourceTrackerNamespaceLister helps list and get ResourceTrackers. 54 | // All objects returned here must be treated as read-only. 55 | type ResourceTrackerNamespaceLister interface { 56 | // List lists all ResourceTrackers in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.ResourceTracker, err error) 59 | // Get retrieves the ResourceTracker from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.ResourceTracker, error) 62 | ResourceTrackerNamespaceListerExpansion 63 | } 64 | 65 | // resourceTrackerNamespaceLister implements the ResourceTrackerNamespaceLister 66 | // interface. 67 | type resourceTrackerNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.ResourceTracker] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/traitdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // TraitDefinitionLister helps list TraitDefinitions. 28 | // All objects returned here must be treated as read-only. 29 | type TraitDefinitionLister interface { 30 | // List lists all TraitDefinitions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.TraitDefinition, err error) 33 | // TraitDefinitions returns an object that can list and get TraitDefinitions. 34 | TraitDefinitions(namespace string) TraitDefinitionNamespaceLister 35 | TraitDefinitionListerExpansion 36 | } 37 | 38 | // traitDefinitionLister implements the TraitDefinitionLister interface. 39 | type traitDefinitionLister struct { 40 | listers.ResourceIndexer[*v1beta1.TraitDefinition] 41 | } 42 | 43 | // NewTraitDefinitionLister returns a new TraitDefinitionLister. 44 | func NewTraitDefinitionLister(indexer cache.Indexer) TraitDefinitionLister { 45 | return &traitDefinitionLister{listers.New[*v1beta1.TraitDefinition](indexer, v1beta1.Resource("traitdefinition"))} 46 | } 47 | 48 | // TraitDefinitions returns an object that can list and get TraitDefinitions. 49 | func (s *traitDefinitionLister) TraitDefinitions(namespace string) TraitDefinitionNamespaceLister { 50 | return traitDefinitionNamespaceLister{listers.NewNamespaced[*v1beta1.TraitDefinition](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // TraitDefinitionNamespaceLister helps list and get TraitDefinitions. 54 | // All objects returned here must be treated as read-only. 55 | type TraitDefinitionNamespaceLister interface { 56 | // List lists all TraitDefinitions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.TraitDefinition, err error) 59 | // Get retrieves the TraitDefinition from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.TraitDefinition, error) 62 | TraitDefinitionNamespaceListerExpansion 63 | } 64 | 65 | // traitDefinitionNamespaceLister implements the TraitDefinitionNamespaceLister 66 | // interface. 67 | type traitDefinitionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.TraitDefinition] 69 | } 70 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1alpha1/component_types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha1 18 | 19 | const ( 20 | // RefObjectsComponentType refers to the type of ref-objects 21 | RefObjectsComponentType = "ref-objects" 22 | ) 23 | 24 | // RefObjectsComponentSpec defines the spec of ref-objects component 25 | type RefObjectsComponentSpec struct { 26 | // Objects the referrers to the Kubernetes objects 27 | Objects []ObjectReferrer `json:"objects,omitempty"` 28 | // URLs are the links that stores the referred objects 29 | URLs []string `json:"urls,omitempty"` 30 | } 31 | 32 | // ObjectReferrer selects Kubernetes objects 33 | type ObjectReferrer struct { 34 | // ObjectTypeIdentifier identifies the type of referred objects 35 | ObjectTypeIdentifier `json:",inline"` 36 | // ObjectSelector select object by name or labelSelector 37 | ObjectSelector `json:",inline"` 38 | } 39 | 40 | // ObjectTypeIdentifier identifies the scheme of Kubernetes object 41 | type ObjectTypeIdentifier struct { 42 | // Resource is the resource name of the Kubernetes object. 43 | Resource string `json:"resource"` 44 | // Group is the API Group of the Kubernetes object. 45 | Group string `json:"group"` 46 | // LegacyObjectTypeIdentifier is the legacy identifier 47 | // Deprecated: use resource/group instead 48 | LegacyObjectTypeIdentifier `json:",inline"` 49 | } 50 | 51 | // LegacyObjectTypeIdentifier legacy object type identifier 52 | type LegacyObjectTypeIdentifier struct { 53 | // APIVersion is the APIVersion of the Kubernetes object. 54 | APIVersion string `json:"apiVersion"` 55 | // APIVersion is the Kind of the Kubernetes object. 56 | Kind string `json:"kind"` 57 | } 58 | 59 | // ObjectSelector selector for Kubernetes object 60 | type ObjectSelector struct { 61 | // Name is the name of the Kubernetes object. 62 | // If empty, it will inherit the application component's name. 63 | Name string `json:"name,omitempty"` 64 | // Namespace is the namespace for selecting Kubernetes objects. 65 | // If empty, it will inherit the application's namespace. 66 | Namespace string `json:"namespace,omitempty"` 67 | // Cluster is the cluster for selecting Kubernetes objects. 68 | // If empty, it will use the local cluster 69 | Cluster string `json:"cluster,omitempty"` 70 | // LabelSelector selects Kubernetes objects by labels 71 | // Exclusive to "name" 72 | LabelSelector map[string]string `json:"labelSelector,omitempty"` 73 | // DeprecatedLabelSelector a deprecated alias to LabelSelector 74 | // Deprecated: use labelSelector instead. 75 | DeprecatedLabelSelector map[string]string `json:"selector,omitempty"` 76 | } 77 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/resourcetracker.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // ResourceTrackersGetter has a method to return a ResourceTrackerInterface. 32 | // A group's client should implement this interface. 33 | type ResourceTrackersGetter interface { 34 | ResourceTrackers(namespace string) ResourceTrackerInterface 35 | } 36 | 37 | // ResourceTrackerInterface has methods to work with ResourceTracker resources. 38 | type ResourceTrackerInterface interface { 39 | Create(ctx context.Context, resourceTracker *v1beta1.ResourceTracker, opts v1.CreateOptions) (*v1beta1.ResourceTracker, error) 40 | Update(ctx context.Context, resourceTracker *v1beta1.ResourceTracker, opts v1.UpdateOptions) (*v1beta1.ResourceTracker, error) 41 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 42 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 43 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ResourceTracker, error) 44 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ResourceTrackerList, error) 45 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 46 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ResourceTracker, err error) 47 | ResourceTrackerExpansion 48 | } 49 | 50 | // resourceTrackers implements ResourceTrackerInterface 51 | type resourceTrackers struct { 52 | *gentype.ClientWithList[*v1beta1.ResourceTracker, *v1beta1.ResourceTrackerList] 53 | } 54 | 55 | // newResourceTrackers returns a ResourceTrackers 56 | func newResourceTrackers(c *CoreV1beta1Client, namespace string) *resourceTrackers { 57 | return &resourceTrackers{ 58 | gentype.NewClientWithList[*v1beta1.ResourceTracker, *v1beta1.ResourceTrackerList]( 59 | "resourcetrackers", 60 | c.RESTClient(), 61 | scheme.ParameterCodec, 62 | namespace, 63 | func() *v1beta1.ResourceTracker { return &v1beta1.ResourceTracker{} }, 64 | func() *v1beta1.ResourceTrackerList { return &v1beta1.ResourceTrackerList{} }), 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/policydefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // PolicyDefinitionLister helps list PolicyDefinitions. 28 | // All objects returned here must be treated as read-only. 29 | type PolicyDefinitionLister interface { 30 | // List lists all PolicyDefinitions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.PolicyDefinition, err error) 33 | // PolicyDefinitions returns an object that can list and get PolicyDefinitions. 34 | PolicyDefinitions(namespace string) PolicyDefinitionNamespaceLister 35 | PolicyDefinitionListerExpansion 36 | } 37 | 38 | // policyDefinitionLister implements the PolicyDefinitionLister interface. 39 | type policyDefinitionLister struct { 40 | listers.ResourceIndexer[*v1beta1.PolicyDefinition] 41 | } 42 | 43 | // NewPolicyDefinitionLister returns a new PolicyDefinitionLister. 44 | func NewPolicyDefinitionLister(indexer cache.Indexer) PolicyDefinitionLister { 45 | return &policyDefinitionLister{listers.New[*v1beta1.PolicyDefinition](indexer, v1beta1.Resource("policydefinition"))} 46 | } 47 | 48 | // PolicyDefinitions returns an object that can list and get PolicyDefinitions. 49 | func (s *policyDefinitionLister) PolicyDefinitions(namespace string) PolicyDefinitionNamespaceLister { 50 | return policyDefinitionNamespaceLister{listers.NewNamespaced[*v1beta1.PolicyDefinition](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // PolicyDefinitionNamespaceLister helps list and get PolicyDefinitions. 54 | // All objects returned here must be treated as read-only. 55 | type PolicyDefinitionNamespaceLister interface { 56 | // List lists all PolicyDefinitions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.PolicyDefinition, err error) 59 | // Get retrieves the PolicyDefinition from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.PolicyDefinition, error) 62 | PolicyDefinitionNamespaceListerExpansion 63 | } 64 | 65 | // policyDefinitionNamespaceLister implements the PolicyDefinitionNamespaceLister 66 | // interface. 67 | type policyDefinitionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.PolicyDefinition] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/application.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // ApplicationsGetter has a method to return a ApplicationInterface. 32 | // A group's client should implement this interface. 33 | type ApplicationsGetter interface { 34 | Applications(namespace string) ApplicationInterface 35 | } 36 | 37 | // ApplicationInterface has methods to work with Application resources. 38 | type ApplicationInterface interface { 39 | Create(ctx context.Context, application *v1beta1.Application, opts v1.CreateOptions) (*v1beta1.Application, error) 40 | Update(ctx context.Context, application *v1beta1.Application, opts v1.UpdateOptions) (*v1beta1.Application, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, application *v1beta1.Application, opts v1.UpdateOptions) (*v1beta1.Application, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Application, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ApplicationList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Application, err error) 49 | ApplicationExpansion 50 | } 51 | 52 | // applications implements ApplicationInterface 53 | type applications struct { 54 | *gentype.ClientWithList[*v1beta1.Application, *v1beta1.ApplicationList] 55 | } 56 | 57 | // newApplications returns a Applications 58 | func newApplications(c *CoreV1beta1Client, namespace string) *applications { 59 | return &applications{ 60 | gentype.NewClientWithList[*v1beta1.Application, *v1beta1.ApplicationList]( 61 | "applications", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.Application { return &v1beta1.Application{} }, 66 | func() *v1beta1.ApplicationList { return &v1beta1.ApplicationList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/definitionrevision.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // DefinitionRevisionsGetter has a method to return a DefinitionRevisionInterface. 32 | // A group's client should implement this interface. 33 | type DefinitionRevisionsGetter interface { 34 | DefinitionRevisions(namespace string) DefinitionRevisionInterface 35 | } 36 | 37 | // DefinitionRevisionInterface has methods to work with DefinitionRevision resources. 38 | type DefinitionRevisionInterface interface { 39 | Create(ctx context.Context, definitionRevision *v1beta1.DefinitionRevision, opts v1.CreateOptions) (*v1beta1.DefinitionRevision, error) 40 | Update(ctx context.Context, definitionRevision *v1beta1.DefinitionRevision, opts v1.UpdateOptions) (*v1beta1.DefinitionRevision, error) 41 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 42 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 43 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.DefinitionRevision, error) 44 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DefinitionRevisionList, error) 45 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 46 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DefinitionRevision, err error) 47 | DefinitionRevisionExpansion 48 | } 49 | 50 | // definitionRevisions implements DefinitionRevisionInterface 51 | type definitionRevisions struct { 52 | *gentype.ClientWithList[*v1beta1.DefinitionRevision, *v1beta1.DefinitionRevisionList] 53 | } 54 | 55 | // newDefinitionRevisions returns a DefinitionRevisions 56 | func newDefinitionRevisions(c *CoreV1beta1Client, namespace string) *definitionRevisions { 57 | return &definitionRevisions{ 58 | gentype.NewClientWithList[*v1beta1.DefinitionRevision, *v1beta1.DefinitionRevisionList]( 59 | "definitionrevisions", 60 | c.RESTClient(), 61 | scheme.ParameterCodec, 62 | namespace, 63 | func() *v1beta1.DefinitionRevision { return &v1beta1.DefinitionRevision{} }, 64 | func() *v1beta1.DefinitionRevisionList { return &v1beta1.DefinitionRevisionList{} }), 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/definitionrevision.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // DefinitionRevisionLister helps list DefinitionRevisions. 28 | // All objects returned here must be treated as read-only. 29 | type DefinitionRevisionLister interface { 30 | // List lists all DefinitionRevisions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.DefinitionRevision, err error) 33 | // DefinitionRevisions returns an object that can list and get DefinitionRevisions. 34 | DefinitionRevisions(namespace string) DefinitionRevisionNamespaceLister 35 | DefinitionRevisionListerExpansion 36 | } 37 | 38 | // definitionRevisionLister implements the DefinitionRevisionLister interface. 39 | type definitionRevisionLister struct { 40 | listers.ResourceIndexer[*v1beta1.DefinitionRevision] 41 | } 42 | 43 | // NewDefinitionRevisionLister returns a new DefinitionRevisionLister. 44 | func NewDefinitionRevisionLister(indexer cache.Indexer) DefinitionRevisionLister { 45 | return &definitionRevisionLister{listers.New[*v1beta1.DefinitionRevision](indexer, v1beta1.Resource("definitionrevision"))} 46 | } 47 | 48 | // DefinitionRevisions returns an object that can list and get DefinitionRevisions. 49 | func (s *definitionRevisionLister) DefinitionRevisions(namespace string) DefinitionRevisionNamespaceLister { 50 | return definitionRevisionNamespaceLister{listers.NewNamespaced[*v1beta1.DefinitionRevision](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // DefinitionRevisionNamespaceLister helps list and get DefinitionRevisions. 54 | // All objects returned here must be treated as read-only. 55 | type DefinitionRevisionNamespaceLister interface { 56 | // List lists all DefinitionRevisions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.DefinitionRevision, err error) 59 | // Get retrieves the DefinitionRevision from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.DefinitionRevision, error) 62 | DefinitionRevisionNamespaceListerExpansion 63 | } 64 | 65 | // definitionRevisionNamespaceLister implements the DefinitionRevisionNamespaceLister 66 | // interface. 67 | type definitionRevisionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.DefinitionRevision] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/workloaddefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // WorkloadDefinitionLister helps list WorkloadDefinitions. 28 | // All objects returned here must be treated as read-only. 29 | type WorkloadDefinitionLister interface { 30 | // List lists all WorkloadDefinitions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.WorkloadDefinition, err error) 33 | // WorkloadDefinitions returns an object that can list and get WorkloadDefinitions. 34 | WorkloadDefinitions(namespace string) WorkloadDefinitionNamespaceLister 35 | WorkloadDefinitionListerExpansion 36 | } 37 | 38 | // workloadDefinitionLister implements the WorkloadDefinitionLister interface. 39 | type workloadDefinitionLister struct { 40 | listers.ResourceIndexer[*v1beta1.WorkloadDefinition] 41 | } 42 | 43 | // NewWorkloadDefinitionLister returns a new WorkloadDefinitionLister. 44 | func NewWorkloadDefinitionLister(indexer cache.Indexer) WorkloadDefinitionLister { 45 | return &workloadDefinitionLister{listers.New[*v1beta1.WorkloadDefinition](indexer, v1beta1.Resource("workloaddefinition"))} 46 | } 47 | 48 | // WorkloadDefinitions returns an object that can list and get WorkloadDefinitions. 49 | func (s *workloadDefinitionLister) WorkloadDefinitions(namespace string) WorkloadDefinitionNamespaceLister { 50 | return workloadDefinitionNamespaceLister{listers.NewNamespaced[*v1beta1.WorkloadDefinition](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // WorkloadDefinitionNamespaceLister helps list and get WorkloadDefinitions. 54 | // All objects returned here must be treated as read-only. 55 | type WorkloadDefinitionNamespaceLister interface { 56 | // List lists all WorkloadDefinitions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.WorkloadDefinition, err error) 59 | // Get retrieves the WorkloadDefinition from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.WorkloadDefinition, error) 62 | WorkloadDefinitionNamespaceListerExpansion 63 | } 64 | 65 | // workloadDefinitionNamespaceLister implements the WorkloadDefinitionNamespaceLister 66 | // interface. 67 | type workloadDefinitionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.WorkloadDefinition] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/applicationrevision.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // ApplicationRevisionLister helps list ApplicationRevisions. 28 | // All objects returned here must be treated as read-only. 29 | type ApplicationRevisionLister interface { 30 | // List lists all ApplicationRevisions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.ApplicationRevision, err error) 33 | // ApplicationRevisions returns an object that can list and get ApplicationRevisions. 34 | ApplicationRevisions(namespace string) ApplicationRevisionNamespaceLister 35 | ApplicationRevisionListerExpansion 36 | } 37 | 38 | // applicationRevisionLister implements the ApplicationRevisionLister interface. 39 | type applicationRevisionLister struct { 40 | listers.ResourceIndexer[*v1beta1.ApplicationRevision] 41 | } 42 | 43 | // NewApplicationRevisionLister returns a new ApplicationRevisionLister. 44 | func NewApplicationRevisionLister(indexer cache.Indexer) ApplicationRevisionLister { 45 | return &applicationRevisionLister{listers.New[*v1beta1.ApplicationRevision](indexer, v1beta1.Resource("applicationrevision"))} 46 | } 47 | 48 | // ApplicationRevisions returns an object that can list and get ApplicationRevisions. 49 | func (s *applicationRevisionLister) ApplicationRevisions(namespace string) ApplicationRevisionNamespaceLister { 50 | return applicationRevisionNamespaceLister{listers.NewNamespaced[*v1beta1.ApplicationRevision](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // ApplicationRevisionNamespaceLister helps list and get ApplicationRevisions. 54 | // All objects returned here must be treated as read-only. 55 | type ApplicationRevisionNamespaceLister interface { 56 | // List lists all ApplicationRevisions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.ApplicationRevision, err error) 59 | // Get retrieves the ApplicationRevision from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.ApplicationRevision, error) 62 | ApplicationRevisionNamespaceListerExpansion 63 | } 64 | 65 | // applicationRevisionNamespaceLister implements the ApplicationRevisionNamespaceLister 66 | // interface. 67 | type applicationRevisionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.ApplicationRevision] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/componentdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // ComponentDefinitionLister helps list ComponentDefinitions. 28 | // All objects returned here must be treated as read-only. 29 | type ComponentDefinitionLister interface { 30 | // List lists all ComponentDefinitions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.ComponentDefinition, err error) 33 | // ComponentDefinitions returns an object that can list and get ComponentDefinitions. 34 | ComponentDefinitions(namespace string) ComponentDefinitionNamespaceLister 35 | ComponentDefinitionListerExpansion 36 | } 37 | 38 | // componentDefinitionLister implements the ComponentDefinitionLister interface. 39 | type componentDefinitionLister struct { 40 | listers.ResourceIndexer[*v1beta1.ComponentDefinition] 41 | } 42 | 43 | // NewComponentDefinitionLister returns a new ComponentDefinitionLister. 44 | func NewComponentDefinitionLister(indexer cache.Indexer) ComponentDefinitionLister { 45 | return &componentDefinitionLister{listers.New[*v1beta1.ComponentDefinition](indexer, v1beta1.Resource("componentdefinition"))} 46 | } 47 | 48 | // ComponentDefinitions returns an object that can list and get ComponentDefinitions. 49 | func (s *componentDefinitionLister) ComponentDefinitions(namespace string) ComponentDefinitionNamespaceLister { 50 | return componentDefinitionNamespaceLister{listers.NewNamespaced[*v1beta1.ComponentDefinition](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // ComponentDefinitionNamespaceLister helps list and get ComponentDefinitions. 54 | // All objects returned here must be treated as read-only. 55 | type ComponentDefinitionNamespaceLister interface { 56 | // List lists all ComponentDefinitions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.ComponentDefinition, err error) 59 | // Get retrieves the ComponentDefinition from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.ComponentDefinition, error) 62 | ComponentDefinitionNamespaceListerExpansion 63 | } 64 | 65 | // componentDefinitionNamespaceLister implements the ComponentDefinitionNamespaceLister 66 | // interface. 67 | type componentDefinitionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.ComponentDefinition] 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/traitdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // TraitDefinitionsGetter has a method to return a TraitDefinitionInterface. 32 | // A group's client should implement this interface. 33 | type TraitDefinitionsGetter interface { 34 | TraitDefinitions(namespace string) TraitDefinitionInterface 35 | } 36 | 37 | // TraitDefinitionInterface has methods to work with TraitDefinition resources. 38 | type TraitDefinitionInterface interface { 39 | Create(ctx context.Context, traitDefinition *v1beta1.TraitDefinition, opts v1.CreateOptions) (*v1beta1.TraitDefinition, error) 40 | Update(ctx context.Context, traitDefinition *v1beta1.TraitDefinition, opts v1.UpdateOptions) (*v1beta1.TraitDefinition, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, traitDefinition *v1beta1.TraitDefinition, opts v1.UpdateOptions) (*v1beta1.TraitDefinition, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.TraitDefinition, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.TraitDefinitionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.TraitDefinition, err error) 49 | TraitDefinitionExpansion 50 | } 51 | 52 | // traitDefinitions implements TraitDefinitionInterface 53 | type traitDefinitions struct { 54 | *gentype.ClientWithList[*v1beta1.TraitDefinition, *v1beta1.TraitDefinitionList] 55 | } 56 | 57 | // newTraitDefinitions returns a TraitDefinitions 58 | func newTraitDefinitions(c *CoreV1beta1Client, namespace string) *traitDefinitions { 59 | return &traitDefinitions{ 60 | gentype.NewClientWithList[*v1beta1.TraitDefinition, *v1beta1.TraitDefinitionList]( 61 | "traitdefinitions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.TraitDefinition { return &v1beta1.TraitDefinition{} }, 66 | func() *v1beta1.TraitDefinitionList { return &v1beta1.TraitDefinitionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/policydefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // PolicyDefinitionsGetter has a method to return a PolicyDefinitionInterface. 32 | // A group's client should implement this interface. 33 | type PolicyDefinitionsGetter interface { 34 | PolicyDefinitions(namespace string) PolicyDefinitionInterface 35 | } 36 | 37 | // PolicyDefinitionInterface has methods to work with PolicyDefinition resources. 38 | type PolicyDefinitionInterface interface { 39 | Create(ctx context.Context, policyDefinition *v1beta1.PolicyDefinition, opts v1.CreateOptions) (*v1beta1.PolicyDefinition, error) 40 | Update(ctx context.Context, policyDefinition *v1beta1.PolicyDefinition, opts v1.UpdateOptions) (*v1beta1.PolicyDefinition, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, policyDefinition *v1beta1.PolicyDefinition, opts v1.UpdateOptions) (*v1beta1.PolicyDefinition, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.PolicyDefinition, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PolicyDefinitionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.PolicyDefinition, err error) 49 | PolicyDefinitionExpansion 50 | } 51 | 52 | // policyDefinitions implements PolicyDefinitionInterface 53 | type policyDefinitions struct { 54 | *gentype.ClientWithList[*v1beta1.PolicyDefinition, *v1beta1.PolicyDefinitionList] 55 | } 56 | 57 | // newPolicyDefinitions returns a PolicyDefinitions 58 | func newPolicyDefinitions(c *CoreV1beta1Client, namespace string) *policyDefinitions { 59 | return &policyDefinitions{ 60 | gentype.NewClientWithList[*v1beta1.PolicyDefinition, *v1beta1.PolicyDefinitionList]( 61 | "policydefinitions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.PolicyDefinition { return &v1beta1.PolicyDefinition{} }, 66 | func() *v1beta1.PolicyDefinitionList { return &v1beta1.PolicyDefinitionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/workflowstepdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | "k8s.io/apimachinery/pkg/labels" 23 | "k8s.io/client-go/listers" 24 | "k8s.io/client-go/tools/cache" 25 | ) 26 | 27 | // WorkflowStepDefinitionLister helps list WorkflowStepDefinitions. 28 | // All objects returned here must be treated as read-only. 29 | type WorkflowStepDefinitionLister interface { 30 | // List lists all WorkflowStepDefinitions in the indexer. 31 | // Objects returned here must be treated as read-only. 32 | List(selector labels.Selector) (ret []*v1beta1.WorkflowStepDefinition, err error) 33 | // WorkflowStepDefinitions returns an object that can list and get WorkflowStepDefinitions. 34 | WorkflowStepDefinitions(namespace string) WorkflowStepDefinitionNamespaceLister 35 | WorkflowStepDefinitionListerExpansion 36 | } 37 | 38 | // workflowStepDefinitionLister implements the WorkflowStepDefinitionLister interface. 39 | type workflowStepDefinitionLister struct { 40 | listers.ResourceIndexer[*v1beta1.WorkflowStepDefinition] 41 | } 42 | 43 | // NewWorkflowStepDefinitionLister returns a new WorkflowStepDefinitionLister. 44 | func NewWorkflowStepDefinitionLister(indexer cache.Indexer) WorkflowStepDefinitionLister { 45 | return &workflowStepDefinitionLister{listers.New[*v1beta1.WorkflowStepDefinition](indexer, v1beta1.Resource("workflowstepdefinition"))} 46 | } 47 | 48 | // WorkflowStepDefinitions returns an object that can list and get WorkflowStepDefinitions. 49 | func (s *workflowStepDefinitionLister) WorkflowStepDefinitions(namespace string) WorkflowStepDefinitionNamespaceLister { 50 | return workflowStepDefinitionNamespaceLister{listers.NewNamespaced[*v1beta1.WorkflowStepDefinition](s.ResourceIndexer, namespace)} 51 | } 52 | 53 | // WorkflowStepDefinitionNamespaceLister helps list and get WorkflowStepDefinitions. 54 | // All objects returned here must be treated as read-only. 55 | type WorkflowStepDefinitionNamespaceLister interface { 56 | // List lists all WorkflowStepDefinitions in the indexer for a given namespace. 57 | // Objects returned here must be treated as read-only. 58 | List(selector labels.Selector) (ret []*v1beta1.WorkflowStepDefinition, err error) 59 | // Get retrieves the WorkflowStepDefinition from the indexer for a given namespace and name. 60 | // Objects returned here must be treated as read-only. 61 | Get(name string) (*v1beta1.WorkflowStepDefinition, error) 62 | WorkflowStepDefinitionNamespaceListerExpansion 63 | } 64 | 65 | // workflowStepDefinitionNamespaceLister implements the WorkflowStepDefinitionNamespaceLister 66 | // interface. 67 | type workflowStepDefinitionNamespaceLister struct { 68 | listers.ResourceIndexer[*v1beta1.WorkflowStepDefinition] 69 | } 70 | -------------------------------------------------------------------------------- /test/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log" 6 | 7 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 8 | "k8s.io/apimachinery/pkg/runtime" 9 | ctrl "sigs.k8s.io/controller-runtime" 10 | "sigs.k8s.io/controller-runtime/pkg/client" 11 | 12 | core_oam_dev "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev" 13 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 14 | core_v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 15 | "github.com/oam-dev/kubevela-core-api/pkg/oam/util" 16 | ) 17 | 18 | var scheme = runtime.NewScheme() 19 | 20 | func init() { 21 | _ = core_oam_dev.AddToScheme(scheme) 22 | } 23 | 24 | func main() { 25 | k8sClient, err := client.New(ctrl.GetConfigOrDie(), client.Options{Scheme: scheme}) 26 | if err != nil { 27 | log.Fatal(err) 28 | } 29 | err = k8sClient.Create(context.Background(), &core_v1beta1.ComponentDefinition{ 30 | TypeMeta: metav1.TypeMeta{ 31 | Kind: "ComponentDefinition", 32 | APIVersion: "core.oam.dev/v1beta1", 33 | }, 34 | ObjectMeta: metav1.ObjectMeta{ 35 | Name: "test-comp", 36 | Namespace: "vela-system", 37 | }, 38 | Spec: core_v1beta1.ComponentDefinitionSpec{ 39 | Workload: common.WorkloadTypeDescriptor{ 40 | Definition: common.WorkloadGVK{ 41 | Kind: "Deployment", 42 | APIVersion: "apps/v1", 43 | }, 44 | }, 45 | Schematic: &common.Schematic{ 46 | CUE: &common.CUE{ 47 | Template: webServiceTemplate, 48 | }, 49 | }, 50 | }, 51 | }) 52 | 53 | if err != nil { 54 | log.Fatal(err) 55 | } 56 | 57 | err = k8sClient.Create(context.Background(), &core_v1beta1.Application{ 58 | TypeMeta: metav1.TypeMeta{ 59 | Kind: "Application", 60 | APIVersion: "core.oam.dev/v1beta1", 61 | }, 62 | ObjectMeta: metav1.ObjectMeta{ 63 | Name: "test-app", 64 | Namespace: "default", 65 | }, 66 | Spec: core_v1beta1.ApplicationSpec{ 67 | Components: []common.ApplicationComponent{ 68 | { 69 | Name: "web", 70 | Type: "webservice", 71 | Properties: util.Object2RawExtension(map[string]interface{}{ 72 | "image": "nginx:1.14.0", 73 | }), 74 | Traits: []common.ApplicationTrait{ 75 | { 76 | Type: "labels", 77 | Properties: util.Object2RawExtension(map[string]interface{}{ 78 | "hello": "world", 79 | }), 80 | }, 81 | }, 82 | }, 83 | }, 84 | }, 85 | }) 86 | if err != nil { 87 | log.Fatal(err) 88 | } 89 | } 90 | 91 | var webServiceTemplate = `output: { 92 | apiVersion: "apps/v1" 93 | kind: "Deployment" 94 | metadata: labels: { 95 | "componentdefinition.oam.dev/version": "v1" 96 | } 97 | spec: { 98 | selector: matchLabels: { 99 | "app.oam.dev/component": context.name 100 | } 101 | template: { 102 | metadata: labels: { 103 | "app.oam.dev/component": context.name 104 | } 105 | spec: { 106 | containers: [{ 107 | name: context.name 108 | image: parameter.image 109 | if parameter["cmd"] != _|_ { 110 | command: parameter.cmd 111 | } 112 | if context["config"] != _|_ { 113 | env: context.config 114 | } 115 | ports: [{ 116 | containerPort: parameter.port 117 | }] 118 | }] 119 | } 120 | } 121 | } 122 | } 123 | parameter: { 124 | image: string 125 | cmd?: [...string] 126 | port: *80 | int 127 | } 128 | ` 129 | -------------------------------------------------------------------------------- /pkg/oam/auxiliary.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package oam 18 | 19 | import ( 20 | "time" 21 | 22 | "github.com/crossplane/crossplane-runtime/pkg/meta" 23 | "sigs.k8s.io/controller-runtime/pkg/client" 24 | ) 25 | 26 | // SetCluster add cluster label to object 27 | func SetCluster(o client.Object, clusterName string) { 28 | meta.AddLabels(o, map[string]string{LabelAppCluster: clusterName}) 29 | } 30 | 31 | // SetClusterIfEmpty set cluster label to object if the label is empty 32 | func SetClusterIfEmpty(o client.Object, clusterName string) { 33 | if GetCluster(o) == "" { 34 | SetCluster(o, clusterName) 35 | } 36 | } 37 | 38 | // GetCluster get cluster from object 39 | func GetCluster(o client.Object) string { 40 | if labels := o.GetLabels(); labels != nil { 41 | return labels[LabelAppCluster] 42 | } 43 | return "" 44 | } 45 | 46 | // GetPublishVersion get PublishVersion from object 47 | func GetPublishVersion(o client.Object) string { 48 | if annotations := o.GetAnnotations(); annotations != nil { 49 | return annotations[AnnotationPublishVersion] 50 | } 51 | return "" 52 | } 53 | 54 | // GetDeployVersion get DeployVersion from object 55 | func GetDeployVersion(o client.Object) string { 56 | if annotations := o.GetAnnotations(); annotations != nil { 57 | return annotations[AnnotationDeployVersion] 58 | } 59 | return "" 60 | } 61 | 62 | // GetLastAppliedTime . 63 | func GetLastAppliedTime(o client.Object) time.Time { 64 | if annotations := o.GetAnnotations(); annotations != nil { 65 | s := annotations[AnnotationLastAppliedTime] 66 | if t, err := time.Parse(time.RFC3339, s); err == nil { 67 | return t 68 | } 69 | } 70 | return o.GetCreationTimestamp().Time 71 | } 72 | 73 | // SetPublishVersion set PublishVersion for object 74 | func SetPublishVersion(o client.Object, publishVersion string) { 75 | annotations := o.GetAnnotations() 76 | if annotations == nil { 77 | annotations = map[string]string{} 78 | } 79 | annotations[AnnotationPublishVersion] = publishVersion 80 | o.SetAnnotations(annotations) 81 | } 82 | 83 | // GetControllerRequirement get ControllerRequirement from object 84 | func GetControllerRequirement(o client.Object) string { 85 | if annotations := o.GetAnnotations(); annotations != nil { 86 | return annotations[AnnotationControllerRequirement] 87 | } 88 | return "" 89 | } 90 | 91 | // SetControllerRequirement set ControllerRequirement for object 92 | func SetControllerRequirement(o client.Object, controllerRequirement string) { 93 | annotations := o.GetAnnotations() 94 | if annotations == nil { 95 | annotations = map[string]string{} 96 | } 97 | annotations[AnnotationControllerRequirement] = controllerRequirement 98 | if controllerRequirement == "" { 99 | delete(annotations, AnnotationControllerRequirement) 100 | } 101 | o.SetAnnotations(annotations) 102 | } 103 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/workloaddefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // WorkloadDefinitionsGetter has a method to return a WorkloadDefinitionInterface. 32 | // A group's client should implement this interface. 33 | type WorkloadDefinitionsGetter interface { 34 | WorkloadDefinitions(namespace string) WorkloadDefinitionInterface 35 | } 36 | 37 | // WorkloadDefinitionInterface has methods to work with WorkloadDefinition resources. 38 | type WorkloadDefinitionInterface interface { 39 | Create(ctx context.Context, workloadDefinition *v1beta1.WorkloadDefinition, opts v1.CreateOptions) (*v1beta1.WorkloadDefinition, error) 40 | Update(ctx context.Context, workloadDefinition *v1beta1.WorkloadDefinition, opts v1.UpdateOptions) (*v1beta1.WorkloadDefinition, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, workloadDefinition *v1beta1.WorkloadDefinition, opts v1.UpdateOptions) (*v1beta1.WorkloadDefinition, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.WorkloadDefinition, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.WorkloadDefinitionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.WorkloadDefinition, err error) 49 | WorkloadDefinitionExpansion 50 | } 51 | 52 | // workloadDefinitions implements WorkloadDefinitionInterface 53 | type workloadDefinitions struct { 54 | *gentype.ClientWithList[*v1beta1.WorkloadDefinition, *v1beta1.WorkloadDefinitionList] 55 | } 56 | 57 | // newWorkloadDefinitions returns a WorkloadDefinitions 58 | func newWorkloadDefinitions(c *CoreV1beta1Client, namespace string) *workloadDefinitions { 59 | return &workloadDefinitions{ 60 | gentype.NewClientWithList[*v1beta1.WorkloadDefinition, *v1beta1.WorkloadDefinitionList]( 61 | "workloaddefinitions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.WorkloadDefinition { return &v1beta1.WorkloadDefinition{} }, 66 | func() *v1beta1.WorkloadDefinitionList { return &v1beta1.WorkloadDefinitionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/workflow_step_definition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | 22 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | 24 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 25 | ) 26 | 27 | // WorkflowStepDefinitionSpec defines the desired state of WorkflowStepDefinition 28 | type WorkflowStepDefinitionSpec struct { 29 | // Reference to the CustomResourceDefinition that defines this trait kind. 30 | Reference common.DefinitionReference `json:"definitionRef,omitempty"` 31 | 32 | // Schematic defines the data format and template of the encapsulation of the workflow step definition. 33 | // Only CUE schematic is supported for now. 34 | // +optional 35 | Schematic *common.Schematic `json:"schematic,omitempty"` 36 | 37 | // +optional 38 | Version string `json:"version,omitempty"` 39 | } 40 | 41 | // WorkflowStepDefinitionStatus is the status of WorkflowStepDefinition 42 | type WorkflowStepDefinitionStatus struct { 43 | // ConditionedStatus reflects the observed status of a resource 44 | condition.ConditionedStatus `json:",inline"` 45 | // ConfigMapRef refer to a ConfigMap which contains OpenAPI V3 JSON schema of Component parameters. 46 | ConfigMapRef string `json:"configMapRef,omitempty"` 47 | // LatestRevision of the component definition 48 | // +optional 49 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 50 | } 51 | 52 | // SetConditions set condition for WorkflowStepDefinition 53 | func (d *WorkflowStepDefinition) SetConditions(c ...condition.Condition) { 54 | d.Status.SetConditions(c...) 55 | } 56 | 57 | // GetCondition gets condition from WorkflowStepDefinition 58 | func (d *WorkflowStepDefinition) GetCondition(conditionType condition.ConditionType) condition.Condition { 59 | return d.Status.GetCondition(conditionType) 60 | } 61 | 62 | // +kubebuilder:object:root=true 63 | 64 | // WorkflowStepDefinition is the Schema for the workflowstepdefinitions API 65 | // +kubebuilder:resource:scope=Namespaced,categories={oam},shortName=workflowstep 66 | // +kubebuilder:storageversion 67 | // +kubebuilder:subresource:status 68 | // +genclient 69 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 70 | type WorkflowStepDefinition struct { 71 | metav1.TypeMeta `json:",inline"` 72 | metav1.ObjectMeta `json:"metadata,omitempty"` 73 | 74 | Spec WorkflowStepDefinitionSpec `json:"spec,omitempty"` 75 | Status WorkflowStepDefinitionStatus `json:"status,omitempty"` 76 | } 77 | 78 | // +kubebuilder:object:root=true 79 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 80 | 81 | // WorkflowStepDefinitionList contains a list of WorkflowStepDefinition 82 | type WorkflowStepDefinitionList struct { 83 | metav1.TypeMeta `json:",inline"` 84 | metav1.ListMeta `json:"metadata,omitempty"` 85 | Items []WorkflowStepDefinition `json:"items"` 86 | } 87 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/applicationrevision.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // ApplicationRevisionsGetter has a method to return a ApplicationRevisionInterface. 32 | // A group's client should implement this interface. 33 | type ApplicationRevisionsGetter interface { 34 | ApplicationRevisions(namespace string) ApplicationRevisionInterface 35 | } 36 | 37 | // ApplicationRevisionInterface has methods to work with ApplicationRevision resources. 38 | type ApplicationRevisionInterface interface { 39 | Create(ctx context.Context, applicationRevision *v1beta1.ApplicationRevision, opts v1.CreateOptions) (*v1beta1.ApplicationRevision, error) 40 | Update(ctx context.Context, applicationRevision *v1beta1.ApplicationRevision, opts v1.UpdateOptions) (*v1beta1.ApplicationRevision, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, applicationRevision *v1beta1.ApplicationRevision, opts v1.UpdateOptions) (*v1beta1.ApplicationRevision, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ApplicationRevision, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ApplicationRevisionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ApplicationRevision, err error) 49 | ApplicationRevisionExpansion 50 | } 51 | 52 | // applicationRevisions implements ApplicationRevisionInterface 53 | type applicationRevisions struct { 54 | *gentype.ClientWithList[*v1beta1.ApplicationRevision, *v1beta1.ApplicationRevisionList] 55 | } 56 | 57 | // newApplicationRevisions returns a ApplicationRevisions 58 | func newApplicationRevisions(c *CoreV1beta1Client, namespace string) *applicationRevisions { 59 | return &applicationRevisions{ 60 | gentype.NewClientWithList[*v1beta1.ApplicationRevision, *v1beta1.ApplicationRevisionList]( 61 | "applicationrevisions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.ApplicationRevision { return &v1beta1.ApplicationRevision{} }, 66 | func() *v1beta1.ApplicationRevisionList { return &v1beta1.ApplicationRevisionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/componentdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // ComponentDefinitionsGetter has a method to return a ComponentDefinitionInterface. 32 | // A group's client should implement this interface. 33 | type ComponentDefinitionsGetter interface { 34 | ComponentDefinitions(namespace string) ComponentDefinitionInterface 35 | } 36 | 37 | // ComponentDefinitionInterface has methods to work with ComponentDefinition resources. 38 | type ComponentDefinitionInterface interface { 39 | Create(ctx context.Context, componentDefinition *v1beta1.ComponentDefinition, opts v1.CreateOptions) (*v1beta1.ComponentDefinition, error) 40 | Update(ctx context.Context, componentDefinition *v1beta1.ComponentDefinition, opts v1.UpdateOptions) (*v1beta1.ComponentDefinition, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, componentDefinition *v1beta1.ComponentDefinition, opts v1.UpdateOptions) (*v1beta1.ComponentDefinition, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ComponentDefinition, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ComponentDefinitionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ComponentDefinition, err error) 49 | ComponentDefinitionExpansion 50 | } 51 | 52 | // componentDefinitions implements ComponentDefinitionInterface 53 | type componentDefinitions struct { 54 | *gentype.ClientWithList[*v1beta1.ComponentDefinition, *v1beta1.ComponentDefinitionList] 55 | } 56 | 57 | // newComponentDefinitions returns a ComponentDefinitions 58 | func newComponentDefinitions(c *CoreV1beta1Client, namespace string) *componentDefinitions { 59 | return &componentDefinitions{ 60 | gentype.NewClientWithList[*v1beta1.ComponentDefinition, *v1beta1.ComponentDefinitionList]( 61 | "componentdefinitions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.ComponentDefinition { return &v1beta1.ComponentDefinition{} }, 66 | func() *v1beta1.ComponentDefinitionList { return &v1beta1.ComponentDefinitionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/policy_definition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021. The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | 22 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | 24 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 25 | ) 26 | 27 | // PolicyDefinitionSpec defines the desired state of PolicyDefinition 28 | type PolicyDefinitionSpec struct { 29 | // Reference to the CustomResourceDefinition that defines this trait kind. 30 | Reference common.DefinitionReference `json:"definitionRef,omitempty"` 31 | 32 | // Schematic defines the data format and template of the encapsulation of the policy definition. 33 | // Only CUE schematic is supported for now. 34 | // +optional 35 | Schematic *common.Schematic `json:"schematic,omitempty"` 36 | 37 | // ManageHealthCheck means the policy will handle health checking and skip application controller 38 | // built-in health checking. 39 | ManageHealthCheck bool `json:"manageHealthCheck,omitempty"` 40 | 41 | //+optional 42 | Version string `json:"version,omitempty"` 43 | } 44 | 45 | // PolicyDefinitionStatus is the status of PolicyDefinition 46 | type PolicyDefinitionStatus struct { 47 | // ConditionedStatus reflects the observed status of a resource 48 | condition.ConditionedStatus `json:",inline"` 49 | 50 | // ConfigMapRef refer to a ConfigMap which contains OpenAPI V3 JSON schema of Component parameters. 51 | ConfigMapRef string `json:"configMapRef,omitempty"` 52 | 53 | // LatestRevision of the component definition 54 | // +optional 55 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 56 | } 57 | 58 | // SetConditions set condition for PolicyDefinition 59 | func (d *PolicyDefinition) SetConditions(c ...condition.Condition) { 60 | d.Status.SetConditions(c...) 61 | } 62 | 63 | // GetCondition gets condition from PolicyDefinition 64 | func (d *PolicyDefinition) GetCondition(conditionType condition.ConditionType) condition.Condition { 65 | return d.Status.GetCondition(conditionType) 66 | } 67 | 68 | // +kubebuilder:object:root=true 69 | 70 | // PolicyDefinition is the Schema for the policydefinitions API 71 | // +kubebuilder:resource:scope=Namespaced,categories={oam},shortName=def-policy 72 | // +kubebuilder:storageversion 73 | // +kubebuilder:subresource:status 74 | // +genclient 75 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 76 | type PolicyDefinition struct { 77 | metav1.TypeMeta `json:",inline"` 78 | metav1.ObjectMeta `json:"metadata,omitempty"` 79 | 80 | Spec PolicyDefinitionSpec `json:"spec,omitempty"` 81 | Status PolicyDefinitionStatus `json:"status,omitempty"` 82 | } 83 | 84 | // +kubebuilder:object:root=true 85 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 86 | 87 | // PolicyDefinitionList contains a list of PolicyDefinition 88 | type PolicyDefinitionList struct { 89 | metav1.TypeMeta `json:",inline"` 90 | metav1.ListMeta `json:"metadata,omitempty"` 91 | Items []PolicyDefinition `json:"items"` 92 | } 93 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/workflowstepdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | 23 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | scheme "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | types "k8s.io/apimachinery/pkg/types" 27 | watch "k8s.io/apimachinery/pkg/watch" 28 | gentype "k8s.io/client-go/gentype" 29 | ) 30 | 31 | // WorkflowStepDefinitionsGetter has a method to return a WorkflowStepDefinitionInterface. 32 | // A group's client should implement this interface. 33 | type WorkflowStepDefinitionsGetter interface { 34 | WorkflowStepDefinitions(namespace string) WorkflowStepDefinitionInterface 35 | } 36 | 37 | // WorkflowStepDefinitionInterface has methods to work with WorkflowStepDefinition resources. 38 | type WorkflowStepDefinitionInterface interface { 39 | Create(ctx context.Context, workflowStepDefinition *v1beta1.WorkflowStepDefinition, opts v1.CreateOptions) (*v1beta1.WorkflowStepDefinition, error) 40 | Update(ctx context.Context, workflowStepDefinition *v1beta1.WorkflowStepDefinition, opts v1.UpdateOptions) (*v1beta1.WorkflowStepDefinition, error) 41 | // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 42 | UpdateStatus(ctx context.Context, workflowStepDefinition *v1beta1.WorkflowStepDefinition, opts v1.UpdateOptions) (*v1beta1.WorkflowStepDefinition, error) 43 | Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 44 | DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 45 | Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.WorkflowStepDefinition, error) 46 | List(ctx context.Context, opts v1.ListOptions) (*v1beta1.WorkflowStepDefinitionList, error) 47 | Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 48 | Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.WorkflowStepDefinition, err error) 49 | WorkflowStepDefinitionExpansion 50 | } 51 | 52 | // workflowStepDefinitions implements WorkflowStepDefinitionInterface 53 | type workflowStepDefinitions struct { 54 | *gentype.ClientWithList[*v1beta1.WorkflowStepDefinition, *v1beta1.WorkflowStepDefinitionList] 55 | } 56 | 57 | // newWorkflowStepDefinitions returns a WorkflowStepDefinitions 58 | func newWorkflowStepDefinitions(c *CoreV1beta1Client, namespace string) *workflowStepDefinitions { 59 | return &workflowStepDefinitions{ 60 | gentype.NewClientWithList[*v1beta1.WorkflowStepDefinition, *v1beta1.WorkflowStepDefinitionList]( 61 | "workflowstepdefinitions", 62 | c.RESTClient(), 63 | scheme.ParameterCodec, 64 | namespace, 65 | func() *v1beta1.WorkflowStepDefinition { return &v1beta1.WorkflowStepDefinition{} }, 66 | func() *v1beta1.WorkflowStepDefinitionList { return &v1beta1.WorkflowStepDefinitionList{} }), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/core.oam.dev_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | import ( 21 | "net/http" 22 | 23 | v1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 24 | "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/scheme" 25 | rest "k8s.io/client-go/rest" 26 | ) 27 | 28 | type CoreV1alpha1Interface interface { 29 | RESTClient() rest.Interface 30 | PoliciesGetter 31 | } 32 | 33 | // CoreV1alpha1Client is used to interact with features provided by the core.oam.dev group. 34 | type CoreV1alpha1Client struct { 35 | restClient rest.Interface 36 | } 37 | 38 | func (c *CoreV1alpha1Client) Policies(namespace string) PolicyInterface { 39 | return newPolicies(c, namespace) 40 | } 41 | 42 | // NewForConfig creates a new CoreV1alpha1Client for the given config. 43 | // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), 44 | // where httpClient was generated with rest.HTTPClientFor(c). 45 | func NewForConfig(c *rest.Config) (*CoreV1alpha1Client, error) { 46 | config := *c 47 | if err := setConfigDefaults(&config); err != nil { 48 | return nil, err 49 | } 50 | httpClient, err := rest.HTTPClientFor(&config) 51 | if err != nil { 52 | return nil, err 53 | } 54 | return NewForConfigAndClient(&config, httpClient) 55 | } 56 | 57 | // NewForConfigAndClient creates a new CoreV1alpha1Client for the given config and http client. 58 | // Note the http client provided takes precedence over the configured transport values. 59 | func NewForConfigAndClient(c *rest.Config, h *http.Client) (*CoreV1alpha1Client, error) { 60 | config := *c 61 | if err := setConfigDefaults(&config); err != nil { 62 | return nil, err 63 | } 64 | client, err := rest.RESTClientForConfigAndClient(&config, h) 65 | if err != nil { 66 | return nil, err 67 | } 68 | return &CoreV1alpha1Client{client}, nil 69 | } 70 | 71 | // NewForConfigOrDie creates a new CoreV1alpha1Client for the given config and 72 | // panics if there is an error in the config. 73 | func NewForConfigOrDie(c *rest.Config) *CoreV1alpha1Client { 74 | client, err := NewForConfig(c) 75 | if err != nil { 76 | panic(err) 77 | } 78 | return client 79 | } 80 | 81 | // New creates a new CoreV1alpha1Client for the given RESTClient. 82 | func New(c rest.Interface) *CoreV1alpha1Client { 83 | return &CoreV1alpha1Client{c} 84 | } 85 | 86 | func setConfigDefaults(config *rest.Config) error { 87 | gv := v1alpha1.SchemeGroupVersion 88 | config.GroupVersion = &gv 89 | config.APIPath = "/apis" 90 | config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() 91 | 92 | if config.UserAgent == "" { 93 | config.UserAgent = rest.DefaultKubernetesUserAgent() 94 | } 95 | 96 | return nil 97 | } 98 | 99 | // RESTClient returns a RESTClient that is used to communicate 100 | // with API server by this client implementation. 101 | func (c *CoreV1alpha1Client) RESTClient() rest.Interface { 102 | if c == nil { 103 | return nil 104 | } 105 | return c.restClient 106 | } 107 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/applicationrevision_types_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "encoding/json" 21 | "fmt" 22 | "testing" 23 | 24 | "github.com/kubevela/pkg/util/compression" 25 | "github.com/stretchr/testify/assert" 26 | "k8s.io/apimachinery/pkg/runtime" 27 | 28 | "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 29 | ) 30 | 31 | func TestApplicationRevisionCompression(t *testing.T) { 32 | // Fill data 33 | spec := &ApplicationRevisionSpec{} 34 | spec.Application = Application{Spec: ApplicationSpec{Components: []common.ApplicationComponent{{Name: "test-name"}}}} 35 | spec.ComponentDefinitions = make(map[string]*ComponentDefinition) 36 | spec.ComponentDefinitions["def"] = &ComponentDefinition{Spec: ComponentDefinitionSpec{PodSpecPath: "path"}} 37 | spec.WorkloadDefinitions = make(map[string]WorkloadDefinition) 38 | spec.WorkloadDefinitions["def"] = WorkloadDefinition{Spec: WorkloadDefinitionSpec{Reference: common.DefinitionReference{Name: "testdef"}}} 39 | spec.TraitDefinitions = make(map[string]*TraitDefinition) 40 | spec.TraitDefinitions["def"] = &TraitDefinition{Spec: TraitDefinitionSpec{ControlPlaneOnly: true}} 41 | spec.PolicyDefinitions = make(map[string]PolicyDefinition) 42 | spec.PolicyDefinitions["def"] = PolicyDefinition{Spec: PolicyDefinitionSpec{ManageHealthCheck: true}} 43 | spec.WorkflowStepDefinitions = make(map[string]*WorkflowStepDefinition) 44 | spec.WorkflowStepDefinitions["def"] = &WorkflowStepDefinition{Spec: WorkflowStepDefinitionSpec{Reference: common.DefinitionReference{Name: "testname"}}} 45 | spec.ReferredObjects = []common.ReferredObject{{RawExtension: runtime.RawExtension{Raw: []byte("123")}}} 46 | 47 | testAppRev := &ApplicationRevision{Spec: *spec} 48 | 49 | marshalAndUnmarshal := func(in *ApplicationRevision) (*ApplicationRevision, int) { 50 | out := &ApplicationRevision{} 51 | b, err := json.Marshal(in) 52 | assert.NoError(t, err) 53 | if in.Spec.Compression.Type != compression.Uncompressed { 54 | assert.Contains(t, string(b), fmt.Sprintf("\"type\":\"%s\",\"data\":\"", in.Spec.Compression.Type)) 55 | } 56 | err = json.Unmarshal(b, out) 57 | assert.NoError(t, err) 58 | assert.Equal(t, out.Spec.Compression.Type, in.Spec.Compression.Type) 59 | assert.Equal(t, out.Spec.Compression.Data, "") 60 | return out, len(b) 61 | } 62 | 63 | // uncompressed 64 | testAppRev.Spec.Compression.SetType(compression.Uncompressed) 65 | uncomp, uncompsize := marshalAndUnmarshal(testAppRev) 66 | 67 | // zstd compressed 68 | testAppRev.Spec.Compression.SetType(compression.Zstd) 69 | zstdcomp, zstdsize := marshalAndUnmarshal(testAppRev) 70 | // We will compare content later. Clear compression methods since it will interfere 71 | // comparison and is verified earlier. 72 | zstdcomp.Spec.Compression.SetType(compression.Uncompressed) 73 | 74 | // gzip compressed 75 | testAppRev.Spec.Compression.SetType(compression.Gzip) 76 | gzipcomp, gzipsize := marshalAndUnmarshal(testAppRev) 77 | gzipcomp.Spec.Compression.SetType(compression.Uncompressed) 78 | 79 | assert.Equal(t, uncomp, zstdcomp) 80 | assert.Equal(t, zstdcomp, gzipcomp) 81 | 82 | assert.Less(t, zstdsize, uncompsize) 83 | assert.Less(t, gzipsize, uncompsize) 84 | } 85 | -------------------------------------------------------------------------------- /pkg/generated/client/clientset/versioned/fake/clientset_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by client-gen. DO NOT EDIT. 17 | 18 | package fake 19 | 20 | import ( 21 | clientset "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 22 | corev1alpha1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1" 23 | fakecorev1alpha1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1alpha1/fake" 24 | corev1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1" 25 | fakecorev1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/fake" 26 | "k8s.io/apimachinery/pkg/runtime" 27 | "k8s.io/apimachinery/pkg/watch" 28 | "k8s.io/client-go/discovery" 29 | fakediscovery "k8s.io/client-go/discovery/fake" 30 | "k8s.io/client-go/testing" 31 | ) 32 | 33 | // NewSimpleClientset returns a clientset that will respond with the provided objects. 34 | // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 35 | // without applying any field management, validations and/or defaults. It shouldn't be considered a replacement 36 | // for a real clientset and is mostly useful in simple unit tests. 37 | // 38 | // DEPRECATED: NewClientset replaces this with support for field management, which significantly improves 39 | // server side apply testing. NewClientset is only available when apply configurations are generated (e.g. 40 | // via --with-applyconfig). 41 | func NewSimpleClientset(objects ...runtime.Object) *Clientset { 42 | o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) 43 | for _, obj := range objects { 44 | if err := o.Add(obj); err != nil { 45 | panic(err) 46 | } 47 | } 48 | 49 | cs := &Clientset{tracker: o} 50 | cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} 51 | cs.AddReactor("*", "*", testing.ObjectReaction(o)) 52 | cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 53 | gvr := action.GetResource() 54 | ns := action.GetNamespace() 55 | watch, err := o.Watch(gvr, ns) 56 | if err != nil { 57 | return false, nil, err 58 | } 59 | return true, watch, nil 60 | }) 61 | 62 | return cs 63 | } 64 | 65 | // Clientset implements clientset.Interface. Meant to be embedded into a 66 | // struct to get a default implementation. This makes faking out just the method 67 | // you want to test easier. 68 | type Clientset struct { 69 | testing.Fake 70 | discovery *fakediscovery.FakeDiscovery 71 | tracker testing.ObjectTracker 72 | } 73 | 74 | func (c *Clientset) Discovery() discovery.DiscoveryInterface { 75 | return c.discovery 76 | } 77 | 78 | func (c *Clientset) Tracker() testing.ObjectTracker { 79 | return c.tracker 80 | } 81 | 82 | var ( 83 | _ clientset.Interface = &Clientset{} 84 | _ testing.FakeClient = &Clientset{} 85 | ) 86 | 87 | // CoreV1alpha1 retrieves the CoreV1alpha1Client 88 | func (c *Clientset) CoreV1alpha1() corev1alpha1.CoreV1alpha1Interface { 89 | return &fakecorev1alpha1.FakeCoreV1alpha1{Fake: &c.Fake} 90 | } 91 | 92 | // CoreV1beta1 retrieves the CoreV1beta1Client 93 | func (c *Clientset) CoreV1beta1() corev1beta1.CoreV1beta1Interface { 94 | return &fakecorev1beta1.FakeCoreV1beta1{Fake: &c.Fake} 95 | } 96 | -------------------------------------------------------------------------------- /pkg/generated/client/listers/core.oam.dev/v1beta1/expansion_generated.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by lister-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | // ApplicationListerExpansion allows custom methods to be added to 21 | // ApplicationLister. 22 | type ApplicationListerExpansion interface{} 23 | 24 | // ApplicationNamespaceListerExpansion allows custom methods to be added to 25 | // ApplicationNamespaceLister. 26 | type ApplicationNamespaceListerExpansion interface{} 27 | 28 | // ApplicationRevisionListerExpansion allows custom methods to be added to 29 | // ApplicationRevisionLister. 30 | type ApplicationRevisionListerExpansion interface{} 31 | 32 | // ApplicationRevisionNamespaceListerExpansion allows custom methods to be added to 33 | // ApplicationRevisionNamespaceLister. 34 | type ApplicationRevisionNamespaceListerExpansion interface{} 35 | 36 | // ComponentDefinitionListerExpansion allows custom methods to be added to 37 | // ComponentDefinitionLister. 38 | type ComponentDefinitionListerExpansion interface{} 39 | 40 | // ComponentDefinitionNamespaceListerExpansion allows custom methods to be added to 41 | // ComponentDefinitionNamespaceLister. 42 | type ComponentDefinitionNamespaceListerExpansion interface{} 43 | 44 | // DefinitionRevisionListerExpansion allows custom methods to be added to 45 | // DefinitionRevisionLister. 46 | type DefinitionRevisionListerExpansion interface{} 47 | 48 | // DefinitionRevisionNamespaceListerExpansion allows custom methods to be added to 49 | // DefinitionRevisionNamespaceLister. 50 | type DefinitionRevisionNamespaceListerExpansion interface{} 51 | 52 | // PolicyDefinitionListerExpansion allows custom methods to be added to 53 | // PolicyDefinitionLister. 54 | type PolicyDefinitionListerExpansion interface{} 55 | 56 | // PolicyDefinitionNamespaceListerExpansion allows custom methods to be added to 57 | // PolicyDefinitionNamespaceLister. 58 | type PolicyDefinitionNamespaceListerExpansion interface{} 59 | 60 | // ResourceTrackerListerExpansion allows custom methods to be added to 61 | // ResourceTrackerLister. 62 | type ResourceTrackerListerExpansion interface{} 63 | 64 | // ResourceTrackerNamespaceListerExpansion allows custom methods to be added to 65 | // ResourceTrackerNamespaceLister. 66 | type ResourceTrackerNamespaceListerExpansion interface{} 67 | 68 | // TraitDefinitionListerExpansion allows custom methods to be added to 69 | // TraitDefinitionLister. 70 | type TraitDefinitionListerExpansion interface{} 71 | 72 | // TraitDefinitionNamespaceListerExpansion allows custom methods to be added to 73 | // TraitDefinitionNamespaceLister. 74 | type TraitDefinitionNamespaceListerExpansion interface{} 75 | 76 | // WorkflowStepDefinitionListerExpansion allows custom methods to be added to 77 | // WorkflowStepDefinitionLister. 78 | type WorkflowStepDefinitionListerExpansion interface{} 79 | 80 | // WorkflowStepDefinitionNamespaceListerExpansion allows custom methods to be added to 81 | // WorkflowStepDefinitionNamespaceLister. 82 | type WorkflowStepDefinitionNamespaceListerExpansion interface{} 83 | 84 | // WorkloadDefinitionListerExpansion allows custom methods to be added to 85 | // WorkloadDefinitionLister. 86 | type WorkloadDefinitionListerExpansion interface{} 87 | 88 | // WorkloadDefinitionNamespaceListerExpansion allows custom methods to be added to 89 | // WorkloadDefinitionNamespaceLister. 90 | type WorkloadDefinitionNamespaceListerExpansion interface{} 91 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1alpha1/policy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1alpha1 19 | 20 | import ( 21 | "context" 22 | time "time" 23 | 24 | coreoamdevv1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 25 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 26 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 27 | v1alpha1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/listers/core.oam.dev/v1alpha1" 28 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 | runtime "k8s.io/apimachinery/pkg/runtime" 30 | watch "k8s.io/apimachinery/pkg/watch" 31 | cache "k8s.io/client-go/tools/cache" 32 | ) 33 | 34 | // PolicyInformer provides access to a shared informer and lister for 35 | // Policies. 36 | type PolicyInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1alpha1.PolicyLister 39 | } 40 | 41 | type policyInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewPolicyInformer constructs a new informer for Policy type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredPolicyInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredPolicyInformer constructs a new informer for Policy type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.CoreV1alpha1().Policies(namespace).List(context.TODO(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.CoreV1alpha1().Policies(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1alpha1.Policy{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *policyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *policyInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1alpha1.Policy{}, f.defaultInformer) 85 | } 86 | 87 | func (f *policyInformer) Lister() v1alpha1.PolicyLister { 88 | return v1alpha1.NewPolicyLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /apis/core.oam.dev/v1beta1/register_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2025 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "reflect" 21 | "strings" 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | "k8s.io/apimachinery/pkg/runtime/schema" 26 | ) 27 | 28 | func TestDefinitionTypeMap(t *testing.T) { 29 | tests := []struct { 30 | name string 31 | defType reflect.Type 32 | expectedGVR schema.GroupVersionResource 33 | expectedKind string 34 | }{ 35 | { 36 | name: "ComponentDefinition", 37 | defType: reflect.TypeOf(ComponentDefinition{}), 38 | expectedGVR: ComponentDefinitionGVR, 39 | expectedKind: ComponentDefinitionKind, 40 | }, 41 | { 42 | name: "TraitDefinition", 43 | defType: reflect.TypeOf(TraitDefinition{}), 44 | expectedGVR: TraitDefinitionGVR, 45 | expectedKind: TraitDefinitionKind, 46 | }, 47 | { 48 | name: "PolicyDefinition", 49 | defType: reflect.TypeOf(PolicyDefinition{}), 50 | expectedGVR: PolicyDefinitionGVR, 51 | expectedKind: PolicyDefinitionKind, 52 | }, 53 | { 54 | name: "WorkflowStepDefinition", 55 | defType: reflect.TypeOf(WorkflowStepDefinition{}), 56 | expectedGVR: WorkflowStepDefinitionGVR, 57 | expectedKind: WorkflowStepDefinitionKind, 58 | }, 59 | } 60 | 61 | for _, tt := range tests { 62 | t.Run(tt.name, func(t *testing.T) { 63 | info, ok := DefinitionTypeMap[tt.defType] 64 | assert.Truef(t, ok, "Type %v should exist in DefinitionTypeMap", tt.defType) 65 | assert.Equal(t, tt.expectedGVR, info.GVR) 66 | assert.Equal(t, tt.expectedKind, info.Kind) 67 | 68 | // Verify GVR follows Kubernetes conventions 69 | assert.Equal(t, Group, info.GVR.Group) 70 | assert.Equal(t, Version, info.GVR.Version) 71 | // Resource should be lowercase plural of Kind 72 | assert.Equal(t, strings.ToLower(info.Kind)+"s", info.GVR.Resource) 73 | }) 74 | } 75 | } 76 | 77 | func TestDefinitionTypeMapCompleteness(t *testing.T) { 78 | // Ensure all expected definition types are in the map 79 | expectedTypes := []reflect.Type{ 80 | reflect.TypeOf(ComponentDefinition{}), 81 | reflect.TypeOf(TraitDefinition{}), 82 | reflect.TypeOf(PolicyDefinition{}), 83 | reflect.TypeOf(WorkflowStepDefinition{}), 84 | } 85 | 86 | assert.Equal(t, len(expectedTypes), len(DefinitionTypeMap), "DefinitionTypeMap should contain exactly %d entries", len(expectedTypes)) 87 | 88 | for _, expectedType := range expectedTypes { 89 | _, ok := DefinitionTypeMap[expectedType] 90 | assert.Truef(t, ok, "DefinitionTypeMap should contain %v", expectedType) 91 | } 92 | } 93 | 94 | func TestDefinitionKindValues(t *testing.T) { 95 | // Verify that the Kind values match the actual type names 96 | tests := []struct { 97 | defType interface{} 98 | expectedKind string 99 | }{ 100 | {ComponentDefinition{}, "ComponentDefinition"}, 101 | {TraitDefinition{}, "TraitDefinition"}, 102 | {PolicyDefinition{}, "PolicyDefinition"}, 103 | {WorkflowStepDefinition{}, "WorkflowStepDefinition"}, 104 | } 105 | 106 | for _, tt := range tests { 107 | t.Run(tt.expectedKind, func(t *testing.T) { 108 | actualKind := reflect.TypeOf(tt.defType).Name() 109 | assert.Equal(t, tt.expectedKind, actualKind) 110 | 111 | // Also verify it matches what's in the map 112 | info, ok := DefinitionTypeMap[reflect.TypeOf(tt.defType)] 113 | assert.True(t, ok) 114 | assert.Equal(t, tt.expectedKind, info.Kind) 115 | }) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1/application.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | time "time" 23 | 24 | coreoamdevv1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 26 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 27 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/listers/core.oam.dev/v1beta1" 28 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 | runtime "k8s.io/apimachinery/pkg/runtime" 30 | watch "k8s.io/apimachinery/pkg/watch" 31 | cache "k8s.io/client-go/tools/cache" 32 | ) 33 | 34 | // ApplicationInformer provides access to a shared informer and lister for 35 | // Applications. 36 | type ApplicationInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.ApplicationLister 39 | } 40 | 41 | type applicationInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewApplicationInformer constructs a new informer for Application type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredApplicationInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredApplicationInformer constructs a new informer for Application type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredApplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.CoreV1beta1().Applications(namespace).List(context.TODO(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.CoreV1beta1().Applications(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.Application{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *applicationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredApplicationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *applicationInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.Application{}, f.defaultInformer) 85 | } 86 | 87 | func (f *applicationInformer) Lister() v1beta1.ApplicationLister { 88 | return v1beta1.NewApplicationLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/generic.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package externalversions 19 | 20 | import ( 21 | "fmt" 22 | 23 | v1alpha1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1alpha1" 24 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | cache "k8s.io/client-go/tools/cache" 27 | ) 28 | 29 | // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 30 | // sharedInformers based on type 31 | type GenericInformer interface { 32 | Informer() cache.SharedIndexInformer 33 | Lister() cache.GenericLister 34 | } 35 | 36 | type genericInformer struct { 37 | informer cache.SharedIndexInformer 38 | resource schema.GroupResource 39 | } 40 | 41 | // Informer returns the SharedIndexInformer. 42 | func (f *genericInformer) Informer() cache.SharedIndexInformer { 43 | return f.informer 44 | } 45 | 46 | // Lister returns the GenericLister. 47 | func (f *genericInformer) Lister() cache.GenericLister { 48 | return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 49 | } 50 | 51 | // ForResource gives generic access to a shared informer of the matching type 52 | // TODO extend this to unknown resources with a client pool 53 | func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 54 | switch resource { 55 | // Group=core.oam.dev, Version=v1alpha1 56 | case v1alpha1.SchemeGroupVersion.WithResource("policies"): 57 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1alpha1().Policies().Informer()}, nil 58 | 59 | // Group=core.oam.dev, Version=v1beta1 60 | case v1beta1.SchemeGroupVersion.WithResource("applications"): 61 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().Applications().Informer()}, nil 62 | case v1beta1.SchemeGroupVersion.WithResource("applicationrevisions"): 63 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ApplicationRevisions().Informer()}, nil 64 | case v1beta1.SchemeGroupVersion.WithResource("componentdefinitions"): 65 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ComponentDefinitions().Informer()}, nil 66 | case v1beta1.SchemeGroupVersion.WithResource("definitionrevisions"): 67 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().DefinitionRevisions().Informer()}, nil 68 | case v1beta1.SchemeGroupVersion.WithResource("policydefinitions"): 69 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().PolicyDefinitions().Informer()}, nil 70 | case v1beta1.SchemeGroupVersion.WithResource("resourcetrackers"): 71 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ResourceTrackers().Informer()}, nil 72 | case v1beta1.SchemeGroupVersion.WithResource("traitdefinitions"): 73 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().TraitDefinitions().Informer()}, nil 74 | case v1beta1.SchemeGroupVersion.WithResource("workflowstepdefinitions"): 75 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().WorkflowStepDefinitions().Informer()}, nil 76 | case v1beta1.SchemeGroupVersion.WithResource("workloaddefinitions"): 77 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().WorkloadDefinitions().Informer()}, nil 78 | 79 | } 80 | 81 | return nil, fmt.Errorf("no informer found for %v", resource) 82 | } 83 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1/resourcetracker.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | time "time" 23 | 24 | coreoamdevv1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 26 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 27 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/listers/core.oam.dev/v1beta1" 28 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 | runtime "k8s.io/apimachinery/pkg/runtime" 30 | watch "k8s.io/apimachinery/pkg/watch" 31 | cache "k8s.io/client-go/tools/cache" 32 | ) 33 | 34 | // ResourceTrackerInformer provides access to a shared informer and lister for 35 | // ResourceTrackers. 36 | type ResourceTrackerInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.ResourceTrackerLister 39 | } 40 | 41 | type resourceTrackerInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewResourceTrackerInformer constructs a new informer for ResourceTracker type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewResourceTrackerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredResourceTrackerInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredResourceTrackerInformer constructs a new informer for ResourceTracker type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredResourceTrackerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.CoreV1beta1().ResourceTrackers(namespace).List(context.TODO(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.CoreV1beta1().ResourceTrackers(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.ResourceTracker{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *resourceTrackerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredResourceTrackerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *resourceTrackerInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.ResourceTracker{}, f.defaultInformer) 85 | } 86 | 87 | func (f *resourceTrackerInformer) Lister() v1beta1.ResourceTrackerLister { 88 | return v1beta1.NewResourceTrackerLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1/traitdefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | time "time" 23 | 24 | coreoamdevv1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 26 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 27 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/listers/core.oam.dev/v1beta1" 28 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 | runtime "k8s.io/apimachinery/pkg/runtime" 30 | watch "k8s.io/apimachinery/pkg/watch" 31 | cache "k8s.io/client-go/tools/cache" 32 | ) 33 | 34 | // TraitDefinitionInformer provides access to a shared informer and lister for 35 | // TraitDefinitions. 36 | type TraitDefinitionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.TraitDefinitionLister 39 | } 40 | 41 | type traitDefinitionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewTraitDefinitionInformer constructs a new informer for TraitDefinition type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewTraitDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredTraitDefinitionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredTraitDefinitionInformer constructs a new informer for TraitDefinition type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredTraitDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.CoreV1beta1().TraitDefinitions(namespace).List(context.TODO(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.CoreV1beta1().TraitDefinitions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.TraitDefinition{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *traitDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredTraitDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *traitDefinitionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.TraitDefinition{}, f.defaultInformer) 85 | } 86 | 87 | func (f *traitDefinitionInformer) Lister() v1beta1.TraitDefinitionLister { 88 | return v1beta1.NewTraitDefinitionLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1/policydefinition.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The KubeVela Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | // Code generated by informer-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | "context" 22 | time "time" 23 | 24 | coreoamdevv1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 25 | versioned "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned" 26 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 27 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/listers/core.oam.dev/v1beta1" 28 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 | runtime "k8s.io/apimachinery/pkg/runtime" 30 | watch "k8s.io/apimachinery/pkg/watch" 31 | cache "k8s.io/client-go/tools/cache" 32 | ) 33 | 34 | // PolicyDefinitionInformer provides access to a shared informer and lister for 35 | // PolicyDefinitions. 36 | type PolicyDefinitionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.PolicyDefinitionLister 39 | } 40 | 41 | type policyDefinitionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewPolicyDefinitionInformer constructs a new informer for PolicyDefinition type. 48 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 49 | // one. This reduces memory footprint and number of connections to the server. 50 | func NewPolicyDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredPolicyDefinitionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredPolicyDefinitionInformer constructs a new informer for PolicyDefinition type. 55 | // Always prefer using an informer factory to get a shared informer instead of getting an independent 56 | // one. This reduces memory footprint and number of connections to the server. 57 | func NewFilteredPolicyDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 58 | return cache.NewSharedIndexInformer( 59 | &cache.ListWatch{ 60 | ListFunc: func(options v1.ListOptions) (runtime.Object, error) { 61 | if tweakListOptions != nil { 62 | tweakListOptions(&options) 63 | } 64 | return client.CoreV1beta1().PolicyDefinitions(namespace).List(context.TODO(), options) 65 | }, 66 | WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { 67 | if tweakListOptions != nil { 68 | tweakListOptions(&options) 69 | } 70 | return client.CoreV1beta1().PolicyDefinitions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.PolicyDefinition{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *policyDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredPolicyDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *policyDefinitionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.PolicyDefinition{}, f.defaultInformer) 85 | } 86 | 87 | func (f *policyDefinitionInformer) Lister() v1beta1.PolicyDefinitionLister { 88 | return v1beta1.NewPolicyDefinitionLister(f.Informer().GetIndexer()) 89 | } 90 | --------------------------------------------------------------------------------