feat: generate openapi and applyconfig extract APIs

Signed-off-by: Luca Burgazzoli <lburgazzoli@gmail.com>
This commit is contained in:
Luca Burgazzoli 2024-10-03 10:43:41 +02:00 committed by Luca Burgazzoli
parent 92f9481086
commit 236cdd1f18
37 changed files with 4070 additions and 817 deletions

View File

@ -30,9 +30,7 @@ HELM_CHART_URL ?= https://raw.githubusercontent.com/dapr/helm-charts/master/dapr
OPENSHIFT_VERSIONS ?= v4.12
## Tool Versions
CODEGEN_VERSION ?= v0.30.5
KUSTOMIZE_VERSION ?= v5.4.3
CONTROLLER_TOOLS_VERSION ?= v0.16.3
KIND_VERSION ?= v0.24.0
KIND_IMAGE_VERSION ?= v1.30.4
LINTER_VERSION ?= v1.61.0
@ -52,7 +50,6 @@ OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
OPM ?= $(LOCALBIN)/opm
GOVULNCHECK ?= $(LOCALBIN)/govulncheck
KO ?= $(LOCALBIN)/ko
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
@ -107,11 +104,11 @@ update/dapr: ## Update the helm chart.
##@ Development
.PHONY: manifests
manifests: codegen-tools-install ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(PROJECT_PATH)/hack/scripts/gen_crd.sh $(PROJECT_PATH)
manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(PROJECT_PATH)/hack/scripts/gen_manifests.sh $(PROJECT_PATH)
.PHONY: generate
generate: codegen-tools-install ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(PROJECT_PATH)/hack/scripts/gen_res.sh $(PROJECT_PATH)
$(PROJECT_PATH)/hack/scripts/gen_client.sh $(PROJECT_PATH)
@ -319,13 +316,6 @@ $(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || \
GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.PHONY: golangci-lint
golangci-lint: $(LINTER)
$(LINTER): $(LOCALBIN)
@ -362,11 +352,6 @@ $(GOVULNCHECK): $(LOCALBIN)
@test -s $(GOVULNCHECK) || \
GOBIN=$(LOCALBIN) go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)
.PHONY: codegen-tools-install
codegen-tools-install: $(LOCALBIN)
@echo "Installing code gen tools"
$(PROJECT_PATH)/hack/scripts/install_gen_tools.sh $(PROJECT_PATH) $(CODEGEN_VERSION) $(CONTROLLER_TOOLS_VERSION)
.PHONY: operator-sdk
operator-sdk: $(OPERATOR_SDK)
$(OPERATOR_SDK): $(LOCALBIN)

View File

@ -0,0 +1,7 @@
// Package v1alpha1 contains API Schema definitions for the operator.dapr.io API group.
//
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
// +groupName=operator.dapr.io
package v1alpha1

View File

@ -20,6 +20,8 @@ import (
"flag"
"os"
"github.com/dapr/kubernetes-operator/cmd/modelschema"
"github.com/dapr/kubernetes-operator/cmd/run"
"github.com/dapr/kubernetes-operator/pkg/logger"
@ -36,7 +38,8 @@ func main() {
},
}
rootCmd.AddCommand(run.NewRunCmd())
rootCmd.AddCommand(modelschema.NewCmd())
rootCmd.AddCommand(run.NewCmd())
fs := flag.NewFlagSet("", flag.PanicOnError)

View File

@ -0,0 +1,89 @@
package modelschema
import (
"encoding/json"
"fmt"
"os"
"strings"
"github.com/dapr/kubernetes-operator/pkg/generated/openapi"
"github.com/spf13/cobra"
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/validation/spec"
)
const (
cmdName = "modelschema"
)
func NewCmd() *cobra.Command {
// Outputs openAPI schema JSON containing the schema definitions in zz_generated.openapi.go.
cmd := cobra.Command{
Use: cmdName,
Short: cmdName,
RunE: func(cmd *cobra.Command, args []string) error {
refFunc := func(name string) spec.Ref {
return spec.MustCreateRef("#/definitions/" + friendlyName(name))
}
defs := openapi.GetOpenAPIDefinitions(refFunc)
schemaDefs := make(map[string]spec.Schema, len(defs))
for k, v := range defs {
// Replace top-level schema with v2 if a v2 schema is embedded
// so that the output of this program is always in OpenAPI v2.
// This is done by looking up an extension that marks the embedded v2
// schema, and, if the v2 schema is found, make it the resulting schema for
// the type.
if schema, ok := v.Schema.Extensions[common.ExtensionV2Schema]; ok {
if v2Schema, isOpenAPISchema := schema.(spec.Schema); isOpenAPISchema {
schemaDefs[friendlyName(k)] = v2Schema
continue
}
}
schemaDefs[friendlyName(k)] = v.Schema
}
data, err := json.Marshal(&spec.Swagger{
SwaggerProps: spec.SwaggerProps{
Definitions: schemaDefs,
Info: &spec.Info{
InfoProps: spec.InfoProps{
Title: "Gateway API",
Version: "unversioned",
},
},
Swagger: "2.0",
},
})
if err != nil {
return fmt.Errorf("error serializing api definitions: %w", err)
}
os.Stdout.Write(data)
return nil
},
}
return &cmd
}
// From k8s.io/apiserver/pkg/endpoints/openapi/openapi.go.
func friendlyName(name string) string {
nameParts := strings.Split(name, "/")
// Reverse first part. e.g., io.k8s... instead of k8s.io...
if len(nameParts) > 0 && strings.Contains(nameParts[0], ".") {
parts := strings.Split(nameParts[0], ".")
for i, j := 0, len(parts)-1; i < j; i, j = i+1, j-1 {
parts[i], parts[j] = parts[j], parts[i]
}
nameParts[0] = strings.Join(parts, ".")
}
return strings.Join(nameParts, ".")
}

View File

