├── .github ├── CODEOWNERS └── workflows │ └── go.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── apis ├── apis.go ├── core.oam.dev │ ├── common │ │ ├── doc.go │ │ ├── register.go │ │ ├── types.go │ │ ├── types_test.go │ │ └── zz_generated.deepcopy.go │ ├── condition │ │ ├── condition.go │ │ ├── condition_test.go │ │ ├── doc.go │ │ └── zz_generated.deepcopy.go │ ├── groupversion_info.go │ ├── v1alpha1 │ │ ├── applyonce_policy_types.go │ │ ├── component_types.go │ │ ├── doc.go │ │ ├── envbinding_types.go │ │ ├── external_types.go │ │ ├── garbagecollect_policy_types.go │ │ ├── garbagecollect_policy_types_test.go │ │ ├── policy_types.go │ │ ├── readonly_policy_types.go │ │ ├── register.go │ │ ├── resource_policy_types.go │ │ ├── resource_update_policy_types.go │ │ ├── sharedresource_policy_types.go │ │ ├── sharedresource_policy_types_test.go │ │ ├── takeover_policy_types.go │ │ └── zz_generated.deepcopy.go │ └── v1beta1 │ │ ├── application_types.go │ │ ├── applicationrevision_types.go │ │ ├── applicationrevision_types_test.go │ │ ├── componentdefinition_types.go │ │ ├── conversion.go │ │ ├── core_types.go │ │ ├── definitionrevision_types.go │ │ ├── doc.go │ │ ├── policy_definition.go │ │ ├── register.go │ │ ├── resourcetracker_types.go │ │ ├── resourcetracker_types_test.go │ │ ├── workflow_step_definition.go │ │ └── zz_generated.deepcopy.go ├── generate.go └── types │ ├── capability.go │ ├── componentmanifest.go │ ├── event.go │ ├── multicluster.go │ └── types.go ├── go.mod ├── go.sum ├── pkg ├── generated │ └── client │ │ ├── applyconfiguration │ │ ├── core.oam.dev │ │ │ └── v1beta1 │ │ │ │ ├── application.go │ │ │ │ ├── applicationrevision.go │ │ │ │ ├── applicationrevisioncompressiblefields.go │ │ │ │ ├── applicationrevisioncompression.go │ │ │ │ ├── applicationrevisionspec.go │ │ │ │ ├── applicationrevisionstatus.go │ │ │ │ ├── applicationspec.go │ │ │ │ ├── apppolicy.go │ │ │ │ ├── componentdefinition.go │ │ │ │ ├── componentdefinitionspec.go │ │ │ │ ├── componentdefinitionstatus.go │ │ │ │ ├── definitionrevision.go │ │ │ │ ├── definitionrevisionspec.go │ │ │ │ ├── managedresource.go │ │ │ │ ├── policydefinition.go │ │ │ │ ├── policydefinitionspec.go │ │ │ │ ├── policydefinitionstatus.go │ │ │ │ ├── resourcetracker.go │ │ │ │ ├── resourcetrackercompression.go │ │ │ │ ├── resourcetrackerspec.go │ │ │ │ ├── traitdefinition.go │ │ │ │ ├── traitdefinitionspec.go │ │ │ │ ├── traitdefinitionstatus.go │ │ │ │ ├── workflow.go │ │ │ │ ├── workflowstepdefinition.go │ │ │ │ ├── workflowstepdefinitionspec.go │ │ │ │ ├── workflowstepdefinitionstatus.go │ │ │ │ ├── workloaddefinition.go │ │ │ │ ├── workloaddefinitionspec.go │ │ │ │ └── workloaddefinitionstatus.go │ │ ├── internal │ │ │ └── internal.go │ │ └── utils.go │ │ ├── clientset │ │ └── versioned │ │ │ ├── clientset.go │ │ │ ├── fake │ │ │ ├── clientset_generated.go │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ ├── scheme │ │ │ ├── doc.go │ │ │ └── register.go │ │ │ └── typed │ │ │ └── core.oam.dev │ │ │ └── v1beta1 │ │ │ ├── application.go │ │ │ ├── applicationrevision.go │ │ │ ├── componentdefinition.go │ │ │ ├── core.oam.dev_client.go │ │ │ ├── definitionrevision.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── fake_application.go │ │ │ ├── fake_applicationrevision.go │ │ │ ├── fake_componentdefinition.go │ │ │ ├── fake_core.oam.dev_client.go │ │ │ ├── fake_definitionrevision.go │ │ │ ├── fake_policydefinition.go │ │ │ ├── fake_resourcetracker.go │ │ │ ├── fake_traitdefinition.go │ │ │ ├── fake_workflowstepdefinition.go │ │ │ └── fake_workloaddefinition.go │ │ │ ├── generated_expansion.go │ │ │ ├── policydefinition.go │ │ │ ├── resourcetracker.go │ │ │ ├── traitdefinition.go │ │ │ ├── workflowstepdefinition.go │ │ │ └── workloaddefinition.go │ │ ├── informers │ │ └── externalversions │ │ │ ├── core.oam.dev │ │ │ ├── interface.go │ │ │ └── v1beta1 │ │ │ │ ├── application.go │ │ │ │ ├── applicationrevision.go │ │ │ │ ├── componentdefinition.go │ │ │ │ ├── definitionrevision.go │ │ │ │ ├── interface.go │ │ │ │ ├── policydefinition.go │ │ │ │ ├── resourcetracker.go │ │ │ │ ├── traitdefinition.go │ │ │ │ ├── workflowstepdefinition.go │ │ │ │ └── workloaddefinition.go │ │ │ ├── factory.go │ │ │ ├── generic.go │ │ │ └── internalinterfaces │ │ │ └── factory_interfaces.go │ │ └── listers │ │ └── core.oam.dev │ │ └── v1beta1 │ │ ├── application.go │ │ ├── applicationrevision.go │ │ ├── componentdefinition.go │ │ ├── definitionrevision.go │ │ ├── expansion_generated.go │ │ ├── policydefinition.go │ │ ├── resourcetracker.go │ │ ├── traitdefinition.go │ │ ├── workflowstepdefinition.go │ │ └── workloaddefinition.go ├── oam │ ├── auxiliary.go │ ├── auxliary_test.go │ ├── labels.go │ ├── mock │ │ ├── client.go │ │ └── mocks.go │ ├── testutil │ │ └── helper.go │ ├── types.go │ ├── util │ │ ├── helper.go │ │ ├── helper_test.go │ │ ├── test_utils.go │ │ ├── test_utils_test.go │ │ ├── version.go │ │ └── version_test.go │ └── var.go └── utils │ └── errors │ ├── crd.go │ ├── list.go │ ├── reason.go │ └── resourcetracker.go ├── sync.sh └── 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 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.22" 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: 1.22 23 | 24 | - name: Build 25 | run: go build -v ./... 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | main 3 | test/testapi 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /apis/types/capability.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 | "cuelang.org/go/cue" 21 | ) 22 | 23 | // Source record the source of Capability 24 | type Source struct { 25 | RepoName string `json:"repoName"` 26 | ChartName string `json:"chartName,omitempty"` 27 | } 28 | 29 | // CRDInfo record the CRD info of the Capability 30 | type CRDInfo struct { 31 | APIVersion string `json:"apiVersion"` 32 | Kind string `json:"kind"` 33 | } 34 | 35 | // CapType defines the type of capability 36 | type CapType string 37 | 38 | const ( 39 | // TypeComponentDefinition represents OAM ComponentDefinition 40 | TypeComponentDefinition CapType = "componentDefinition" 41 | // TypeWorkload represents OAM Workload 42 | TypeWorkload CapType = "workload" 43 | // TypeTrait represents OAM Trait 44 | TypeTrait CapType = "trait" 45 | // TypeWorkflowStep represent OAM Workflow 46 | TypeWorkflowStep CapType = "workflowstep" 47 | // TypePolicy represent OAM Policy 48 | TypePolicy CapType = "policy" 49 | ) 50 | 51 | // CapabilityConfigMapNamePrefix is the prefix for capability ConfigMap name 52 | const CapabilityConfigMapNamePrefix = "schema-" 53 | 54 | const ( 55 | // OpenapiV3JSONSchema is the key to store OpenAPI v3 JSON schema in ConfigMap 56 | OpenapiV3JSONSchema string = "openapi-v3-json-schema" 57 | // UISchema is the key to store ui custom schema 58 | UISchema string = "ui-schema" 59 | // VelaQLConfigmapKey is the key to store velaql view 60 | VelaQLConfigmapKey string = "template" 61 | ) 62 | 63 | // CapabilityCategory defines the category of a capability 64 | type CapabilityCategory string 65 | 66 | // categories of capability schematic 67 | const ( 68 | TerraformCategory CapabilityCategory = "terraform" 69 | 70 | CUECategory CapabilityCategory = "cue" 71 | ) 72 | 73 | // Parameter defines a parameter for cli from capability template 74 | type Parameter struct { 75 | Name string `json:"name"` 76 | Short string `json:"short,omitempty"` 77 | Required bool `json:"required,omitempty"` 78 | Default interface{} `json:"default,omitempty"` 79 | Usage string `json:"usage,omitempty"` 80 | Ignore bool `json:"ignore,omitempty"` 81 | Type cue.Kind `json:"type,omitempty"` 82 | Alias string `json:"alias,omitempty"` 83 | JSONType string `json:"jsonType,omitempty"` 84 | } 85 | 86 | // Capability defines the content of a capability 87 | type Capability struct { 88 | Name string `json:"name"` 89 | Type CapType `json:"type"` 90 | CueTemplate string `json:"template,omitempty"` 91 | CueTemplateURI string `json:"templateURI,omitempty"` 92 | Parameters []Parameter `json:"parameters,omitempty"` 93 | CrdName string `json:"crdName,omitempty"` 94 | Status string `json:"status,omitempty"` 95 | Description string `json:"description,omitempty"` 96 | Example string `json:"example,omitempty"` 97 | Labels map[string]string `json:"labels,omitempty"` 98 | Category CapabilityCategory `json:"category,omitempty"` 99 | 100 | // trait only 101 | AppliesTo []string `json:"appliesTo,omitempty"` 102 | 103 | // Namespace represents it's a system-level or user-level capability. 104 | Namespace string `json:"namespace,omitempty"` 105 | 106 | // Plugin Source 107 | Source *Source `json:"source,omitempty"` 108 | 109 | // Terraform 110 | TerraformConfiguration string `json:"terraformConfiguration,omitempty"` 111 | ConfigurationType string `json:"configurationType,omitempty"` 112 | Path string `json:"path,omitempty"` 113 | } 114 | -------------------------------------------------------------------------------- /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/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/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/applyconfiguration/core.oam.dev/v1beta1/applicationrevisioncompression.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | compression "github.com/kubevela/pkg/util/compression" 22 | ) 23 | 24 | // ApplicationRevisionCompressionApplyConfiguration represents an declarative configuration of the ApplicationRevisionCompression type for use 25 | // with apply. 26 | type ApplicationRevisionCompressionApplyConfiguration struct { 27 | compression.CompressedText `json:",inline"` 28 | } 29 | 30 | // ApplicationRevisionCompressionApplyConfiguration constructs an declarative configuration of the ApplicationRevisionCompression type for use with 31 | // apply. 32 | func ApplicationRevisionCompression() *ApplicationRevisionCompressionApplyConfiguration { 33 | return &ApplicationRevisionCompressionApplyConfiguration{} 34 | } 35 | 36 | // WithType sets the Type field in the declarative configuration to the given value 37 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 38 | // If called multiple times, the Type field is set to the value of the last call. 39 | func (b *ApplicationRevisionCompressionApplyConfiguration) WithType(value compression.Type) *ApplicationRevisionCompressionApplyConfiguration { 40 | b.Type = &value 41 | return b 42 | } 43 | 44 | // WithData sets the Data field in the declarative configuration to the given value 45 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 46 | // If called multiple times, the Data field is set to the value of the last call. 47 | func (b *ApplicationRevisionCompressionApplyConfiguration) WithData(value string) *ApplicationRevisionCompressionApplyConfiguration { 48 | b.Data = &value 49 | return b 50 | } 51 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/applicationrevisionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | ) 23 | 24 | // ApplicationRevisionStatusApplyConfiguration represents an declarative configuration of the ApplicationRevisionStatus type for use 25 | // with apply. 26 | type ApplicationRevisionStatusApplyConfiguration struct { 27 | Succeeded *bool `json:"succeeded,omitempty"` 28 | Workflow *common.WorkflowStatus `json:"workflow,omitempty"` 29 | WorkflowContext map[string]string `json:"workflowContext,omitempty"` 30 | } 31 | 32 | // ApplicationRevisionStatusApplyConfiguration constructs an declarative configuration of the ApplicationRevisionStatus type for use with 33 | // apply. 34 | func ApplicationRevisionStatus() *ApplicationRevisionStatusApplyConfiguration { 35 | return &ApplicationRevisionStatusApplyConfiguration{} 36 | } 37 | 38 | // WithSucceeded sets the Succeeded field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the Succeeded field is set to the value of the last call. 41 | func (b *ApplicationRevisionStatusApplyConfiguration) WithSucceeded(value bool) *ApplicationRevisionStatusApplyConfiguration { 42 | b.Succeeded = &value 43 | return b 44 | } 45 | 46 | // WithWorkflow sets the Workflow field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Workflow field is set to the value of the last call. 49 | func (b *ApplicationRevisionStatusApplyConfiguration) WithWorkflow(value common.WorkflowStatus) *ApplicationRevisionStatusApplyConfiguration { 50 | b.Workflow = &value 51 | return b 52 | } 53 | 54 | // WithWorkflowContext puts the entries into the WorkflowContext field in the declarative configuration 55 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 56 | // If called multiple times, the entries provided by each call will be put on the WorkflowContext field, 57 | // overwriting an existing map entries in WorkflowContext field with the same key. 58 | func (b *ApplicationRevisionStatusApplyConfiguration) WithWorkflowContext(entries map[string]string) *ApplicationRevisionStatusApplyConfiguration { 59 | if b.WorkflowContext == nil && len(entries) > 0 { 60 | b.WorkflowContext = make(map[string]string, len(entries)) 61 | } 62 | for k, v := range entries { 63 | b.WorkflowContext[k] = v 64 | } 65 | return b 66 | } 67 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/applicationspec.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | ) 23 | 24 | // ApplicationSpecApplyConfiguration represents an declarative configuration of the ApplicationSpec type for use 25 | // with apply. 26 | type ApplicationSpecApplyConfiguration struct { 27 | Components []common.ApplicationComponent `json:"components,omitempty"` 28 | Policies []AppPolicyApplyConfiguration `json:"policies,omitempty"` 29 | Workflow *WorkflowApplyConfiguration `json:"workflow,omitempty"` 30 | } 31 | 32 | // ApplicationSpecApplyConfiguration constructs an declarative configuration of the ApplicationSpec type for use with 33 | // apply. 34 | func ApplicationSpec() *ApplicationSpecApplyConfiguration { 35 | return &ApplicationSpecApplyConfiguration{} 36 | } 37 | 38 | // WithComponents adds the given value to the Components field in the declarative configuration 39 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 40 | // If called multiple times, values provided by each call will be appended to the Components field. 41 | func (b *ApplicationSpecApplyConfiguration) WithComponents(values ...common.ApplicationComponent) *ApplicationSpecApplyConfiguration { 42 | for i := range values { 43 | b.Components = append(b.Components, values[i]) 44 | } 45 | return b 46 | } 47 | 48 | // WithPolicies adds the given value to the Policies field in the declarative configuration 49 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 50 | // If called multiple times, values provided by each call will be appended to the Policies field. 51 | func (b *ApplicationSpecApplyConfiguration) WithPolicies(values ...*AppPolicyApplyConfiguration) *ApplicationSpecApplyConfiguration { 52 | for i := range values { 53 | if values[i] == nil { 54 | panic("nil value passed to WithPolicies") 55 | } 56 | b.Policies = append(b.Policies, *values[i]) 57 | } 58 | return b 59 | } 60 | 61 | // WithWorkflow sets the Workflow field in the declarative configuration to the given value 62 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 63 | // If called multiple times, the Workflow field is set to the value of the last call. 64 | func (b *ApplicationSpecApplyConfiguration) WithWorkflow(value *WorkflowApplyConfiguration) *ApplicationSpecApplyConfiguration { 65 | b.Workflow = value 66 | return b 67 | } 68 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/apppolicy.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | runtime "k8s.io/apimachinery/pkg/runtime" 22 | ) 23 | 24 | // AppPolicyApplyConfiguration represents an declarative configuration of the AppPolicy type for use 25 | // with apply. 26 | type AppPolicyApplyConfiguration struct { 27 | Name *string `json:"name,omitempty"` 28 | Type *string `json:"type,omitempty"` 29 | Properties *runtime.RawExtension `json:"properties,omitempty"` 30 | } 31 | 32 | // AppPolicyApplyConfiguration constructs an declarative configuration of the AppPolicy type for use with 33 | // apply. 34 | func AppPolicy() *AppPolicyApplyConfiguration { 35 | return &AppPolicyApplyConfiguration{} 36 | } 37 | 38 | // WithName sets the Name field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the Name field is set to the value of the last call. 41 | func (b *AppPolicyApplyConfiguration) WithName(value string) *AppPolicyApplyConfiguration { 42 | b.Name = &value 43 | return b 44 | } 45 | 46 | // WithType sets the Type field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Type field is set to the value of the last call. 49 | func (b *AppPolicyApplyConfiguration) WithType(value string) *AppPolicyApplyConfiguration { 50 | b.Type = &value 51 | return b 52 | } 53 | 54 | // WithProperties sets the Properties field in the declarative configuration to the given value 55 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 56 | // If called multiple times, the Properties field is set to the value of the last call. 57 | func (b *AppPolicyApplyConfiguration) WithProperties(value runtime.RawExtension) *AppPolicyApplyConfiguration { 58 | b.Properties = &value 59 | return b 60 | } 61 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/componentdefinitionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | condition "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | ) 24 | 25 | // ComponentDefinitionStatusApplyConfiguration represents an declarative configuration of the ComponentDefinitionStatus type for use 26 | // with apply. 27 | type ComponentDefinitionStatusApplyConfiguration struct { 28 | condition.ConditionedStatus `json:",inline"` 29 | ConfigMapRef *string `json:"configMapRef,omitempty"` 30 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 31 | } 32 | 33 | // ComponentDefinitionStatusApplyConfiguration constructs an declarative configuration of the ComponentDefinitionStatus type for use with 34 | // apply. 35 | func ComponentDefinitionStatus() *ComponentDefinitionStatusApplyConfiguration { 36 | return &ComponentDefinitionStatusApplyConfiguration{} 37 | } 38 | 39 | // WithConditions adds the given value to the Conditions field in the declarative configuration 40 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 41 | // If called multiple times, values provided by each call will be appended to the Conditions field. 42 | func (b *ComponentDefinitionStatusApplyConfiguration) WithConditions(values ...condition.Condition) *ComponentDefinitionStatusApplyConfiguration { 43 | for i := range values { 44 | b.Conditions = append(b.Conditions, values[i]) 45 | } 46 | return b 47 | } 48 | 49 | // WithConfigMapRef sets the ConfigMapRef field in the declarative configuration to the given value 50 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 51 | // If called multiple times, the ConfigMapRef field is set to the value of the last call. 52 | func (b *ComponentDefinitionStatusApplyConfiguration) WithConfigMapRef(value string) *ComponentDefinitionStatusApplyConfiguration { 53 | b.ConfigMapRef = &value 54 | return b 55 | } 56 | 57 | // WithLatestRevision sets the LatestRevision field in the declarative configuration to the given value 58 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 59 | // If called multiple times, the LatestRevision field is set to the value of the last call. 60 | func (b *ComponentDefinitionStatusApplyConfiguration) WithLatestRevision(value common.Revision) *ComponentDefinitionStatusApplyConfiguration { 61 | b.LatestRevision = &value 62 | return b 63 | } 64 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/policydefinitionspec.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | ) 23 | 24 | // PolicyDefinitionSpecApplyConfiguration represents an declarative configuration of the PolicyDefinitionSpec type for use 25 | // with apply. 26 | type PolicyDefinitionSpecApplyConfiguration struct { 27 | Reference *common.DefinitionReference `json:"definitionRef,omitempty"` 28 | Schematic *common.Schematic `json:"schematic,omitempty"` 29 | ManageHealthCheck *bool `json:"manageHealthCheck,omitempty"` 30 | Version *string `json:"version,omitempty"` 31 | } 32 | 33 | // PolicyDefinitionSpecApplyConfiguration constructs an declarative configuration of the PolicyDefinitionSpec type for use with 34 | // apply. 35 | func PolicyDefinitionSpec() *PolicyDefinitionSpecApplyConfiguration { 36 | return &PolicyDefinitionSpecApplyConfiguration{} 37 | } 38 | 39 | // WithReference sets the Reference field in the declarative configuration to the given value 40 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 41 | // If called multiple times, the Reference field is set to the value of the last call. 42 | func (b *PolicyDefinitionSpecApplyConfiguration) WithReference(value common.DefinitionReference) *PolicyDefinitionSpecApplyConfiguration { 43 | b.Reference = &value 44 | return b 45 | } 46 | 47 | // WithSchematic sets the Schematic field in the declarative configuration to the given value 48 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 49 | // If called multiple times, the Schematic field is set to the value of the last call. 50 | func (b *PolicyDefinitionSpecApplyConfiguration) WithSchematic(value common.Schematic) *PolicyDefinitionSpecApplyConfiguration { 51 | b.Schematic = &value 52 | return b 53 | } 54 | 55 | // WithManageHealthCheck sets the ManageHealthCheck field in the declarative configuration to the given value 56 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 57 | // If called multiple times, the ManageHealthCheck field is set to the value of the last call. 58 | func (b *PolicyDefinitionSpecApplyConfiguration) WithManageHealthCheck(value bool) *PolicyDefinitionSpecApplyConfiguration { 59 | b.ManageHealthCheck = &value 60 | return b 61 | } 62 | 63 | // WithVersion sets the Version field in the declarative configuration to the given value 64 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 65 | // If called multiple times, the Version field is set to the value of the last call. 66 | func (b *PolicyDefinitionSpecApplyConfiguration) WithVersion(value string) *PolicyDefinitionSpecApplyConfiguration { 67 | b.Version = &value 68 | return b 69 | } 70 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/policydefinitionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | condition "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | ) 24 | 25 | // PolicyDefinitionStatusApplyConfiguration represents an declarative configuration of the PolicyDefinitionStatus type for use 26 | // with apply. 27 | type PolicyDefinitionStatusApplyConfiguration struct { 28 | condition.ConditionedStatus `json:",inline"` 29 | ConfigMapRef *string `json:"configMapRef,omitempty"` 30 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 31 | } 32 | 33 | // PolicyDefinitionStatusApplyConfiguration constructs an declarative configuration of the PolicyDefinitionStatus type for use with 34 | // apply. 35 | func PolicyDefinitionStatus() *PolicyDefinitionStatusApplyConfiguration { 36 | return &PolicyDefinitionStatusApplyConfiguration{} 37 | } 38 | 39 | // WithConditions adds the given value to the Conditions field in the declarative configuration 40 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 41 | // If called multiple times, values provided by each call will be appended to the Conditions field. 42 | func (b *PolicyDefinitionStatusApplyConfiguration) WithConditions(values ...condition.Condition) *PolicyDefinitionStatusApplyConfiguration { 43 | for i := range values { 44 | b.Conditions = append(b.Conditions, values[i]) 45 | } 46 | return b 47 | } 48 | 49 | // WithConfigMapRef sets the ConfigMapRef field in the declarative configuration to the given value 50 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 51 | // If called multiple times, the ConfigMapRef field is set to the value of the last call. 52 | func (b *PolicyDefinitionStatusApplyConfiguration) WithConfigMapRef(value string) *PolicyDefinitionStatusApplyConfiguration { 53 | b.ConfigMapRef = &value 54 | return b 55 | } 56 | 57 | // WithLatestRevision sets the LatestRevision field in the declarative configuration to the given value 58 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 59 | // If called multiple times, the LatestRevision field is set to the value of the last call. 60 | func (b *PolicyDefinitionStatusApplyConfiguration) WithLatestRevision(value common.Revision) *PolicyDefinitionStatusApplyConfiguration { 61 | b.LatestRevision = &value 62 | return b 63 | } 64 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/resourcetrackercompression.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | compression "github.com/kubevela/pkg/util/compression" 22 | ) 23 | 24 | // ResourceTrackerCompressionApplyConfiguration represents an declarative configuration of the ResourceTrackerCompression type for use 25 | // with apply. 26 | type ResourceTrackerCompressionApplyConfiguration struct { 27 | compression.CompressedText `json:",inline"` 28 | } 29 | 30 | // ResourceTrackerCompressionApplyConfiguration constructs an declarative configuration of the ResourceTrackerCompression type for use with 31 | // apply. 32 | func ResourceTrackerCompression() *ResourceTrackerCompressionApplyConfiguration { 33 | return &ResourceTrackerCompressionApplyConfiguration{} 34 | } 35 | 36 | // WithType sets the Type field in the declarative configuration to the given value 37 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 38 | // If called multiple times, the Type field is set to the value of the last call. 39 | func (b *ResourceTrackerCompressionApplyConfiguration) WithType(value compression.Type) *ResourceTrackerCompressionApplyConfiguration { 40 | b.Type = &value 41 | return b 42 | } 43 | 44 | // WithData sets the Data field in the declarative configuration to the given value 45 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 46 | // If called multiple times, the Data field is set to the value of the last call. 47 | func (b *ResourceTrackerCompressionApplyConfiguration) WithData(value string) *ResourceTrackerCompressionApplyConfiguration { 48 | b.Data = &value 49 | return b 50 | } 51 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/resourcetrackerspec.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 applyconfiguration-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 | ) 23 | 24 | // ResourceTrackerSpecApplyConfiguration represents an declarative configuration of the ResourceTrackerSpec type for use 25 | // with apply. 26 | type ResourceTrackerSpecApplyConfiguration struct { 27 | Type *v1beta1.ResourceTrackerType `json:"type,omitempty"` 28 | ApplicationGeneration *int64 `json:"applicationGeneration,omitempty"` 29 | ManagedResources []ManagedResourceApplyConfiguration `json:"managedResources,omitempty"` 30 | Compression *ResourceTrackerCompressionApplyConfiguration `json:"compression,omitempty"` 31 | } 32 | 33 | // ResourceTrackerSpecApplyConfiguration constructs an declarative configuration of the ResourceTrackerSpec type for use with 34 | // apply. 35 | func ResourceTrackerSpec() *ResourceTrackerSpecApplyConfiguration { 36 | return &ResourceTrackerSpecApplyConfiguration{} 37 | } 38 | 39 | // WithType sets the Type field in the declarative configuration to the given value 40 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 41 | // If called multiple times, the Type field is set to the value of the last call. 42 | func (b *ResourceTrackerSpecApplyConfiguration) WithType(value v1beta1.ResourceTrackerType) *ResourceTrackerSpecApplyConfiguration { 43 | b.Type = &value 44 | return b 45 | } 46 | 47 | // WithApplicationGeneration sets the ApplicationGeneration field in the declarative configuration to the given value 48 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 49 | // If called multiple times, the ApplicationGeneration field is set to the value of the last call. 50 | func (b *ResourceTrackerSpecApplyConfiguration) WithApplicationGeneration(value int64) *ResourceTrackerSpecApplyConfiguration { 51 | b.ApplicationGeneration = &value 52 | return b 53 | } 54 | 55 | // WithManagedResources adds the given value to the ManagedResources field in the declarative configuration 56 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 57 | // If called multiple times, values provided by each call will be appended to the ManagedResources field. 58 | func (b *ResourceTrackerSpecApplyConfiguration) WithManagedResources(values ...*ManagedResourceApplyConfiguration) *ResourceTrackerSpecApplyConfiguration { 59 | for i := range values { 60 | if values[i] == nil { 61 | panic("nil value passed to WithManagedResources") 62 | } 63 | b.ManagedResources = append(b.ManagedResources, *values[i]) 64 | } 65 | return b 66 | } 67 | 68 | // WithCompression sets the Compression field in the declarative configuration to the given value 69 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 70 | // If called multiple times, the Compression field is set to the value of the last call. 71 | func (b *ResourceTrackerSpecApplyConfiguration) WithCompression(value *ResourceTrackerCompressionApplyConfiguration) *ResourceTrackerSpecApplyConfiguration { 72 | b.Compression = value 73 | return b 74 | } 75 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/traitdefinitionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | condition "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | ) 24 | 25 | // TraitDefinitionStatusApplyConfiguration represents an declarative configuration of the TraitDefinitionStatus type for use 26 | // with apply. 27 | type TraitDefinitionStatusApplyConfiguration struct { 28 | condition.ConditionedStatus `json:",inline"` 29 | ConfigMapRef *string `json:"configMapRef,omitempty"` 30 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 31 | } 32 | 33 | // TraitDefinitionStatusApplyConfiguration constructs an declarative configuration of the TraitDefinitionStatus type for use with 34 | // apply. 35 | func TraitDefinitionStatus() *TraitDefinitionStatusApplyConfiguration { 36 | return &TraitDefinitionStatusApplyConfiguration{} 37 | } 38 | 39 | // WithConditions adds the given value to the Conditions field in the declarative configuration 40 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 41 | // If called multiple times, values provided by each call will be appended to the Conditions field. 42 | func (b *TraitDefinitionStatusApplyConfiguration) WithConditions(values ...condition.Condition) *TraitDefinitionStatusApplyConfiguration { 43 | for i := range values { 44 | b.Conditions = append(b.Conditions, values[i]) 45 | } 46 | return b 47 | } 48 | 49 | // WithConfigMapRef sets the ConfigMapRef field in the declarative configuration to the given value 50 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 51 | // If called multiple times, the ConfigMapRef field is set to the value of the last call. 52 | func (b *TraitDefinitionStatusApplyConfiguration) WithConfigMapRef(value string) *TraitDefinitionStatusApplyConfiguration { 53 | b.ConfigMapRef = &value 54 | return b 55 | } 56 | 57 | // WithLatestRevision sets the LatestRevision field in the declarative configuration to the given value 58 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 59 | // If called multiple times, the LatestRevision field is set to the value of the last call. 60 | func (b *TraitDefinitionStatusApplyConfiguration) WithLatestRevision(value common.Revision) *TraitDefinitionStatusApplyConfiguration { 61 | b.LatestRevision = &value 62 | return b 63 | } 64 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/workflow.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | v1alpha1 "github.com/kubevela/workflow/api/v1alpha1" 22 | ) 23 | 24 | // WorkflowApplyConfiguration represents an declarative configuration of the Workflow type for use 25 | // with apply. 26 | type WorkflowApplyConfiguration struct { 27 | Ref *string `json:"ref,omitempty"` 28 | Mode *v1alpha1.WorkflowExecuteMode `json:"mode,omitempty"` 29 | Steps []v1alpha1.WorkflowStep `json:"steps,omitempty"` 30 | } 31 | 32 | // WorkflowApplyConfiguration constructs an declarative configuration of the Workflow type for use with 33 | // apply. 34 | func Workflow() *WorkflowApplyConfiguration { 35 | return &WorkflowApplyConfiguration{} 36 | } 37 | 38 | // WithRef sets the Ref field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the Ref field is set to the value of the last call. 41 | func (b *WorkflowApplyConfiguration) WithRef(value string) *WorkflowApplyConfiguration { 42 | b.Ref = &value 43 | return b 44 | } 45 | 46 | // WithMode sets the Mode field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Mode field is set to the value of the last call. 49 | func (b *WorkflowApplyConfiguration) WithMode(value v1alpha1.WorkflowExecuteMode) *WorkflowApplyConfiguration { 50 | b.Mode = &value 51 | return b 52 | } 53 | 54 | // WithSteps adds the given value to the Steps field in the declarative configuration 55 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 56 | // If called multiple times, values provided by each call will be appended to the Steps field. 57 | func (b *WorkflowApplyConfiguration) WithSteps(values ...v1alpha1.WorkflowStep) *WorkflowApplyConfiguration { 58 | for i := range values { 59 | b.Steps = append(b.Steps, values[i]) 60 | } 61 | return b 62 | } 63 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/workflowstepdefinitionspec.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | ) 23 | 24 | // WorkflowStepDefinitionSpecApplyConfiguration represents an declarative configuration of the WorkflowStepDefinitionSpec type for use 25 | // with apply. 26 | type WorkflowStepDefinitionSpecApplyConfiguration struct { 27 | Reference *common.DefinitionReference `json:"definitionRef,omitempty"` 28 | Schematic *common.Schematic `json:"schematic,omitempty"` 29 | Version *string `json:"version,omitempty"` 30 | } 31 | 32 | // WorkflowStepDefinitionSpecApplyConfiguration constructs an declarative configuration of the WorkflowStepDefinitionSpec type for use with 33 | // apply. 34 | func WorkflowStepDefinitionSpec() *WorkflowStepDefinitionSpecApplyConfiguration { 35 | return &WorkflowStepDefinitionSpecApplyConfiguration{} 36 | } 37 | 38 | // WithReference sets the Reference field in the declarative configuration to the given value 39 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 40 | // If called multiple times, the Reference field is set to the value of the last call. 41 | func (b *WorkflowStepDefinitionSpecApplyConfiguration) WithReference(value common.DefinitionReference) *WorkflowStepDefinitionSpecApplyConfiguration { 42 | b.Reference = &value 43 | return b 44 | } 45 | 46 | // WithSchematic sets the Schematic field in the declarative configuration to the given value 47 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 48 | // If called multiple times, the Schematic field is set to the value of the last call. 49 | func (b *WorkflowStepDefinitionSpecApplyConfiguration) WithSchematic(value common.Schematic) *WorkflowStepDefinitionSpecApplyConfiguration { 50 | b.Schematic = &value 51 | return b 52 | } 53 | 54 | // WithVersion sets the Version field in the declarative configuration to the given value 55 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 56 | // If called multiple times, the Version field is set to the value of the last call. 57 | func (b *WorkflowStepDefinitionSpecApplyConfiguration) WithVersion(value string) *WorkflowStepDefinitionSpecApplyConfiguration { 58 | b.Version = &value 59 | return b 60 | } 61 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/workflowstepdefinitionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | common "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/common" 22 | condition "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 23 | ) 24 | 25 | // WorkflowStepDefinitionStatusApplyConfiguration represents an declarative configuration of the WorkflowStepDefinitionStatus type for use 26 | // with apply. 27 | type WorkflowStepDefinitionStatusApplyConfiguration struct { 28 | condition.ConditionedStatus `json:",inline"` 29 | ConfigMapRef *string `json:"configMapRef,omitempty"` 30 | LatestRevision *common.Revision `json:"latestRevision,omitempty"` 31 | } 32 | 33 | // WorkflowStepDefinitionStatusApplyConfiguration constructs an declarative configuration of the WorkflowStepDefinitionStatus type for use with 34 | // apply. 35 | func WorkflowStepDefinitionStatus() *WorkflowStepDefinitionStatusApplyConfiguration { 36 | return &WorkflowStepDefinitionStatusApplyConfiguration{} 37 | } 38 | 39 | // WithConditions adds the given value to the Conditions field in the declarative configuration 40 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 41 | // If called multiple times, values provided by each call will be appended to the Conditions field. 42 | func (b *WorkflowStepDefinitionStatusApplyConfiguration) WithConditions(values ...condition.Condition) *WorkflowStepDefinitionStatusApplyConfiguration { 43 | for i := range values { 44 | b.Conditions = append(b.Conditions, values[i]) 45 | } 46 | return b 47 | } 48 | 49 | // WithConfigMapRef sets the ConfigMapRef field in the declarative configuration to the given value 50 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 51 | // If called multiple times, the ConfigMapRef field is set to the value of the last call. 52 | func (b *WorkflowStepDefinitionStatusApplyConfiguration) WithConfigMapRef(value string) *WorkflowStepDefinitionStatusApplyConfiguration { 53 | b.ConfigMapRef = &value 54 | return b 55 | } 56 | 57 | // WithLatestRevision sets the LatestRevision field in the declarative configuration to the given value 58 | // and returns the receiver, so that objects can be built by chaining "With" function invocations. 59 | // If called multiple times, the LatestRevision field is set to the value of the last call. 60 | func (b *WorkflowStepDefinitionStatusApplyConfiguration) WithLatestRevision(value common.Revision) *WorkflowStepDefinitionStatusApplyConfiguration { 61 | b.LatestRevision = &value 62 | return b 63 | } 64 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/core.oam.dev/v1beta1/workloaddefinitionstatus.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package v1beta1 19 | 20 | import ( 21 | condition "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/condition" 22 | ) 23 | 24 | // WorkloadDefinitionStatusApplyConfiguration represents an declarative configuration of the WorkloadDefinitionStatus type for use 25 | // with apply. 26 | type WorkloadDefinitionStatusApplyConfiguration struct { 27 | condition.ConditionedStatus `json:",inline"` 28 | } 29 | 30 | // WorkloadDefinitionStatusApplyConfiguration constructs an declarative configuration of the WorkloadDefinitionStatus type for use with 31 | // apply. 32 | func WorkloadDefinitionStatus() *WorkloadDefinitionStatusApplyConfiguration { 33 | return &WorkloadDefinitionStatusApplyConfiguration{} 34 | } 35 | 36 | // WithConditions adds the given value to the Conditions field in the declarative configuration 37 | // and returns the receiver, so that objects can be build by chaining "With" function invocations. 38 | // If called multiple times, values provided by each call will be appended to the Conditions field. 39 | func (b *WorkloadDefinitionStatusApplyConfiguration) WithConditions(values ...condition.Condition) *WorkloadDefinitionStatusApplyConfiguration { 40 | for i := range values { 41 | b.Conditions = append(b.Conditions, values[i]) 42 | } 43 | return b 44 | } 45 | -------------------------------------------------------------------------------- /pkg/generated/client/applyconfiguration/internal/internal.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 applyconfiguration-gen. DO NOT EDIT. 17 | 18 | package internal 19 | 20 | import ( 21 | "fmt" 22 | "sync" 23 | 24 | typed "sigs.k8s.io/structured-merge-diff/v4/typed" 25 | ) 26 | 27 | func Parser() *typed.Parser { 28 | parserOnce.Do(func() { 29 | var err error 30 | parser, err = typed.NewParser(schemaYAML) 31 | if err != nil { 32 | panic(fmt.Sprintf("Failed to parse schema: %v", err)) 33 | } 34 | }) 35 | return parser 36 | } 37 | 38 | var parserOnce sync.Once 39 | var parser *typed.Parser 40 | var schemaYAML = typed.YAMLObject(`types: 41 | - name: __untyped_atomic_ 42 | scalar: untyped 43 | list: 44 | elementType: 45 | namedType: __untyped_atomic_ 46 | elementRelationship: atomic 47 | map: 48 | elementType: 49 | namedType: __untyped_atomic_ 50 | elementRelationship: atomic 51 | - name: __untyped_deduced_ 52 | scalar: untyped 53 | list: 54 | elementType: 55 | namedType: __untyped_atomic_ 56 | elementRelationship: atomic 57 | map: 58 | elementType: 59 | namedType: __untyped_deduced_ 60 | elementRelationship: separable 61 | `) 62 | -------------------------------------------------------------------------------- /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 | corev1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1" 23 | fakecorev1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/clientset/versioned/typed/core.oam.dev/v1beta1/fake" 24 | "k8s.io/apimachinery/pkg/runtime" 25 | "k8s.io/apimachinery/pkg/watch" 26 | "k8s.io/client-go/discovery" 27 | fakediscovery "k8s.io/client-go/discovery/fake" 28 | "k8s.io/client-go/testing" 29 | ) 30 | 31 | // NewSimpleClientset returns a clientset that will respond with the provided objects. 32 | // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, 33 | // without applying any validations and/or defaults. It shouldn't be considered a replacement 34 | // for a real clientset and is mostly useful in simple unit tests. 35 | func NewSimpleClientset(objects ...runtime.Object) *Clientset { 36 | o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) 37 | for _, obj := range objects { 38 | if err := o.Add(obj); err != nil { 39 | panic(err) 40 | } 41 | } 42 | 43 | cs := &Clientset{tracker: o} 44 | cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} 45 | cs.AddReactor("*", "*", testing.ObjectReaction(o)) 46 | cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { 47 | gvr := action.GetResource() 48 | ns := action.GetNamespace() 49 | watch, err := o.Watch(gvr, ns) 50 | if err != nil { 51 | return false, nil, err 52 | } 53 | return true, watch, nil 54 | }) 55 | 56 | return cs 57 | } 58 | 59 | // Clientset implements clientset.Interface. Meant to be embedded into a 60 | // struct to get a default implementation. This makes faking out just the method 61 | // you want to test easier. 62 | type Clientset struct { 63 | testing.Fake 64 | discovery *fakediscovery.FakeDiscovery 65 | tracker testing.ObjectTracker 66 | } 67 | 68 | func (c *Clientset) Discovery() discovery.DiscoveryInterface { 69 | return c.discovery 70 | } 71 | 72 | func (c *Clientset) Tracker() testing.ObjectTracker { 73 | return c.tracker 74 | } 75 | 76 | var ( 77 | _ clientset.Interface = &Clientset{} 78 | _ testing.FakeClient = &Clientset{} 79 | ) 80 | 81 | // CoreV1beta1 retrieves the CoreV1beta1Client 82 | func (c *Clientset) CoreV1beta1() corev1beta1.CoreV1beta1Interface { 83 | return &fakecorev1beta1.FakeCoreV1beta1{Fake: &c.Fake} 84 | } 85 | -------------------------------------------------------------------------------- /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/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 | corev1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | runtime "k8s.io/apimachinery/pkg/runtime" 24 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 26 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 27 | ) 28 | 29 | var scheme = runtime.NewScheme() 30 | var codecs = serializer.NewCodecFactory(scheme) 31 | 32 | var localSchemeBuilder = runtime.SchemeBuilder{ 33 | corev1beta1.AddToScheme, 34 | } 35 | 36 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 37 | // of clientsets, like in: 38 | // 39 | // import ( 40 | // "k8s.io/client-go/kubernetes" 41 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 42 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 43 | // ) 44 | // 45 | // kclientset, _ := kubernetes.NewForConfig(c) 46 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 47 | // 48 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 49 | // correctly. 50 | var AddToScheme = localSchemeBuilder.AddToScheme 51 | 52 | func init() { 53 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 54 | utilruntime.Must(AddToScheme(scheme)) 55 | } 56 | -------------------------------------------------------------------------------- /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/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 | corev1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 22 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | runtime "k8s.io/apimachinery/pkg/runtime" 24 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 26 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 27 | ) 28 | 29 | var Scheme = runtime.NewScheme() 30 | var Codecs = serializer.NewCodecFactory(Scheme) 31 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 32 | var localSchemeBuilder = runtime.SchemeBuilder{ 33 | corev1beta1.AddToScheme, 34 | } 35 | 36 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 37 | // of clientsets, like in: 38 | // 39 | // import ( 40 | // "k8s.io/client-go/kubernetes" 41 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 42 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 43 | // ) 44 | // 45 | // kclientset, _ := kubernetes.NewForConfig(c) 46 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 47 | // 48 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 49 | // correctly. 50 | var AddToScheme = localSchemeBuilder.AddToScheme 51 | 52 | func init() { 53 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 54 | utilruntime.Must(AddToScheme(Scheme)) 55 | } 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | v1beta1 "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/core.oam.dev/v1beta1" 22 | internalinterfaces "github.com/oam-dev/kubevela-core-api/pkg/generated/client/informers/externalversions/internalinterfaces" 23 | ) 24 | 25 | // Interface provides access to each of this group's versions. 26 | type Interface interface { 27 | // V1beta1 provides access to shared informers for resources in V1beta1. 28 | V1beta1() v1beta1.Interface 29 | } 30 | 31 | type group struct { 32 | factory internalinterfaces.SharedInformerFactory 33 | namespace string 34 | tweakListOptions internalinterfaces.TweakListOptionsFunc 35 | } 36 | 37 | // New returns a new Interface. 38 | func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { 39 | return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} 40 | } 41 | 42 | // V1beta1 returns a new v1beta1.Interface. 43 | func (g *group) V1beta1() v1beta1.Interface { 44 | return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) 45 | } 46 | -------------------------------------------------------------------------------- /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/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 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 | // ApplicationRevisionInformer provides access to a shared informer and lister for 35 | // ApplicationRevisions. 36 | type ApplicationRevisionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.ApplicationRevisionLister 39 | } 40 | 41 | type applicationRevisionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewApplicationRevisionInformer constructs a new informer for ApplicationRevision 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 NewApplicationRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredApplicationRevisionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredApplicationRevisionInformer constructs a new informer for ApplicationRevision 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 NewFilteredApplicationRevisionInformer(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().ApplicationRevisions(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().ApplicationRevisions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.ApplicationRevision{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *applicationRevisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredApplicationRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *applicationRevisionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.ApplicationRevision{}, f.defaultInformer) 85 | } 86 | 87 | func (f *applicationRevisionInformer) Lister() v1beta1.ApplicationRevisionLister { 88 | return v1beta1.NewApplicationRevisionLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/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 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 | // ComponentDefinitionInformer provides access to a shared informer and lister for 35 | // ComponentDefinitions. 36 | type ComponentDefinitionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.ComponentDefinitionLister 39 | } 40 | 41 | type componentDefinitionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewComponentDefinitionInformer constructs a new informer for ComponentDefinition 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 NewComponentDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredComponentDefinitionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredComponentDefinitionInformer constructs a new informer for ComponentDefinition 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 NewFilteredComponentDefinitionInformer(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().ComponentDefinitions(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().ComponentDefinitions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.ComponentDefinition{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *componentDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredComponentDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *componentDefinitionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.ComponentDefinition{}, f.defaultInformer) 85 | } 86 | 87 | func (f *componentDefinitionInformer) Lister() v1beta1.ComponentDefinitionLister { 88 | return v1beta1.NewComponentDefinitionLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/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 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 | // DefinitionRevisionInformer provides access to a shared informer and lister for 35 | // DefinitionRevisions. 36 | type DefinitionRevisionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.DefinitionRevisionLister 39 | } 40 | 41 | type definitionRevisionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewDefinitionRevisionInformer constructs a new informer for DefinitionRevision 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 NewDefinitionRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredDefinitionRevisionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredDefinitionRevisionInformer constructs a new informer for DefinitionRevision 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 NewFilteredDefinitionRevisionInformer(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().DefinitionRevisions(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().DefinitionRevisions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.DefinitionRevision{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *definitionRevisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredDefinitionRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *definitionRevisionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.DefinitionRevision{}, f.defaultInformer) 85 | } 86 | 87 | func (f *definitionRevisionInformer) Lister() v1beta1.DefinitionRevisionLister { 88 | return v1beta1.NewDefinitionRevisionLister(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 | -------------------------------------------------------------------------------- /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/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 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 | // WorkflowStepDefinitionInformer provides access to a shared informer and lister for 35 | // WorkflowStepDefinitions. 36 | type WorkflowStepDefinitionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.WorkflowStepDefinitionLister 39 | } 40 | 41 | type workflowStepDefinitionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewWorkflowStepDefinitionInformer constructs a new informer for WorkflowStepDefinition 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 NewWorkflowStepDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredWorkflowStepDefinitionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredWorkflowStepDefinitionInformer constructs a new informer for WorkflowStepDefinition 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 NewFilteredWorkflowStepDefinitionInformer(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().WorkflowStepDefinitions(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().WorkflowStepDefinitions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.WorkflowStepDefinition{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *workflowStepDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredWorkflowStepDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *workflowStepDefinitionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.WorkflowStepDefinition{}, f.defaultInformer) 85 | } 86 | 87 | func (f *workflowStepDefinitionInformer) Lister() v1beta1.WorkflowStepDefinitionLister { 88 | return v1beta1.NewWorkflowStepDefinitionLister(f.Informer().GetIndexer()) 89 | } 90 | -------------------------------------------------------------------------------- /pkg/generated/client/informers/externalversions/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 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 | // WorkloadDefinitionInformer provides access to a shared informer and lister for 35 | // WorkloadDefinitions. 36 | type WorkloadDefinitionInformer interface { 37 | Informer() cache.SharedIndexInformer 38 | Lister() v1beta1.WorkloadDefinitionLister 39 | } 40 | 41 | type workloadDefinitionInformer struct { 42 | factory internalinterfaces.SharedInformerFactory 43 | tweakListOptions internalinterfaces.TweakListOptionsFunc 44 | namespace string 45 | } 46 | 47 | // NewWorkloadDefinitionInformer constructs a new informer for WorkloadDefinition 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 NewWorkloadDefinitionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 51 | return NewFilteredWorkloadDefinitionInformer(client, namespace, resyncPeriod, indexers, nil) 52 | } 53 | 54 | // NewFilteredWorkloadDefinitionInformer constructs a new informer for WorkloadDefinition 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 NewFilteredWorkloadDefinitionInformer(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().WorkloadDefinitions(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().WorkloadDefinitions(namespace).Watch(context.TODO(), options) 71 | }, 72 | }, 73 | &coreoamdevv1beta1.WorkloadDefinition{}, 74 | resyncPeriod, 75 | indexers, 76 | ) 77 | } 78 | 79 | func (f *workloadDefinitionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 80 | return NewFilteredWorkloadDefinitionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 81 | } 82 | 83 | func (f *workloadDefinitionInformer) Informer() cache.SharedIndexInformer { 84 | return f.factory.InformerFor(&coreoamdevv1beta1.WorkloadDefinition{}, f.defaultInformer) 85 | } 86 | 87 | func (f *workloadDefinitionInformer) Lister() v1beta1.WorkloadDefinitionLister { 88 | return v1beta1.NewWorkloadDefinitionLister(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 | v1beta1 "github.com/oam-dev/kubevela-core-api/apis/core.oam.dev/v1beta1" 24 | schema "k8s.io/apimachinery/pkg/runtime/schema" 25 | cache "k8s.io/client-go/tools/cache" 26 | ) 27 | 28 | // GenericInformer is type of SharedIndexInformer which will locate and delegate to other 29 | // sharedInformers based on type 30 | type GenericInformer interface { 31 | Informer() cache.SharedIndexInformer 32 | Lister() cache.GenericLister 33 | } 34 | 35 | type genericInformer struct { 36 | informer cache.SharedIndexInformer 37 | resource schema.GroupResource 38 | } 39 | 40 | // Informer returns the SharedIndexInformer. 41 | func (f *genericInformer) Informer() cache.SharedIndexInformer { 42 | return f.informer 43 | } 44 | 45 | // Lister returns the GenericLister. 46 | func (f *genericInformer) Lister() cache.GenericLister { 47 | return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 48 | } 49 | 50 | // ForResource gives generic access to a shared informer of the matching type 51 | // TODO extend this to unknown resources with a client pool 52 | func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 53 | switch resource { 54 | // Group=core.oam.dev, Version=v1beta1 55 | case v1beta1.SchemeGroupVersion.WithResource("applications"): 56 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().Applications().Informer()}, nil 57 | case v1beta1.SchemeGroupVersion.WithResource("applicationrevisions"): 58 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ApplicationRevisions().Informer()}, nil 59 | case v1beta1.SchemeGroupVersion.WithResource("componentdefinitions"): 60 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ComponentDefinitions().Informer()}, nil 61 | case v1beta1.SchemeGroupVersion.WithResource("definitionrevisions"): 62 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().DefinitionRevisions().Informer()}, nil 63 | case v1beta1.SchemeGroupVersion.WithResource("policydefinitions"): 64 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().PolicyDefinitions().Informer()}, nil 65 | case v1beta1.SchemeGroupVersion.WithResource("resourcetrackers"): 66 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().ResourceTrackers().Informer()}, nil 67 | case v1beta1.SchemeGroupVersion.WithResource("traitdefinitions"): 68 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().TraitDefinitions().Informer()}, nil 69 | case v1beta1.SchemeGroupVersion.WithResource("workflowstepdefinitions"): 70 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().WorkflowStepDefinitions().Informer()}, nil 71 | case v1beta1.SchemeGroupVersion.WithResource("workloaddefinitions"): 72 | return &genericInformer{resource: resource.GroupResource(), informer: f.Core().V1beta1().WorkloadDefinitions().Informer()}, nil 73 | 74 | } 75 | 76 | return nil, fmt.Errorf("no informer found for %v", resource) 77 | } 78 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewApplicationLister returns a new ApplicationLister. 44 | func NewApplicationLister(indexer cache.Indexer) ApplicationLister { 45 | return &applicationLister{indexer: indexer} 46 | } 47 | 48 | // List lists all Applications in the indexer. 49 | func (s *applicationLister) List(selector labels.Selector) (ret []*v1beta1.Application, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.Application)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // Applications returns an object that can list and get Applications. 57 | func (s *applicationLister) Applications(namespace string) ApplicationNamespaceLister { 58 | return applicationNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // ApplicationNamespaceLister helps list and get Applications. 62 | // All objects returned here must be treated as read-only. 63 | type ApplicationNamespaceLister interface { 64 | // List lists all Applications in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.Application, err error) 67 | // Get retrieves the Application from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.Application, error) 70 | ApplicationNamespaceListerExpansion 71 | } 72 | 73 | // applicationNamespaceLister implements the ApplicationNamespaceLister 74 | // interface. 75 | type applicationNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all Applications in the indexer for a given namespace. 81 | func (s applicationNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Application, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.Application)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the Application from the indexer for a given namespace and name. 89 | func (s applicationNamespaceLister) Get(name string) (*v1beta1.Application, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("application"), name) 96 | } 97 | return obj.(*v1beta1.Application), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewDefinitionRevisionLister returns a new DefinitionRevisionLister. 44 | func NewDefinitionRevisionLister(indexer cache.Indexer) DefinitionRevisionLister { 45 | return &definitionRevisionLister{indexer: indexer} 46 | } 47 | 48 | // List lists all DefinitionRevisions in the indexer. 49 | func (s *definitionRevisionLister) List(selector labels.Selector) (ret []*v1beta1.DefinitionRevision, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.DefinitionRevision)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // DefinitionRevisions returns an object that can list and get DefinitionRevisions. 57 | func (s *definitionRevisionLister) DefinitionRevisions(namespace string) DefinitionRevisionNamespaceLister { 58 | return definitionRevisionNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // DefinitionRevisionNamespaceLister helps list and get DefinitionRevisions. 62 | // All objects returned here must be treated as read-only. 63 | type DefinitionRevisionNamespaceLister interface { 64 | // List lists all DefinitionRevisions in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.DefinitionRevision, err error) 67 | // Get retrieves the DefinitionRevision from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.DefinitionRevision, error) 70 | DefinitionRevisionNamespaceListerExpansion 71 | } 72 | 73 | // definitionRevisionNamespaceLister implements the DefinitionRevisionNamespaceLister 74 | // interface. 75 | type definitionRevisionNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all DefinitionRevisions in the indexer for a given namespace. 81 | func (s definitionRevisionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.DefinitionRevision, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.DefinitionRevision)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the DefinitionRevision from the indexer for a given namespace and name. 89 | func (s definitionRevisionNamespaceLister) Get(name string) (*v1beta1.DefinitionRevision, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("definitionrevision"), name) 96 | } 97 | return obj.(*v1beta1.DefinitionRevision), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewPolicyDefinitionLister returns a new PolicyDefinitionLister. 44 | func NewPolicyDefinitionLister(indexer cache.Indexer) PolicyDefinitionLister { 45 | return &policyDefinitionLister{indexer: indexer} 46 | } 47 | 48 | // List lists all PolicyDefinitions in the indexer. 49 | func (s *policyDefinitionLister) List(selector labels.Selector) (ret []*v1beta1.PolicyDefinition, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.PolicyDefinition)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // PolicyDefinitions returns an object that can list and get PolicyDefinitions. 57 | func (s *policyDefinitionLister) PolicyDefinitions(namespace string) PolicyDefinitionNamespaceLister { 58 | return policyDefinitionNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // PolicyDefinitionNamespaceLister helps list and get PolicyDefinitions. 62 | // All objects returned here must be treated as read-only. 63 | type PolicyDefinitionNamespaceLister interface { 64 | // List lists all PolicyDefinitions in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.PolicyDefinition, err error) 67 | // Get retrieves the PolicyDefinition from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.PolicyDefinition, error) 70 | PolicyDefinitionNamespaceListerExpansion 71 | } 72 | 73 | // policyDefinitionNamespaceLister implements the PolicyDefinitionNamespaceLister 74 | // interface. 75 | type policyDefinitionNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all PolicyDefinitions in the indexer for a given namespace. 81 | func (s policyDefinitionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.PolicyDefinition, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.PolicyDefinition)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the PolicyDefinition from the indexer for a given namespace and name. 89 | func (s policyDefinitionNamespaceLister) Get(name string) (*v1beta1.PolicyDefinition, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("policydefinition"), name) 96 | } 97 | return obj.(*v1beta1.PolicyDefinition), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewResourceTrackerLister returns a new ResourceTrackerLister. 44 | func NewResourceTrackerLister(indexer cache.Indexer) ResourceTrackerLister { 45 | return &resourceTrackerLister{indexer: indexer} 46 | } 47 | 48 | // List lists all ResourceTrackers in the indexer. 49 | func (s *resourceTrackerLister) List(selector labels.Selector) (ret []*v1beta1.ResourceTracker, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.ResourceTracker)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // ResourceTrackers returns an object that can list and get ResourceTrackers. 57 | func (s *resourceTrackerLister) ResourceTrackers(namespace string) ResourceTrackerNamespaceLister { 58 | return resourceTrackerNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // ResourceTrackerNamespaceLister helps list and get ResourceTrackers. 62 | // All objects returned here must be treated as read-only. 63 | type ResourceTrackerNamespaceLister interface { 64 | // List lists all ResourceTrackers in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.ResourceTracker, err error) 67 | // Get retrieves the ResourceTracker from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.ResourceTracker, error) 70 | ResourceTrackerNamespaceListerExpansion 71 | } 72 | 73 | // resourceTrackerNamespaceLister implements the ResourceTrackerNamespaceLister 74 | // interface. 75 | type resourceTrackerNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all ResourceTrackers in the indexer for a given namespace. 81 | func (s resourceTrackerNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.ResourceTracker, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.ResourceTracker)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the ResourceTracker from the indexer for a given namespace and name. 89 | func (s resourceTrackerNamespaceLister) Get(name string) (*v1beta1.ResourceTracker, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("resourcetracker"), name) 96 | } 97 | return obj.(*v1beta1.ResourceTracker), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewTraitDefinitionLister returns a new TraitDefinitionLister. 44 | func NewTraitDefinitionLister(indexer cache.Indexer) TraitDefinitionLister { 45 | return &traitDefinitionLister{indexer: indexer} 46 | } 47 | 48 | // List lists all TraitDefinitions in the indexer. 49 | func (s *traitDefinitionLister) List(selector labels.Selector) (ret []*v1beta1.TraitDefinition, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.TraitDefinition)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // TraitDefinitions returns an object that can list and get TraitDefinitions. 57 | func (s *traitDefinitionLister) TraitDefinitions(namespace string) TraitDefinitionNamespaceLister { 58 | return traitDefinitionNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // TraitDefinitionNamespaceLister helps list and get TraitDefinitions. 62 | // All objects returned here must be treated as read-only. 63 | type TraitDefinitionNamespaceLister interface { 64 | // List lists all TraitDefinitions in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.TraitDefinition, err error) 67 | // Get retrieves the TraitDefinition from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.TraitDefinition, error) 70 | TraitDefinitionNamespaceListerExpansion 71 | } 72 | 73 | // traitDefinitionNamespaceLister implements the TraitDefinitionNamespaceLister 74 | // interface. 75 | type traitDefinitionNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all TraitDefinitions in the indexer for a given namespace. 81 | func (s traitDefinitionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.TraitDefinition, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.TraitDefinition)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the TraitDefinition from the indexer for a given namespace and name. 89 | func (s traitDefinitionNamespaceLister) Get(name string) (*v1beta1.TraitDefinition, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("traitdefinition"), name) 96 | } 97 | return obj.(*v1beta1.TraitDefinition), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/api/errors" 23 | "k8s.io/apimachinery/pkg/labels" 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 | indexer cache.Indexer 41 | } 42 | 43 | // NewWorkloadDefinitionLister returns a new WorkloadDefinitionLister. 44 | func NewWorkloadDefinitionLister(indexer cache.Indexer) WorkloadDefinitionLister { 45 | return &workloadDefinitionLister{indexer: indexer} 46 | } 47 | 48 | // List lists all WorkloadDefinitions in the indexer. 49 | func (s *workloadDefinitionLister) List(selector labels.Selector) (ret []*v1beta1.WorkloadDefinition, err error) { 50 | err = cache.ListAll(s.indexer, selector, func(m interface{}) { 51 | ret = append(ret, m.(*v1beta1.WorkloadDefinition)) 52 | }) 53 | return ret, err 54 | } 55 | 56 | // WorkloadDefinitions returns an object that can list and get WorkloadDefinitions. 57 | func (s *workloadDefinitionLister) WorkloadDefinitions(namespace string) WorkloadDefinitionNamespaceLister { 58 | return workloadDefinitionNamespaceLister{indexer: s.indexer, namespace: namespace} 59 | } 60 | 61 | // WorkloadDefinitionNamespaceLister helps list and get WorkloadDefinitions. 62 | // All objects returned here must be treated as read-only. 63 | type WorkloadDefinitionNamespaceLister interface { 64 | // List lists all WorkloadDefinitions in the indexer for a given namespace. 65 | // Objects returned here must be treated as read-only. 66 | List(selector labels.Selector) (ret []*v1beta1.WorkloadDefinition, err error) 67 | // Get retrieves the WorkloadDefinition from the indexer for a given namespace and name. 68 | // Objects returned here must be treated as read-only. 69 | Get(name string) (*v1beta1.WorkloadDefinition, error) 70 | WorkloadDefinitionNamespaceListerExpansion 71 | } 72 | 73 | // workloadDefinitionNamespaceLister implements the WorkloadDefinitionNamespaceLister 74 | // interface. 75 | type workloadDefinitionNamespaceLister struct { 76 | indexer cache.Indexer 77 | namespace string 78 | } 79 | 80 | // List lists all WorkloadDefinitions in the indexer for a given namespace. 81 | func (s workloadDefinitionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.WorkloadDefinition, err error) { 82 | err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { 83 | ret = append(ret, m.(*v1beta1.WorkloadDefinition)) 84 | }) 85 | return ret, err 86 | } 87 | 88 | // Get retrieves the WorkloadDefinition from the indexer for a given namespace and name. 89 | func (s workloadDefinitionNamespaceLister) Get(name string) (*v1beta1.WorkloadDefinition, error) { 90 | obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) 91 | if err != nil { 92 | return nil, err 93 | } 94 | if !exists { 95 | return nil, errors.NewNotFound(v1beta1.Resource("workloaddefinition"), name) 96 | } 97 | return obj.(*v1beta1.WorkloadDefinition), nil 98 | } 99 | -------------------------------------------------------------------------------- /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/oam/auxliary_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 oam 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/require" 23 | v1 "k8s.io/api/apps/v1" 24 | ) 25 | 26 | func TestGetSetCluster(t *testing.T) { 27 | r := require.New(t) 28 | deploy := &v1.Deployment{} 29 | r.Equal("", GetCluster(deploy)) 30 | clusterName := "cluster" 31 | SetClusterIfEmpty(deploy, clusterName) 32 | r.Equal(clusterName, GetCluster(deploy)) 33 | } 34 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | return strings.Contains(err.Error(), "failed to lookup value") && strings.Contains(err.Error(), "not exist") 42 | } 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------