@ -23,37 +23,11 @@ import (
"github.com/dapr/kubernetes-operator/pkg/controller"
)
//nolint:gochecknoinits
func init() {
utilruntime.Must(daprApi.AddToScheme(controller.Scheme))
utilruntime.Must(apiextensions.AddToScheme(controller.Scheme))
}
const (
cmdName = "run"
)
// computeListWatch computes the cache's ListWatch by object.
func computeListWatch() (map[rtclient.Object]rtcache.ByObject, error) {
selector, err := helm.ReleaseSelector()
if err != nil {
return nil, fmt.Errorf("unable to compute cache's watch selector: %w", err)
}
selectors := map[rtclient.Object]rtcache.ByObject{
// k8s
&rbacv1.ClusterRole{}: {Label: selector},
&rbacv1.ClusterRoleBinding{}: {Label: selector},
&rbacv1.Role{}: {Label: selector},
&rbacv1.RoleBinding{}: {Label: selector},
&admregv1.MutatingWebhookConfiguration{}: {Label: selector},
&corev1.Secret{}: {Label: selector},
&corev1.Service{}: {Label: selector},
&corev1.ServiceAccount{}: {Label: selector},
&appsv1.StatefulSet{}: {Label: selector},
&appsv1.Deployment{}: {Label: selector},
}
return selectors, nil
}
func NewRunCmd() *cobra.Command {
func NewCmd() *cobra.Command {
co := controller.Options{
MetricsAddr: ":8080",
ProbeAddr: ":8081",
@ -69,8 +43,8 @@ func NewRunCmd() *cobra.Command {
}
cmd := cobra.Command{
Use: "run",
Short: "run",
Use: cmdName,
Short: cmdName,
RunE: func(cmd *cobra.Command, args []string) error {
selector, err := computeListWatch()
if err != nil {
@ -114,3 +88,33 @@ func NewRunCmd() *cobra.Command {
return &cmd
}
//nolint:gochecknoinits
func init() {
utilruntime.Must(daprApi.AddToScheme(controller.Scheme))
utilruntime.Must(apiextensions.AddToScheme(controller.Scheme))
}
// computeListWatch computes the cache's ListWatch by object.
func computeListWatch() (map[rtclient.Object]rtcache.ByObject, error) {
selector, err := helm.ReleaseSelector()
if err != nil {
return nil, fmt.Errorf("unable to compute cache's watch selector: %w", err)
}
selectors := map[rtclient.Object]rtcache.ByObject{
// k8s
&rbacv1.ClusterRole{}: {Label: selector},
&rbacv1.ClusterRoleBinding{}: {Label: selector},
&rbacv1.Role{}: {Label: selector},
&rbacv1.RoleBinding{}: {Label: selector},
&admregv1.MutatingWebhookConfiguration{}: {Label: selector},
&corev1.Secret{}: {Label: selector},
&corev1.Service{}: {Label: selector},
&corev1.ServiceAccount{}: {Label: selector},
&appsv1.StatefulSet{}: {Label: selector},
&appsv1.Deployment{}: {Label: selector},
}
return selectors, nil
}

8
go.mod
View File

@ -23,8 +23,11 @@ require (
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/code-generator v0.31.1
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/controller-tools v0.16.3
sigs.k8s.io/structured-merge-diff/v4 v4.4.1
)
@ -71,6 +74,7 @@ require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@ -146,12 +150,14 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.24.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
@ -162,7 +168,7 @@ require (
k8s.io/apiserver v0.31.1 // indirect
k8s.io/cli-runtime v0.31.0 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/kubectl v0.31.0 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
oras.land/oras-go v1.2.5 // indirect

23
go.sum
View File

@ -147,6 +147,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA=
github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@ -293,6 +295,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8=
@ -362,11 +368,16 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
@ -432,8 +443,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -526,6 +537,8 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
@ -551,8 +564,12 @@ k8s.io/cli-runtime v0.31.0 h1:V2Q1gj1u3/WfhD475HBQrIYsoryg/LrhhK4RwpN+DhA=
k8s.io/cli-runtime v0.31.0/go.mod h1:vg3H94wsubuvWfSmStDbekvbla5vFGC+zLWqcf+bGDw=
k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0=
k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg=
k8s.io/code-generator v0.31.1 h1:GvkRZEP2g2UnB2QKT2Dgc/kYxIkDxCHENv2Q1itioVs=
k8s.io/code-generator v0.31.1/go.mod h1:oL2ky46L48osNqqZAeOcWWy0S5BXj50vVdwOtTefqIs=
k8s.io/component-base v0.31.1 h1:UpOepcrX3rQ3ab5NB6g5iP0tvsgJWzxTyAo20sgYSy8=
k8s.io/component-base v0.31.1/go.mod h1:WGeaw7t/kTsqpVTaCoVEtillbqAhF2/JgvO0LDOMa0w=
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo=
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM=
@ -565,6 +582,8 @@ oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo=
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/controller-tools v0.16.3 h1:z48C5/d4jCVQQvtiSBL5MYyZ3EO2eFIOXrIKMgHVhFY=
sigs.k8s.io/controller-tools v0.16.3/go.mod h1:AEj6k+w1kYpLZv2einOH3mj52ips4W/6FUjnB5tkJGs=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kustomize/api v0.17.2 h1:E7/Fjk7V5fboiuijoZHgs4aHuexi5Y2loXlVOAVAG5g=

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "project root is expected"
@ -12,15 +12,27 @@ mkdir -p "${PROJECT_ROOT}/pkg/client"
echo "tmp dir: $TMP_DIR"
echo "applyconfiguration-gen"
"${PROJECT_ROOT}"/bin/applyconfiguration-gen \
echo "Generating openapi schema"
go run k8s.io/kube-openapi/cmd/openapi-gen \
--output-file zz_generated.openapi.go \
--output-dir "pkg/generated/openapi" \
--output-pkg "github.com/dapr/kubernetes-operator/pkg/generated/openapi" \
github.com/dapr/kubernetes-operator/api/operator/v1alpha1 \
k8s.io/apimachinery/pkg/apis/meta/v1 \
k8s.io/apimachinery/pkg/runtime \
k8s.io/apimachinery/pkg/version
echo "Generate ApplyConfiguration"
go run k8s.io/code-generator/cmd/applyconfiguration-gen \
--openapi-schema <(go run ${PROJECT_ROOT}/cmd/main.go modelschema) \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-dir="${TMP_DIR}/client/applyconfiguration" \
--output-pkg=github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration \
github.com/dapr/kubernetes-operator/api/operator/v1alpha1
echo "client-gen"
"${PROJECT_ROOT}"/bin/client-gen \
echo "Generate client"
go run k8s.io/code-generator/cmd/client-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-dir="${TMP_DIR}/client/clientset" \
--input-base=github.com/dapr/kubernetes-operator/api \
@ -30,15 +42,15 @@ echo "client-gen"
--apply-configuration-package=github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration \
--output-pkg=github.com/dapr/kubernetes-operator/pkg/client/clientset
echo "lister-gen"
"${PROJECT_ROOT}"/bin/lister-gen \
echo "Generate lister"
go run k8s.io/code-generator/cmd/lister-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-dir="${TMP_DIR}/client/listers" \
--output-pkg=github.com/dapr/kubernetes-operator/pkg/client/listers \
github.com/dapr/kubernetes-operator/api/operator/v1alpha1
echo "informer-gen"
"${PROJECT_ROOT}"/bin/informer-gen \
echo "Generate informer"
go run k8s.io/code-generator/cmd/informer-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-dir="${TMP_DIR}/client/informers" \
--versioned-clientset-package=github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned \

View File

@ -1,12 +0,0 @@
#!/bin/sh
if [ $# -ne 1 ]; then
echo "project root is expected"
fi
PROJECT_ROOT="$1"
"${PROJECT_ROOT}"/bin/controller-gen \
rbac:roleName=dapr-control-plane-role \
crd \
paths="./..." output:crd:artifacts:config="${PROJECT_ROOT}/config/crd/bases"

13
hack/scripts/gen_manifests.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
if [ $# -ne 1 ]; then
echo "project root is expected"
fi
PROJECT_ROOT="$1"
go run sigs.k8s.io/controller-tools/cmd/controller-gen \
rbac:roleName=dapr-control-plane-role \
crd \
paths="{./api/operator/...,./internal/...}" \
output:crd:artifacts:config="${PROJECT_ROOT}/config/crd/bases"

View File

@ -6,6 +6,6 @@ fi
PROJECT_ROOT="$1"
"${PROJECT_ROOT}"/bin/controller-gen \
go run sigs.k8s.io/controller-tools/cmd/controller-gen \
object:headerFile="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
paths="./..."
paths="{./api/operator/...,./internal/...}"

View File

@ -1,29 +0,0 @@
#!/bin/sh
if [ $# -ne 3 ]; then
echo "project root, codegen version and is expected"
fi
PROJECT_ROOT="$1"
CODEGEN_VERSION="$2"
CONTROLLER_TOOLS_VERSION="$3"
if [ ! -f "${PROJECT_ROOT}/bin/applyconfiguration-gen" ]; then
GOBIN="${PROJECT_ROOT}/bin" go install k8s.io/code-generator/cmd/applyconfiguration-gen@"${CODEGEN_VERSION}"
fi
if [ ! -f "${PROJECT_ROOT}/bin/client-gen" ]; then
GOBIN="${PROJECT_ROOT}/bin" go install k8s.io/code-generator/cmd/client-gen@"${CODEGEN_VERSION}"
fi
if [ ! -f "${PROJECT_ROOT}/bin/lister-gen" ]; then
GOBIN="${PROJECT_ROOT}/bin" go install k8s.io/code-generator/cmd/lister-gen@"${CODEGEN_VERSION}"
fi
if [ ! -f "${PROJECT_ROOT}/bin/informer-gen" ]; then
GOBIN="${PROJECT_ROOT}/bin" go install k8s.io/code-generator/cmd/informer-gen@"${CODEGEN_VERSION}"
fi
if [ ! -f "${PROJECT_ROOT}/bin/controller-gen" ]; then
GOBIN="${PROJECT_ROOT}/bin" go install sigs.k8s.io/controller-tools/cmd/controller-gen@"${CONTROLLER_TOOLS_VERSION}"
fi

View File

@ -38,6 +38,344 @@ func Parser() *typed.Parser {
var parserOnce sync.Once
var parser *typed.Parser
var schemaYAML = typed.YAMLObject(`types:
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartMeta
map:
fields:
- name: name
type:
scalar: string
- name: repo
type:
scalar: string
- name: version
type:
scalar: string
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartSpec
map:
fields:
- name: name
type:
scalar: string
- name: repo
type:
scalar: string
- name: secret
type:
scalar: string
- name: version
type:
scalar: string
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlane
map:
fields:
- name: apiVersion
type:
scalar: string
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: spec
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlaneSpec
default: {}
- name: status
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlaneStatus
default: {}
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlaneSpec
map:
fields:
- name: values
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.JSON
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlaneStatus
map:
fields:
- name: chart
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartMeta
- name: conditions
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition
elementRelationship: atomic
- name: observedGeneration
type:
scalar: numeric
- name: phase
type:
scalar: string
default: ""
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControl
map:
fields:
- name: apiVersion
type:
scalar: string
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: spec
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControlSpec
default: {}
- name: status
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControlStatus
default: {}
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControlSpec
map:
elementType:
scalar: untyped
list:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
map:
elementType:
namedType: __untyped_deduced_
elementRelationship: separable
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControlStatus
map:
fields:
- name: chart
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartMeta
- name: conditions
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition
elementRelationship: atomic
- name: observedGeneration
type:
scalar: numeric
- name: phase
type:
scalar: string
default: ""
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstance
map:
fields:
- name: apiVersion
type:
scalar: string
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: spec
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstanceSpec
default: {}
- name: status
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstanceStatus
default: {}
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstanceSpec
map:
fields:
- name: chart
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartSpec
- name: values
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.JSON
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstanceStatus
map:
fields:
- name: chart
type:
namedType: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.ChartMeta
- name: conditions
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition
elementRelationship: atomic
- name: observedGeneration
type:
scalar: numeric
- name: phase
type:
scalar: string
default: ""
- name: com.github.dapr.kubernetes-operator.api.operator.v1alpha1.JSON
map:
elementType:
scalar: untyped
list:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
map:
elementType:
namedType: __untyped_deduced_
elementRelationship: separable
- name: io.k8s.apimachinery.pkg.apis.meta.v1.Condition
map:
fields:
- name: lastTransitionTime
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time
- name: message
type:
scalar: string
default: ""
- name: observedGeneration
type:
scalar: numeric
- name: reason
type:
scalar: string
default: ""
- name: status
type:
scalar: string
default: ""
- name: type
type:
scalar: string
default: ""
- name: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1
map:
elementType:
scalar: untyped
list:
elementType:
namedType: __untyped_atomic_
elementRelationship: atomic
map:
elementType:
namedType: __untyped_deduced_
elementRelationship: separable
- name: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry
map:
fields:
- name: apiVersion
type:
scalar: string
- name: fieldsType
type:
scalar: string
- name: fieldsV1
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1
- name: manager
type:
scalar: string
- name: operation
type:
scalar: string
- name: subresource
type:
scalar: string
- name: time
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time
- name: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
map:
fields:
- name: annotations
type:
map:
elementType:
scalar: string
- name: creationTimestamp
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time
- name: deletionGracePeriodSeconds
type:
scalar: numeric
- name: deletionTimestamp
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time
- name: finalizers
type:
list:
elementType:
scalar: string
elementRelationship: associative
- name: generateName
type:
scalar: string
- name: generation
type:
scalar: numeric
- name: labels
type:
map:
elementType:
scalar: string
- name: managedFields
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry
elementRelationship: atomic
- name: name
type:
scalar: string
- name: namespace
type:
scalar: string
- name: ownerReferences
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference
elementRelationship: associative
keys:
- uid
- name: resourceVersion
type:
scalar: string
- name: selfLink
type:
scalar: string
- name: uid
type:
scalar: string
- name: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference
map:
fields:
- name: apiVersion
type:
scalar: string
default: ""
- name: blockOwnerDeletion
type:
scalar: boolean
- name: controller
type:
scalar: boolean
- name: kind
type:
scalar: string
default: ""
- name: name
type:
scalar: string
default: ""
- name: uid
type:
scalar: string
default: ""
elementRelationship: atomic
- name: io.k8s.apimachinery.pkg.apis.meta.v1.Time
scalar: untyped
- name: __untyped_atomic_
scalar: untyped
list:

View File

@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1
// ChartMetaApplyConfiguration represents an declarative configuration of the ChartMeta type for use
// ChartMetaApplyConfiguration represents a declarative configuration of the ChartMeta type for use
// with apply.
type ChartMetaApplyConfiguration struct {
Repo *string `json:"repo,omitempty"`
@ -25,7 +25,7 @@ type ChartMetaApplyConfiguration struct {
Version *string `json:"version,omitempty"`
}
// ChartMetaApplyConfiguration constructs an declarative configuration of the ChartMeta type for use with
// ChartMetaApplyConfiguration constructs a declarative configuration of the ChartMeta type for use with
// apply.
func ChartMeta() *ChartMetaApplyConfiguration {
return &ChartMetaApplyConfiguration{}

View File

@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1
// ChartSpecApplyConfiguration represents an declarative configuration of the ChartSpec type for use
// ChartSpecApplyConfiguration represents a declarative configuration of the ChartSpec type for use
// with apply.
type ChartSpecApplyConfiguration struct {
Repo *string `json:"repo,omitempty"`
@ -26,7 +26,7 @@ type ChartSpecApplyConfiguration struct {
Secret *string `json:"secret,omitempty"`
}
// ChartSpecApplyConfiguration constructs an declarative configuration of the ChartSpec type for use with
// ChartSpecApplyConfiguration constructs a declarative configuration of the ChartSpec type for use with
// apply.
func ChartSpec() *ChartSpecApplyConfiguration {
return &ChartSpecApplyConfiguration{}

View File

@ -18,12 +18,15 @@ limitations under the License.
package v1alpha1
import (
operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
internal "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/internal"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprControlPlaneApplyConfiguration represents an declarative configuration of the DaprControlPlane type for use
// DaprControlPlaneApplyConfiguration represents a declarative configuration of the DaprControlPlane type for use
// with apply.
type DaprControlPlaneApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
@ -32,7 +35,7 @@ type DaprControlPlaneApplyConfiguration struct {
Status *DaprControlPlaneStatusApplyConfiguration `json:"status,omitempty"`
}
// DaprControlPlane constructs an declarative configuration of the DaprControlPlane type for use with
// DaprControlPlane constructs a declarative configuration of the DaprControlPlane type for use with
// apply.
func DaprControlPlane(name, namespace string) *DaprControlPlaneApplyConfiguration {
b := &DaprControlPlaneApplyConfiguration{}
@ -43,6 +46,42 @@ func DaprControlPlane(name, namespace string) *DaprControlPlaneApplyConfiguratio
return b
}
// ExtractDaprControlPlane extracts the applied configuration owned by fieldManager from
// daprControlPlane. If no managedFields are found in daprControlPlane for fieldManager, a
// DaprControlPlaneApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// daprControlPlane must be a unmodified DaprControlPlane API object that was retrieved from the Kubernetes API.
// ExtractDaprControlPlane provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractDaprControlPlane(daprControlPlane *operatorv1alpha1.DaprControlPlane, fieldManager string) (*DaprControlPlaneApplyConfiguration, error) {
return extractDaprControlPlane(daprControlPlane, fieldManager, "")
}
// ExtractDaprControlPlaneStatus is the same as ExtractDaprControlPlane except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractDaprControlPlaneStatus(daprControlPlane *operatorv1alpha1.DaprControlPlane, fieldManager string) (*DaprControlPlaneApplyConfiguration, error) {
return extractDaprControlPlane(daprControlPlane, fieldManager, "status")
}
func extractDaprControlPlane(daprControlPlane *operatorv1alpha1.DaprControlPlane, fieldManager string, subresource string) (*DaprControlPlaneApplyConfiguration, error) {
b := &DaprControlPlaneApplyConfiguration{}
err := managedfields.ExtractInto(daprControlPlane, internal.Parser().Type("com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprControlPlane"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(daprControlPlane.Name)
b.WithNamespace(daprControlPlane.Namespace)
b.WithKind("DaprControlPlane")
b.WithAPIVersion("operator.dapr.io/v1alpha1")
return b, nil
}
// WithKind sets the Kind field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Kind field is set to the value of the last call.
@ -216,3 +255,9 @@ func (b *DaprControlPlaneApplyConfiguration) WithStatus(value *DaprControlPlaneS
b.Status = value
return b
}
// GetName retrieves the value of the Name field in the declarative configuration.
func (b *DaprControlPlaneApplyConfiguration) GetName() *string {
b.ensureObjectMetaApplyConfigurationExists()
return b.Name
}

View File

@ -17,13 +17,13 @@ limitations under the License.
package v1alpha1
// DaprControlPlaneSpecApplyConfiguration represents an declarative configuration of the DaprControlPlaneSpec type for use
// DaprControlPlaneSpecApplyConfiguration represents a declarative configuration of the DaprControlPlaneSpec type for use
// with apply.
type DaprControlPlaneSpecApplyConfiguration struct {
Values *JSONApplyConfiguration `json:"values,omitempty"`
}
// DaprControlPlaneSpecApplyConfiguration constructs an declarative configuration of the DaprControlPlaneSpec type for use with
// DaprControlPlaneSpecApplyConfiguration constructs a declarative configuration of the DaprControlPlaneSpec type for use with
// apply.
func DaprControlPlaneSpec() *DaprControlPlaneSpecApplyConfiguration {
return &DaprControlPlaneSpecApplyConfiguration{}

View File

@ -21,14 +21,14 @@ import (
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprControlPlaneStatusApplyConfiguration represents an declarative configuration of the DaprControlPlaneStatus type for use
// DaprControlPlaneStatusApplyConfiguration represents a declarative configuration of the DaprControlPlaneStatus type for use
// with apply.
type DaprControlPlaneStatusApplyConfiguration struct {
StatusApplyConfiguration `json:",inline"`
Chart *ChartMetaApplyConfiguration `json:"chart,omitempty"`
}
// DaprControlPlaneStatusApplyConfiguration constructs an declarative configuration of the DaprControlPlaneStatus type for use with
// DaprControlPlaneStatusApplyConfiguration constructs a declarative configuration of the DaprControlPlaneStatus type for use with
// apply.
func DaprControlPlaneStatus() *DaprControlPlaneStatusApplyConfiguration {
return &DaprControlPlaneStatusApplyConfiguration{}

View File

@ -19,12 +19,14 @@ package v1alpha1
import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
internal "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/internal"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprCruiseControlApplyConfiguration represents an declarative configuration of the DaprCruiseControl type for use
// DaprCruiseControlApplyConfiguration represents a declarative configuration of the DaprCruiseControl type for use
// with apply.
type DaprCruiseControlApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
@ -33,7 +35,7 @@ type DaprCruiseControlApplyConfiguration struct {
Status *DaprCruiseControlStatusApplyConfiguration `json:"status,omitempty"`
}
// DaprCruiseControl constructs an declarative configuration of the DaprCruiseControl type for use with
// DaprCruiseControl constructs a declarative configuration of the DaprCruiseControl type for use with
// apply.
func DaprCruiseControl(name, namespace string) *DaprCruiseControlApplyConfiguration {
b := &DaprCruiseControlApplyConfiguration{}
@ -44,6 +46,42 @@ func DaprCruiseControl(name, namespace string) *DaprCruiseControlApplyConfigurat
return b
}
// ExtractDaprCruiseControl extracts the applied configuration owned by fieldManager from
// daprCruiseControl. If no managedFields are found in daprCruiseControl for fieldManager, a
// DaprCruiseControlApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// daprCruiseControl must be a unmodified DaprCruiseControl API object that was retrieved from the Kubernetes API.
// ExtractDaprCruiseControl provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractDaprCruiseControl(daprCruiseControl *v1alpha1.DaprCruiseControl, fieldManager string) (*DaprCruiseControlApplyConfiguration, error) {
return extractDaprCruiseControl(daprCruiseControl, fieldManager, "")
}
// ExtractDaprCruiseControlStatus is the same as ExtractDaprCruiseControl except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractDaprCruiseControlStatus(daprCruiseControl *v1alpha1.DaprCruiseControl, fieldManager string) (*DaprCruiseControlApplyConfiguration, error) {
return extractDaprCruiseControl(daprCruiseControl, fieldManager, "status")
}
func extractDaprCruiseControl(daprCruiseControl *v1alpha1.DaprCruiseControl, fieldManager string, subresource string) (*DaprCruiseControlApplyConfiguration, error) {
b := &DaprCruiseControlApplyConfiguration{}
err := managedfields.ExtractInto(daprCruiseControl, internal.Parser().Type("com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprCruiseControl"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(daprCruiseControl.Name)
b.WithNamespace(daprCruiseControl.Namespace)
b.WithKind("DaprCruiseControl")
b.WithAPIVersion("operator.dapr.io/v1alpha1")
return b, nil
}
// WithKind sets the Kind field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Kind field is set to the value of the last call.
@ -217,3 +255,9 @@ func (b *DaprCruiseControlApplyConfiguration) WithStatus(value *DaprCruiseContro
b.Status = value
return b
}
// GetName retrieves the value of the Name field in the declarative configuration.
func (b *DaprCruiseControlApplyConfiguration) GetName() *string {
b.ensureObjectMetaApplyConfigurationExists()
return b.Name
}

View File

@ -21,14 +21,14 @@ import (
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprCruiseControlStatusApplyConfiguration represents an declarative configuration of the DaprCruiseControlStatus type for use
// DaprCruiseControlStatusApplyConfiguration represents a declarative configuration of the DaprCruiseControlStatus type for use
// with apply.
type DaprCruiseControlStatusApplyConfiguration struct {
StatusApplyConfiguration `json:",inline"`
Chart *ChartMetaApplyConfiguration `json:"chart,omitempty"`
}
// DaprCruiseControlStatusApplyConfiguration constructs an declarative configuration of the DaprCruiseControlStatus type for use with
// DaprCruiseControlStatusApplyConfiguration constructs a declarative configuration of the DaprCruiseControlStatus type for use with
// apply.
func DaprCruiseControlStatus() *DaprCruiseControlStatusApplyConfiguration {
return &DaprCruiseControlStatusApplyConfiguration{}

View File

@ -18,12 +18,15 @@ limitations under the License.
package v1alpha1
import (
operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
internal "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/internal"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprInstanceApplyConfiguration represents an declarative configuration of the DaprInstance type for use
// DaprInstanceApplyConfiguration represents a declarative configuration of the DaprInstance type for use
// with apply.
type DaprInstanceApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
@ -32,7 +35,7 @@ type DaprInstanceApplyConfiguration struct {
Status *DaprInstanceStatusApplyConfiguration `json:"status,omitempty"`
}
// DaprInstance constructs an declarative configuration of the DaprInstance type for use with
// DaprInstance constructs a declarative configuration of the DaprInstance type for use with
// apply.
func DaprInstance(name, namespace string) *DaprInstanceApplyConfiguration {
b := &DaprInstanceApplyConfiguration{}
@ -43,6 +46,42 @@ func DaprInstance(name, namespace string) *DaprInstanceApplyConfiguration {
return b
}
// ExtractDaprInstance extracts the applied configuration owned by fieldManager from
// daprInstance. If no managedFields are found in daprInstance for fieldManager, a
// DaprInstanceApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// daprInstance must be a unmodified DaprInstance API object that was retrieved from the Kubernetes API.
// ExtractDaprInstance provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractDaprInstance(daprInstance *operatorv1alpha1.DaprInstance, fieldManager string) (*DaprInstanceApplyConfiguration, error) {
return extractDaprInstance(daprInstance, fieldManager, "")
}
// ExtractDaprInstanceStatus is the same as ExtractDaprInstance except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractDaprInstanceStatus(daprInstance *operatorv1alpha1.DaprInstance, fieldManager string) (*DaprInstanceApplyConfiguration, error) {
return extractDaprInstance(daprInstance, fieldManager, "status")
}
func extractDaprInstance(daprInstance *operatorv1alpha1.DaprInstance, fieldManager string, subresource string) (*DaprInstanceApplyConfiguration, error) {
b := &DaprInstanceApplyConfiguration{}
err := managedfields.ExtractInto(daprInstance, internal.Parser().Type("com.github.dapr.kubernetes-operator.api.operator.v1alpha1.DaprInstance"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(daprInstance.Name)
b.WithNamespace(daprInstance.Namespace)
b.WithKind("DaprInstance")
b.WithAPIVersion("operator.dapr.io/v1alpha1")
return b, nil
}
// WithKind sets the Kind field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Kind field is set to the value of the last call.
@ -216,3 +255,9 @@ func (b *DaprInstanceApplyConfiguration) WithStatus(value *DaprInstanceStatusApp
b.Status = value
return b
}
// GetName retrieves the value of the Name field in the declarative configuration.
func (b *DaprInstanceApplyConfiguration) GetName() *string {
b.ensureObjectMetaApplyConfigurationExists()
return b.Name
}

View File

@ -17,14 +17,14 @@ limitations under the License.
package v1alpha1
// DaprInstanceSpecApplyConfiguration represents an declarative configuration of the DaprInstanceSpec type for use
// DaprInstanceSpecApplyConfiguration represents a declarative configuration of the DaprInstanceSpec type for use
// with apply.
type DaprInstanceSpecApplyConfiguration struct {
Chart *ChartSpecApplyConfiguration `json:"chart,omitempty"`
Values *JSONApplyConfiguration `json:"values,omitempty"`
}
// DaprInstanceSpecApplyConfiguration constructs an declarative configuration of the DaprInstanceSpec type for use with
// DaprInstanceSpecApplyConfiguration constructs a declarative configuration of the DaprInstanceSpec type for use with
// apply.
func DaprInstanceSpec() *DaprInstanceSpecApplyConfiguration {
return &DaprInstanceSpecApplyConfiguration{}

View File

@ -21,14 +21,14 @@ import (
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// DaprInstanceStatusApplyConfiguration represents an declarative configuration of the DaprInstanceStatus type for use
// DaprInstanceStatusApplyConfiguration represents a declarative configuration of the DaprInstanceStatus type for use
// with apply.
type DaprInstanceStatusApplyConfiguration struct {
StatusApplyConfiguration `json:",inline"`
Chart *ChartMetaApplyConfiguration `json:"chart,omitempty"`
}
// DaprInstanceStatusApplyConfiguration constructs an declarative configuration of the DaprInstanceStatus type for use with
// DaprInstanceStatusApplyConfiguration constructs a declarative configuration of the DaprInstanceStatus type for use with
// apply.
func DaprInstanceStatus() *DaprInstanceStatusApplyConfiguration {
return &DaprInstanceStatusApplyConfiguration{}

View File

@ -21,13 +21,13 @@ import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
)
// JSONApplyConfiguration represents an declarative configuration of the JSON type for use
// JSONApplyConfiguration represents a declarative configuration of the JSON type for use
// with apply.
type JSONApplyConfiguration struct {
v1alpha1.RawMessage `json:",inline"`
}
// JSONApplyConfiguration constructs an declarative configuration of the JSON type for use with
// JSONApplyConfiguration constructs a declarative configuration of the JSON type for use with
// apply.
func JSON() *JSONApplyConfiguration {
return &JSONApplyConfiguration{}

View File

@ -21,7 +21,7 @@ import (
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// StatusApplyConfiguration represents an declarative configuration of the Status type for use
// StatusApplyConfiguration represents a declarative configuration of the Status type for use
// with apply.
type StatusApplyConfiguration struct {
Phase *string `json:"phase,omitempty"`
@ -29,7 +29,7 @@ type StatusApplyConfiguration struct {
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
}
// StatusApplyConfiguration constructs an declarative configuration of the Status type for use with
// StatusApplyConfiguration constructs a declarative configuration of the Status type for use with
// apply.
func Status() *StatusApplyConfiguration {
return &StatusApplyConfiguration{}

View File

@ -19,15 +19,18 @@ package applyconfiguration
import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
internal "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/internal"
operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
testing "k8s.io/client-go/testing"
)
// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no
// apply configuration type exists for the given GroupVersionKind.
func ForKind(kind schema.GroupVersionKind) interface{} {
switch kind {
// Group=operator, Version=v1alpha1
// Group=operator.dapr.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithKind("ChartMeta"):
return &operatorv1alpha1.ChartMetaApplyConfiguration{}
case v1alpha1.SchemeGroupVersion.WithKind("ChartSpec"):
@ -56,3 +59,7 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
}
return nil
}
func NewTypeConverter(scheme *runtime.Scheme) *testing.TypeConverter {
return &testing.TypeConverter{Scheme: scheme, TypeResolver: internal.Parser()}
}

View File

@ -19,9 +19,6 @@ package v1alpha1
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1"
@ -29,7 +26,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
gentype "k8s.io/client-go/gentype"
)
// DaprControlPlanesGetter has a method to return a DaprControlPlaneInterface.
@ -42,6 +39,7 @@ type DaprControlPlanesGetter interface {
type DaprControlPlaneInterface interface {
Create(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.CreateOptions) (*v1alpha1.DaprControlPlane, error)
Update(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (*v1alpha1.DaprControlPlane, error)
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
UpdateStatus(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (*v1alpha1.DaprControlPlane, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
@ -50,206 +48,25 @@ type DaprControlPlaneInterface interface {
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprControlPlane, err error)
Apply(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error)
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
ApplyStatus(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error)
DaprControlPlaneExpansion
}
// daprControlPlanes implements DaprControlPlaneInterface
type daprControlPlanes struct {
client rest.Interface
ns string
*gentype.ClientWithListAndApply[*v1alpha1.DaprControlPlane, *v1alpha1.DaprControlPlaneList, *operatorv1alpha1.DaprControlPlaneApplyConfiguration]
}
// newDaprControlPlanes returns a DaprControlPlanes
func newDaprControlPlanes(c *OperatorV1alpha1Client, namespace string) *daprControlPlanes {
return &daprControlPlanes{
client: c.RESTClient(),
ns: namespace,
gentype.NewClientWithListAndApply[*v1alpha1.DaprControlPlane, *v1alpha1.DaprControlPlaneList, *operatorv1alpha1.DaprControlPlaneApplyConfiguration](
"daprcontrolplanes",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *v1alpha1.DaprControlPlane { return &v1alpha1.DaprControlPlane{} },
func() *v1alpha1.DaprControlPlaneList { return &v1alpha1.DaprControlPlaneList{} }),
}
}
// Get takes name of the daprControlPlane, and returns the corresponding daprControlPlane object, and an error if there is any.
func (c *daprControlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprControlPlane, err error) {
result = &v1alpha1.DaprControlPlane{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of DaprControlPlanes that match those selectors.
func (c *daprControlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprControlPlaneList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.DaprControlPlaneList{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprcontrolplanes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested daprControlPlanes.
func (c *daprControlPlanes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("daprcontrolplanes").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a daprControlPlane and creates it. Returns the server's representation of the daprControlPlane, and an error, if there is any.
func (c *daprControlPlanes) Create(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.CreateOptions) (result *v1alpha1.DaprControlPlane, err error) {
result = &v1alpha1.DaprControlPlane{}
err = c.client.Post().
Namespace(c.ns).
Resource("daprcontrolplanes").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprControlPlane).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a daprControlPlane and updates it. Returns the server's representation of the daprControlPlane, and an error, if there is any.
func (c *daprControlPlanes) Update(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (result *v1alpha1.DaprControlPlane, err error) {
result = &v1alpha1.DaprControlPlane{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(daprControlPlane.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprControlPlane).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *daprControlPlanes) UpdateStatus(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (result *v1alpha1.DaprControlPlane, err error) {
result = &v1alpha1.DaprControlPlane{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(daprControlPlane.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprControlPlane).
Do(ctx).
Into(result)
return
}
// Delete takes name of the daprControlPlane and deletes it. Returns an error if one occurs.
func (c *daprControlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *daprControlPlanes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("daprcontrolplanes").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched daprControlPlane.
func (c *daprControlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprControlPlane, err error) {
result = &v1alpha1.DaprControlPlane{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied daprControlPlane.
func (c *daprControlPlanes) Apply(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) {
if daprControlPlane == nil {
return nil, fmt.Errorf("daprControlPlane provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprControlPlane)
if err != nil {
return nil, err
}
name := daprControlPlane.Name
if name == nil {
return nil, fmt.Errorf("daprControlPlane.Name must be provided to Apply")
}
result = &v1alpha1.DaprControlPlane{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// ApplyStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
func (c *daprControlPlanes) ApplyStatus(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) {
if daprControlPlane == nil {
return nil, fmt.Errorf("daprControlPlane provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprControlPlane)
if err != nil {
return nil, err
}
name := daprControlPlane.Name
if name == nil {
return nil, fmt.Errorf("daprControlPlane.Name must be provided to Apply")
}
result = &v1alpha1.DaprControlPlane{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprcontrolplanes").
Name(*name).
SubResource("status").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -19,9 +19,6 @@ package v1alpha1
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1"
@ -29,7 +26,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
gentype "k8s.io/client-go/gentype"
)
// DaprCruiseControlsGetter has a method to return a DaprCruiseControlInterface.
@ -42,6 +39,7 @@ type DaprCruiseControlsGetter interface {
type DaprCruiseControlInterface interface {
Create(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.CreateOptions) (*v1alpha1.DaprCruiseControl, error)
Update(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (*v1alpha1.DaprCruiseControl, error)
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
UpdateStatus(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (*v1alpha1.DaprCruiseControl, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
@ -50,206 +48,25 @@ type DaprCruiseControlInterface interface {
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprCruiseControl, err error)
Apply(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error)
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error)
DaprCruiseControlExpansion
}
// daprCruiseControls implements DaprCruiseControlInterface
type daprCruiseControls struct {
client rest.Interface
ns string
*gentype.ClientWithListAndApply[*v1alpha1.DaprCruiseControl, *v1alpha1.DaprCruiseControlList, *operatorv1alpha1.DaprCruiseControlApplyConfiguration]
}
// newDaprCruiseControls returns a DaprCruiseControls
func newDaprCruiseControls(c *OperatorV1alpha1Client, namespace string) *daprCruiseControls {
return &daprCruiseControls{
client: c.RESTClient(),
ns: namespace,
gentype.NewClientWithListAndApply[*v1alpha1.DaprCruiseControl, *v1alpha1.DaprCruiseControlList, *operatorv1alpha1.DaprCruiseControlApplyConfiguration](
"daprcruisecontrols",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *v1alpha1.DaprCruiseControl { return &v1alpha1.DaprCruiseControl{} },
func() *v1alpha1.DaprCruiseControlList { return &v1alpha1.DaprCruiseControlList{} }),
}
}
// Get takes name of the daprCruiseControl, and returns the corresponding daprCruiseControl object, and an error if there is any.
func (c *daprCruiseControls) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprCruiseControl, err error) {
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of DaprCruiseControls that match those selectors.
func (c *daprCruiseControls) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprCruiseControlList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.DaprCruiseControlList{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprcruisecontrols").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested daprCruiseControls.
func (c *daprCruiseControls) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("daprcruisecontrols").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a daprCruiseControl and creates it. Returns the server's representation of the daprCruiseControl, and an error, if there is any.
func (c *daprCruiseControls) Create(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.CreateOptions) (result *v1alpha1.DaprCruiseControl, err error) {
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Post().
Namespace(c.ns).
Resource("daprcruisecontrols").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprCruiseControl).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a daprCruiseControl and updates it. Returns the server's representation of the daprCruiseControl, and an error, if there is any.
func (c *daprCruiseControls) Update(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1alpha1.DaprCruiseControl, err error) {
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(daprCruiseControl.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprCruiseControl).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *daprCruiseControls) UpdateStatus(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1alpha1.DaprCruiseControl, err error) {
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(daprCruiseControl.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprCruiseControl).
Do(ctx).
Into(result)
return
}
// Delete takes name of the daprCruiseControl and deletes it. Returns an error if one occurs.
func (c *daprCruiseControls) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *daprCruiseControls) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("daprcruisecontrols").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched daprCruiseControl.
func (c *daprCruiseControls) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprCruiseControl, err error) {
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied daprCruiseControl.
func (c *daprCruiseControls) Apply(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) {
if daprCruiseControl == nil {
return nil, fmt.Errorf("daprCruiseControl provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprCruiseControl)
if err != nil {
return nil, err
}
name := daprCruiseControl.Name
if name == nil {
return nil, fmt.Errorf("daprCruiseControl.Name must be provided to Apply")
}
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// ApplyStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
func (c *daprCruiseControls) ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) {
if daprCruiseControl == nil {
return nil, fmt.Errorf("daprCruiseControl provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprCruiseControl)
if err != nil {
return nil, err
}
name := daprCruiseControl.Name
if name == nil {
return nil, fmt.Errorf("daprCruiseControl.Name must be provided to Apply")
}
result = &v1alpha1.DaprCruiseControl{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprcruisecontrols").
Name(*name).
SubResource("status").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -19,9 +19,6 @@ package v1alpha1
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1"
@ -29,7 +26,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
gentype "k8s.io/client-go/gentype"
)
// DaprInstancesGetter has a method to return a DaprInstanceInterface.
@ -42,6 +39,7 @@ type DaprInstancesGetter interface {
type DaprInstanceInterface interface {
Create(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.CreateOptions) (*v1alpha1.DaprInstance, error)
Update(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (*v1alpha1.DaprInstance, error)
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
UpdateStatus(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (*v1alpha1.DaprInstance, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
@ -50,206 +48,25 @@ type DaprInstanceInterface interface {
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprInstance, err error)
Apply(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error)
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
ApplyStatus(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error)
DaprInstanceExpansion
}
// daprInstances implements DaprInstanceInterface
type daprInstances struct {
client rest.Interface
ns string
*gentype.ClientWithListAndApply[*v1alpha1.DaprInstance, *v1alpha1.DaprInstanceList, *operatorv1alpha1.DaprInstanceApplyConfiguration]
}
// newDaprInstances returns a DaprInstances
func newDaprInstances(c *OperatorV1alpha1Client, namespace string) *daprInstances {
return &daprInstances{
client: c.RESTClient(),
ns: namespace,
gentype.NewClientWithListAndApply[*v1alpha1.DaprInstance, *v1alpha1.DaprInstanceList, *operatorv1alpha1.DaprInstanceApplyConfiguration](
"daprinstances",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *v1alpha1.DaprInstance { return &v1alpha1.DaprInstance{} },
func() *v1alpha1.DaprInstanceList { return &v1alpha1.DaprInstanceList{} }),
}
}
// Get takes name of the daprInstance, and returns the corresponding daprInstance object, and an error if there is any.
func (c *daprInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprInstance, err error) {
result = &v1alpha1.DaprInstance{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprinstances").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of DaprInstances that match those selectors.
func (c *daprInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprInstanceList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.DaprInstanceList{}
err = c.client.Get().
Namespace(c.ns).
Resource("daprinstances").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested daprInstances.
func (c *daprInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("daprinstances").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a daprInstance and creates it. Returns the server's representation of the daprInstance, and an error, if there is any.
func (c *daprInstances) Create(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.CreateOptions) (result *v1alpha1.DaprInstance, err error) {
result = &v1alpha1.DaprInstance{}
err = c.client.Post().
Namespace(c.ns).
Resource("daprinstances").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprInstance).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a daprInstance and updates it. Returns the server's representation of the daprInstance, and an error, if there is any.
func (c *daprInstances) Update(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (result *v1alpha1.DaprInstance, err error) {
result = &v1alpha1.DaprInstance{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprinstances").
Name(daprInstance.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprInstance).
Do(ctx).
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *daprInstances) UpdateStatus(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (result *v1alpha1.DaprInstance, err error) {
result = &v1alpha1.DaprInstance{}
err = c.client.Put().
Namespace(c.ns).
Resource("daprinstances").
Name(daprInstance.Name).
SubResource("status").
VersionedParams(&opts, scheme.ParameterCodec).
Body(daprInstance).
Do(ctx).
Into(result)
return
}
// Delete takes name of the daprInstance and deletes it. Returns an error if one occurs.
func (c *daprInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("daprinstances").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *daprInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("daprinstances").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched daprInstance.
func (c *daprInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprInstance, err error) {
result = &v1alpha1.DaprInstance{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("daprinstances").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied daprInstance.
func (c *daprInstances) Apply(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) {
if daprInstance == nil {
return nil, fmt.Errorf("daprInstance provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprInstance)
if err != nil {
return nil, err
}
name := daprInstance.Name
if name == nil {
return nil, fmt.Errorf("daprInstance.Name must be provided to Apply")
}
result = &v1alpha1.DaprInstance{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprinstances").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// ApplyStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
func (c *daprInstances) ApplyStatus(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) {
if daprInstance == nil {
return nil, fmt.Errorf("daprInstance provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(daprInstance)
if err != nil {
return nil, err
}
name := daprInstance.Name
if name == nil {
return nil, fmt.Errorf("daprInstance.Name must be provided to Apply")
}
result = &v1alpha1.DaprInstance{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("daprinstances").
Name(*name).
SubResource("status").
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@ -32,7 +32,7 @@ type OperatorV1alpha1Interface interface {
DaprInstancesGetter
}
// OperatorV1alpha1Client is used to interact with features provided by the operator group.
// OperatorV1alpha1Client is used to interact with features provided by the operator.dapr.io group.
type OperatorV1alpha1Client struct {
restClient rest.Interface
}

View File

@ -227,6 +227,7 @@ type SharedInformerFactory interface {
// Start initializes all requested informers. They are handled in goroutines
// which run until the stop channel gets closed.
// Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync.
Start(stopCh <-chan struct{})
// Shutdown marks a factory as shutting down. At that point no new

View File

@ -51,7 +51,7 @@ func (f *genericInformer) Lister() cache.GenericLister {
// TODO extend this to unknown resources with a client pool
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
switch resource {
// Group=operator, Version=v1alpha1
// Group=operator.dapr.io, Version=v1alpha1
case v1alpha1.SchemeGroupVersion.WithResource("daprcontrolplanes"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1alpha1().DaprControlPlanes().Informer()}, nil
case v1alpha1.SchemeGroupVersion.WithResource("daprcruisecontrols"):

View File

@ -19,8 +19,8 @@ package v1alpha1
import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/listers"
"k8s.io/client-go/tools/cache"
)
@ -37,25 +37,17 @@ type DaprControlPlaneLister interface {
// daprControlPlaneLister implements the DaprControlPlaneLister interface.
type daprControlPlaneLister struct {
indexer cache.Indexer
listers.ResourceIndexer[*v1alpha1.DaprControlPlane]
}
// NewDaprControlPlaneLister returns a new DaprControlPlaneLister.
func NewDaprControlPlaneLister(indexer cache.Indexer) DaprControlPlaneLister {
return &daprControlPlaneLister{indexer: indexer}
}
// List lists all DaprControlPlanes in the indexer.
func (s *daprControlPlaneLister) List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprControlPlane))
})
return ret, err
return &daprControlPlaneLister{listers.New[*v1alpha1.DaprControlPlane](indexer, v1alpha1.Resource("daprcontrolplane"))}
}
// DaprControlPlanes returns an object that can list and get DaprControlPlanes.
func (s *daprControlPlaneLister) DaprControlPlanes(namespace string) DaprControlPlaneNamespaceLister {
return daprControlPlaneNamespaceLister{indexer: s.indexer, namespace: namespace}
return daprControlPlaneNamespaceLister{listers.NewNamespaced[*v1alpha1.DaprControlPlane](s.ResourceIndexer, namespace)}
}
// DaprControlPlaneNamespaceLister helps list and get DaprControlPlanes.
@ -73,26 +65,5 @@ type DaprControlPlaneNamespaceLister interface {
// daprControlPlaneNamespaceLister implements the DaprControlPlaneNamespaceLister
// interface.
type daprControlPlaneNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all DaprControlPlanes in the indexer for a given namespace.
func (s daprControlPlaneNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprControlPlane))
})
return ret, err
}
// Get retrieves the DaprControlPlane from the indexer for a given namespace and name.
func (s daprControlPlaneNamespaceLister) Get(name string) (*v1alpha1.DaprControlPlane, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("daprcontrolplane"), name)
}
return obj.(*v1alpha1.DaprControlPlane), nil
listers.ResourceIndexer[*v1alpha1.DaprControlPlane]
}

View File

@ -19,8 +19,8 @@ package v1alpha1
import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/listers"
"k8s.io/client-go/tools/cache"
)
@ -37,25 +37,17 @@ type DaprCruiseControlLister interface {
// daprCruiseControlLister implements the DaprCruiseControlLister interface.
type daprCruiseControlLister struct {
indexer cache.Indexer
listers.ResourceIndexer[*v1alpha1.DaprCruiseControl]
}
// NewDaprCruiseControlLister returns a new DaprCruiseControlLister.
func NewDaprCruiseControlLister(indexer cache.Indexer) DaprCruiseControlLister {
return &daprCruiseControlLister{indexer: indexer}
}
// List lists all DaprCruiseControls in the indexer.
func (s *daprCruiseControlLister) List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprCruiseControl))
})
return ret, err
return &daprCruiseControlLister{listers.New[*v1alpha1.DaprCruiseControl](indexer, v1alpha1.Resource("daprcruisecontrol"))}
}
// DaprCruiseControls returns an object that can list and get DaprCruiseControls.
func (s *daprCruiseControlLister) DaprCruiseControls(namespace string) DaprCruiseControlNamespaceLister {
return daprCruiseControlNamespaceLister{indexer: s.indexer, namespace: namespace}
return daprCruiseControlNamespaceLister{listers.NewNamespaced[*v1alpha1.DaprCruiseControl](s.ResourceIndexer, namespace)}
}
// DaprCruiseControlNamespaceLister helps list and get DaprCruiseControls.
@ -73,26 +65,5 @@ type DaprCruiseControlNamespaceLister interface {
// daprCruiseControlNamespaceLister implements the DaprCruiseControlNamespaceLister
// interface.
type daprCruiseControlNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all DaprCruiseControls in the indexer for a given namespace.
func (s daprCruiseControlNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprCruiseControl))
})
return ret, err
}
// Get retrieves the DaprCruiseControl from the indexer for a given namespace and name.
func (s daprCruiseControlNamespaceLister) Get(name string) (*v1alpha1.DaprCruiseControl, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("daprcruisecontrol"), name)
}
return obj.(*v1alpha1.DaprCruiseControl), nil
listers.ResourceIndexer[*v1alpha1.DaprCruiseControl]
}

View File

@ -19,8 +19,8 @@ package v1alpha1
import (
v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/listers"
"k8s.io/client-go/tools/cache"
)
@ -37,25 +37,17 @@ type DaprInstanceLister interface {
// daprInstanceLister implements the DaprInstanceLister interface.
type daprInstanceLister struct {
indexer cache.Indexer
listers.ResourceIndexer[*v1alpha1.DaprInstance]
}
// NewDaprInstanceLister returns a new DaprInstanceLister.
func NewDaprInstanceLister(indexer cache.Indexer) DaprInstanceLister {
return &daprInstanceLister{indexer: indexer}
}
// List lists all DaprInstances in the indexer.
func (s *daprInstanceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprInstance))
})
return ret, err
return &daprInstanceLister{listers.New[*v1alpha1.DaprInstance](indexer, v1alpha1.Resource("daprinstance"))}
}
// DaprInstances returns an object that can list and get DaprInstances.
func (s *daprInstanceLister) DaprInstances(namespace string) DaprInstanceNamespaceLister {
return daprInstanceNamespaceLister{indexer: s.indexer, namespace: namespace}
return daprInstanceNamespaceLister{listers.NewNamespaced[*v1alpha1.DaprInstance](s.ResourceIndexer, namespace)}
}
// DaprInstanceNamespaceLister helps list and get DaprInstances.
@ -73,26 +65,5 @@ type DaprInstanceNamespaceLister interface {
// daprInstanceNamespaceLister implements the DaprInstanceNamespaceLister
// interface.
type daprInstanceNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all DaprInstances in the indexer for a given namespace.
func (s daprInstanceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.DaprInstance))
})
return ret, err
}
// Get retrieves the DaprInstance from the indexer for a given namespace and name.
func (s daprInstanceNamespaceLister) Get(name string) (*v1alpha1.DaprInstance, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("daprinstance"), name)
}
return obj.(*v1alpha1.DaprInstance), nil
listers.ResourceIndexer[*v1alpha1.DaprInstance]
}

File diff suppressed because it is too large Load Diff

36
pkg/tools/tools.go Normal file
View File

@ -0,0 +1,36 @@
//go:build tools
// +build tools
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package contains import references to packages required only for the
// build process.
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package tools
import (
_ "k8s.io/code-generator/cmd/applyconfiguration-gen"
_ "k8s.io/code-generator/cmd/client-gen"
_ "k8s.io/code-generator/cmd/deepcopy-gen"
_ "k8s.io/code-generator/cmd/informer-gen"
_ "k8s.io/code-generator/cmd/lister-gen"
_ "k8s.io/code-generator/cmd/register-gen"
_ "k8s.io/kube-openapi/cmd/openapi-gen"
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
)