From da6b02a2b05be3ac0f6cd6171314742e9f9617d9 Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Wed, 14 Aug 2024 11:06:37 -0400 Subject: [PATCH] K8s: Add k8s codegen PR check (#91903) --- .github/CODEOWNERS | 1 + .github/workflows/pr-k8s-codegen-check.yml | 38 ++++ go.mod | 2 - go.sum | 3 - go.work.sum | 2 + hack/go.mod | 16 ++ hack/go.sum | 18 ++ hack/openapi-codegen.sh | 5 +- hack/update-codegen.sh | 1 + .../common/v0alpha1/zz_generated.openapi.go | 173 +++++++++++++++++- ...enerated.openapi_violation_exceptions.list | 27 --- .../identity/v0alpha1/zz_generated.openapi.go | 2 - .../v0alpha1/zz_generated.openapi.go | 16 +- ...enerated.openapi_violation_exceptions.list | 1 - .../v0alpha1/integration.go | 18 +- .../v0alpha1/interval.go | 4 +- .../v0alpha1/receiver.go | 10 +- .../v0alpha1/receiverspec.go | 4 +- .../v0alpha1/timeinterval.go | 10 +- .../v0alpha1/timeintervalspec.go | 4 +- .../v0alpha1/timerange.go | 4 +- .../v0alpha1/fake/fake_receiver.go | 34 ++-- .../v0alpha1/fake/fake_timeinterval.go | 34 ++-- .../v0alpha1/receiver.go | 157 +--------------- .../v0alpha1/timeinterval.go | 157 +--------------- .../v0alpha1/receiver.go | 39 +--- .../v0alpha1/timeinterval.go | 39 +--- 27 files changed, 363 insertions(+), 456 deletions(-) create mode 100644 .github/workflows/pr-k8s-codegen-check.yml create mode 100644 hack/go.mod create mode 100644 hack/go.sum diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5ebc5224a88..c92f3f3d701 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -725,6 +725,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/i18n-crowdin-upload.yml @grafana/grafana-frontend-platform /.github/workflows/i18n-crowdin-download.yml @grafana/grafana-frontend-platform /.github/workflows/pr-go-workspace-check.yml @grafana/grafana-app-platform-squad +/.github/workflows/pr-k8s-codegen-check.yml @grafana/grafana-app-platform-squad /.github/workflows/run-scenes-e2e.yml @grafana/dashboards-squad /.github/workflows/go_lint.yml @grafana/grafana-backend-services-squad /.github/workflows/trivy-scan.yml @grafana/grafana-backend-services-squad diff --git a/.github/workflows/pr-k8s-codegen-check.yml b/.github/workflows/pr-k8s-codegen-check.yml new file mode 100644 index 00000000000..71dd29b6354 --- /dev/null +++ b/.github/workflows/pr-k8s-codegen-check.yml @@ -0,0 +1,38 @@ +name: "K8s Codegen Check" + +on: + workflow_dispatch: + pull_request: + branches: [main] + paths: + - "pkg/apis/**" + - "pkg/aggregator/apis/**" + - "pkg/apimachinery/apis/**" + - "hack/**" + - "*.sum" + +jobs: + check: + name: K8s Codegen Check + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set go version + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + + - name: Update k8s codegen + run: ./hack/update-codegen.sh + + - name: Check for k8s codegen changes + run: | + if ! git diff --exit-code --quiet; then + echo "Changes detected:" + git diff + echo "Please run './hack/update-codegen.sh' and commit the changes." + exit 1 + fi \ No newline at end of file diff --git a/go.mod b/go.mod index 7b21843da01..755e25db2e4 100644 --- a/go.mod +++ b/go.mod @@ -192,7 +192,6 @@ require ( k8s.io/apimachinery v0.31.0 // @grafana/grafana-app-platform-squad k8s.io/apiserver v0.31.0 // @grafana/grafana-app-platform-squad k8s.io/client-go v0.31.0 // @grafana/grafana-app-platform-squad - k8s.io/code-generator v0.31.0 // @grafana/grafana-app-platform-squad k8s.io/component-base v0.31.0 // @grafana/grafana-app-platform-squad k8s.io/klog/v2 v2.130.1 // @grafana/grafana-app-platform-squad k8s.io/kube-aggregator v0.31.0 // @grafana/grafana-app-platform-squad @@ -485,7 +484,6 @@ require ( github.com/grafana/grafana/pkg/semconv v0.0.0-20240808213237-f4d2e064f435 // indirect github.com/hairyhenderson/go-which v0.2.0 // indirect github.com/iancoleman/orderedmap v0.3.0 // indirect - k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect ) // Use fork of crewjam/saml with fixes for some issues until changes get merged into upstream diff --git a/go.sum b/go.sum index 48827644f74..1a4fb31516e 100644 --- a/go.sum +++ b/go.sum @@ -4706,12 +4706,9 @@ k8s.io/apiserver v0.31.0/go.mod h1:KI9ox5Yu902iBnnyMmy7ajonhKnkeZYJhTZ/YI+WEMk= k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= k8s.io/client-go v0.31.0 h1:QqEJzNjbN2Yv1H79SsS+SWnXkBgVu4Pj3CJQgbx0gI8= k8s.io/client-go v0.31.0/go.mod h1:Y9wvC76g4fLjmU0BA+rV+h2cncoadjvjjkkIGoTLcGU= -k8s.io/code-generator v0.31.0 h1:w607nrMi1KeDKB3/F/J4lIoOgAwc+gV9ZKew4XRfMp8= -k8s.io/code-generator v0.31.0/go.mod h1:84y4w3es8rOJOUUP1rLsIiGlO1JuEaPFXQPA9e/K6U0= k8s.io/component-base v0.31.0 h1:/KIzGM5EvPNQcYgwq5NwoQBaOlVFrghoVGr8lG6vNRs= k8s.io/component-base v0.31.0/go.mod h1:TYVuzI1QmN4L5ItVdMSXKvH7/DtvIuas5/mm8YT3rTo= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -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 v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= diff --git a/go.work.sum b/go.work.sum index b9d097c6d25..39f24172cb4 100644 --- a/go.work.sum +++ b/go.work.sum @@ -877,6 +877,8 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= honnef.co/go/tools v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= +k8s.io/code-generator v0.31.0 h1:w607nrMi1KeDKB3/F/J4lIoOgAwc+gV9ZKew4XRfMp8= +k8s.io/code-generator v0.31.0/go.mod h1:84y4w3es8rOJOUUP1rLsIiGlO1JuEaPFXQPA9e/K6U0= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= diff --git a/hack/go.mod b/hack/go.mod new file mode 100644 index 00000000000..e5507f966e0 --- /dev/null +++ b/hack/go.mod @@ -0,0 +1,16 @@ +module github.com/grafana/grafana/hack + +go 1.22.4 + +require k8s.io/code-generator v0.31.0 + +require ( + github.com/go-logr/logr v1.4.2 // indirect + github.com/spf13/pflag v1.0.5 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect + k8s.io/klog/v2 v2.130.1 // indirect +) diff --git a/hack/go.sum b/hack/go.sum new file mode 100644 index 00000000000..bb36abd861f --- /dev/null +++ b/hack/go.sum @@ -0,0 +1,18 @@ +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +k8s.io/code-generator v0.31.0 h1:w607nrMi1KeDKB3/F/J4lIoOgAwc+gV9ZKew4XRfMp8= +k8s.io/code-generator v0.31.0/go.mod h1:84y4w3es8rOJOUUP1rLsIiGlO1JuEaPFXQPA9e/K6U0= +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= diff --git a/hack/openapi-codegen.sh b/hack/openapi-codegen.sh index 5b7c65a8cf9..5f9e5e68a30 100644 --- a/hack/openapi-codegen.sh +++ b/hack/openapi-codegen.sh @@ -51,7 +51,7 @@ function grafana::codegen::gen_openapi() { ;; "--include-common-input-dirs") if [ "$2" == "true" ]; then - COMMON_INPUT_DIRS='"k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/version"' + COMMON_INPUT_DIRS='k8s.io/apimachinery/pkg/apis/meta/v1 k8s.io/apimachinery/pkg/runtime k8s.io/apimachinery/pkg/version' else COMMON_INPUT_DIRS="" fi @@ -99,6 +99,7 @@ function grafana::codegen::gen_openapi() { # To support running this from anywhere, first cd into this directory, # and then install with forced module mode on and fully qualified name. cd "${KUBE_CODEGEN_ROOT}" + GO111MODULE=on go mod download BINS=( openapi-gen ) @@ -150,7 +151,7 @@ function grafana::codegen::gen_openapi() { --output-file zz_generated.openapi.go \ --go-header-file "${boilerplate}" \ --output-dir "${root}" \ - --output-pkg "${in_pkg_single}" \ + --output-pkg "github.com/grafana/grafana/${in_pkg_single}" \ --report-filename "${new_report}" \ ${COMMON_INPUT_DIRS} \ "${input_pkgs[@]}" diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 55dcaa5d05e..54e1efcef46 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -10,6 +10,7 @@ set -o nounset set -o pipefail SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +pushd "${SCRIPT_ROOT}/hack" && GO111MODULE=on go mod tidy && popd CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo $(go env GOPATH)/pkg/mod/k8s.io/code-generator@v0.31.0)} OUTDIR="${HOME}/go/src" diff --git a/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi.go b/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi.go index 2dd8493f321..56ccd3aad5d 100644 --- a/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi.go +++ b/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi.go @@ -5,8 +5,6 @@ // Code generated by openapi-gen. DO NOT EDIT. -// This file was autogenerated by openapi-gen. Do not edit it manually! - package v0alpha1 import ( @@ -29,6 +27,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "k8s.io/apimachinery/pkg/apis/meta/v1.CreateOptions": schema_pkg_apis_meta_v1_CreateOptions(ref), "k8s.io/apimachinery/pkg/apis/meta/v1.DeleteOptions": schema_pkg_apis_meta_v1_DeleteOptions(ref), "k8s.io/apimachinery/pkg/apis/meta/v1.Duration": schema_pkg_apis_meta_v1_Duration(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.FieldSelectorRequirement": schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref), "k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1": schema_pkg_apis_meta_v1_FieldsV1(ref), "k8s.io/apimachinery/pkg/apis/meta/v1.GetOptions": schema_pkg_apis_meta_v1_GetOptions(ref), "k8s.io/apimachinery/pkg/apis/meta/v1.GroupKind": schema_pkg_apis_meta_v1_GroupKind(ref), @@ -149,6 +148,11 @@ func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenA }, }, "versions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "versions are the versions supported in this group.", Type: []string{"array"}, @@ -170,6 +174,11 @@ func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenA }, }, "serverAddressByClientCIDRs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", Type: []string{"array"}, @@ -214,6 +223,11 @@ func schema_pkg_apis_meta_v1_APIGroupList(ref common.ReferenceCallback) common.O }, }, "groups": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "groups is a list of APIGroup.", Type: []string{"array"}, @@ -305,6 +319,11 @@ func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.Op }, }, "shortNames": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "shortNames is a list of suggested short names of the resource.", Type: []string{"array"}, @@ -320,6 +339,11 @@ func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.Op }, }, "categories": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "categories is a list of the grouped resources this resource belongs to (e.g. 'all')", Type: []string{"array"}, @@ -378,6 +402,11 @@ func schema_pkg_apis_meta_v1_APIResourceList(ref common.ReferenceCallback) commo }, }, "resources": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "resources contains the name of the resources and if they are namespaced.", Type: []string{"array"}, @@ -422,6 +451,11 @@ func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.Op }, }, "versions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "versions are the api versions that are available.", Type: []string{"array"}, @@ -437,6 +471,11 @@ func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.Op }, }, "serverAddressByClientCIDRs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", Type: []string{"array"}, @@ -481,6 +520,11 @@ func schema_pkg_apis_meta_v1_ApplyOptions(ref common.ReferenceCallback) common.O }, }, "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", Type: []string{"array"}, @@ -601,6 +645,11 @@ func schema_pkg_apis_meta_v1_CreateOptions(ref common.ReferenceCallback) common. }, }, "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", Type: []string{"array"}, @@ -684,6 +733,11 @@ func schema_pkg_apis_meta_v1_DeleteOptions(ref common.ReferenceCallback) common. }, }, "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", Type: []string{"array"}, @@ -718,6 +772,56 @@ func schema_pkg_apis_meta_v1_Duration(ref common.ReferenceCallback) common.OpenA } } +func schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FieldSelectorRequirement is a selector that contains values, a key, and an operator that relates the key and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "key is the field selector key that the requirement applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. The list of operators may grow in the future.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + func schema_pkg_apis_meta_v1_FieldsV1(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1000,6 +1104,11 @@ func schema_pkg_apis_meta_v1_LabelSelector(ref common.ReferenceCallback) common. }, }, "matchExpressions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "matchExpressions is a list of label selector requirements. The requirements are ANDed.", Type: []string{"array"}, @@ -1050,6 +1159,11 @@ func schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref common.ReferenceCallba }, }, "values": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", Type: []string{"array"}, @@ -1443,6 +1557,10 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope "ownerReferences": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "uid", + }, + "x-kubernetes-list-type": "map", "x-kubernetes-patch-merge-key": "uid", "x-kubernetes-patch-strategy": "merge", }, @@ -1463,6 +1581,7 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope "finalizers": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ + "x-kubernetes-list-type": "set", "x-kubernetes-patch-strategy": "merge", }, }, @@ -1481,6 +1600,11 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope }, }, "managedFields": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like \"ci-cd\". The set of fields is always in the version that the workflow used when modifying the object.", Type: []string{"array"}, @@ -1687,6 +1811,11 @@ func schema_pkg_apis_meta_v1_PatchOptions(ref common.ReferenceCallback) common.O }, }, "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", Type: []string{"array"}, @@ -1763,6 +1892,11 @@ func schema_pkg_apis_meta_v1_RootPaths(ref common.ReferenceCallback) common.Open Type: []string{"object"}, Properties: map[string]spec.Schema{ "paths": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "paths are the paths available at root.", Type: []string{"array"}, @@ -1864,6 +1998,11 @@ func schema_pkg_apis_meta_v1_Status(ref common.ReferenceCallback) common.OpenAPI }, }, "details": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.", Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails"), @@ -1954,6 +2093,11 @@ func schema_pkg_apis_meta_v1_StatusDetails(ref common.ReferenceCallback) common. }, }, "causes": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.", Type: []string{"array"}, @@ -2011,6 +2155,11 @@ func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPID }, }, "columnDefinitions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "columnDefinitions describes each column in the returned items array. The number of cells per row will always match the number of column definitions.", Type: []string{"array"}, @@ -2025,6 +2174,11 @@ func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPID }, }, "rows": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "rows is the list of items in the table.", Type: []string{"array"}, @@ -2143,6 +2297,11 @@ func schema_pkg_apis_meta_v1_TableRow(ref common.ReferenceCallback) common.OpenA Type: []string{"object"}, Properties: map[string]spec.Schema{ "cells": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "cells will be as wide as the column definitions array and may contain strings, numbers (float64 or int64), booleans, simple maps, lists, or null. See the type field of the column definition for a more detailed description.", Type: []string{"array"}, @@ -2157,6 +2316,11 @@ func schema_pkg_apis_meta_v1_TableRow(ref common.ReferenceCallback) common.OpenA }, }, "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "conditions describe additional status of a row that are relevant for a human user. These conditions apply to the row, not to the object, and will be specific to table output. The only defined condition type is 'Completed', for a row that indicates a resource that has run to completion and can be given less visual priority.", Type: []string{"array"}, @@ -2320,6 +2484,11 @@ func schema_pkg_apis_meta_v1_UpdateOptions(ref common.ReferenceCallback) common. }, }, "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, SchemaProps: spec.SchemaProps{ Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", Type: []string{"array"}, diff --git a/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi_violation_exceptions.list b/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi_violation_exceptions.list index 3061580736b..caca0df1147 100644 --- a/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi_violation_exceptions.list +++ b/pkg/apimachinery/apis/common/v0alpha1/zz_generated.openapi_violation_exceptions.list @@ -1,30 +1,3 @@ -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroup,ServerAddressByClientCIDRs -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroup,Versions -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIGroupList,Groups -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResource,Categories -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResource,ShortNames -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVersions,ServerAddressByClientCIDRs -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,APIVersions,Versions -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ApplyOptions,DryRun -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,CreateOptions,DryRun -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,DeleteOptions,DryRun -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,FieldsV1,Raw -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelector,MatchExpressions -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,LabelSelectorRequirement,Values -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,Finalizers -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,ManagedFields -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,ObjectMeta,OwnerReferences -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,PatchOptions,DryRun -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,RootPaths,Paths -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,StatusDetails,Causes -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,ColumnDefinitions -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,Table,Rows -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Cells -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,TableRow,Conditions -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/apis/meta/v1,UpdateOptions,DryRun -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,RawExtension,Raw -API rule violation: list_type_missing,k8s.io/apimachinery/pkg/runtime,Unknown,Raw API rule violation: names_match,github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1,Unstructured,Object API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Duration diff --git a/pkg/apimachinery/apis/identity/v0alpha1/zz_generated.openapi.go b/pkg/apimachinery/apis/identity/v0alpha1/zz_generated.openapi.go index ac83849d03b..5027aa47724 100644 --- a/pkg/apimachinery/apis/identity/v0alpha1/zz_generated.openapi.go +++ b/pkg/apimachinery/apis/identity/v0alpha1/zz_generated.openapi.go @@ -5,8 +5,6 @@ // Code generated by openapi-gen. DO NOT EDIT. -// This file was autogenerated by openapi-gen. Do not edit it manually! - package v0alpha1 import ( diff --git a/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi.go b/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi.go index afcb58af88b..c2ce1fbc925 100644 --- a/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi.go +++ b/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi.go @@ -5,8 +5,6 @@ // Code generated by openapi-gen. DO NOT EDIT. -// This file was autogenerated by openapi-gen. Do not edit it manually! - package v0alpha1 import ( @@ -41,14 +39,24 @@ func schema_pkg_apis_alerting_notifications_v0alpha1_Integration(ref common.Refe Format: "", }, }, - "SecureFields": { + "secureFields": { VendorExtensible: spec.VendorExtensible{ Extensions: spec.Extensions{ "x-kubernetes-map-type": "atomic", }, }, SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1.Unstructured"), + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, }, }, "settings": { diff --git a/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi_violation_exceptions.list b/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi_violation_exceptions.list index ac3e0fa0bf0..7b756e64dfd 100644 --- a/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi_violation_exceptions.list +++ b/pkg/apis/alerting_notifications/v0alpha1/zz_generated.openapi_violation_exceptions.list @@ -1,4 +1,3 @@ -API rule violation: names_match,github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1,Integration,SecureFields API rule violation: names_match,github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1,Interval,DaysOfMonth API rule violation: names_match,github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1,TimeIntervalSpec,TimeIntervals API rule violation: names_match,github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1,TimeRange,EndTime diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/integration.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/integration.go index 15f78fd342a..9589a5a52a8 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/integration.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/integration.go @@ -5,20 +5,20 @@ package v0alpha1 import ( - json "encoding/json" + v0alpha1 "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1" ) -// IntegrationApplyConfiguration represents an declarative configuration of the Integration type for use +// IntegrationApplyConfiguration represents a declarative configuration of the Integration type for use // with apply. type IntegrationApplyConfiguration struct { - DisableResolveMessage *bool `json:"disableResolveMessage,omitempty"` - SecureFields map[string]bool `json:"SecureFields,omitempty"` - Settings *json.RawMessage `json:"settings,omitempty"` - Type *string `json:"type,omitempty"` - Uid *string `json:"uid,omitempty"` + DisableResolveMessage *bool `json:"disableResolveMessage,omitempty"` + SecureFields map[string]bool `json:"secureFields,omitempty"` + Settings *v0alpha1.Unstructured `json:"settings,omitempty"` + Type *string `json:"type,omitempty"` + Uid *string `json:"uid,omitempty"` } -// IntegrationApplyConfiguration constructs an declarative configuration of the Integration type for use with +// IntegrationApplyConfiguration constructs a declarative configuration of the Integration type for use with // apply. func Integration() *IntegrationApplyConfiguration { return &IntegrationApplyConfiguration{} @@ -49,7 +49,7 @@ func (b *IntegrationApplyConfiguration) WithSecureFields(entries map[string]bool // WithSettings sets the Settings 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 Settings field is set to the value of the last call. -func (b *IntegrationApplyConfiguration) WithSettings(value json.RawMessage) *IntegrationApplyConfiguration { +func (b *IntegrationApplyConfiguration) WithSettings(value v0alpha1.Unstructured) *IntegrationApplyConfiguration { b.Settings = &value return b } diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/interval.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/interval.go index 951000054bb..0354cc603ba 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/interval.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/interval.go @@ -4,7 +4,7 @@ package v0alpha1 -// IntervalApplyConfiguration represents an declarative configuration of the Interval type for use +// IntervalApplyConfiguration represents a declarative configuration of the Interval type for use // with apply. type IntervalApplyConfiguration struct { DaysOfMonth []string `json:"days_of_month,omitempty"` @@ -15,7 +15,7 @@ type IntervalApplyConfiguration struct { Years []string `json:"years,omitempty"` } -// IntervalApplyConfiguration constructs an declarative configuration of the Interval type for use with +// IntervalApplyConfiguration constructs a declarative configuration of the Interval type for use with // apply. func Interval() *IntervalApplyConfiguration { return &IntervalApplyConfiguration{} diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiver.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiver.go index 94565883187..fb663d04903 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiver.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiver.go @@ -10,7 +10,7 @@ import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// ReceiverApplyConfiguration represents an declarative configuration of the Receiver type for use +// ReceiverApplyConfiguration represents a declarative configuration of the Receiver type for use // with apply. type ReceiverApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` @@ -18,7 +18,7 @@ type ReceiverApplyConfiguration struct { Spec *ReceiverSpecApplyConfiguration `json:"spec,omitempty"` } -// Receiver constructs an declarative configuration of the Receiver type for use with +// Receiver constructs a declarative configuration of the Receiver type for use with // apply. func Receiver(name, namespace string) *ReceiverApplyConfiguration { b := &ReceiverApplyConfiguration{} @@ -194,3 +194,9 @@ func (b *ReceiverApplyConfiguration) WithSpec(value *ReceiverSpecApplyConfigurat b.Spec = value return b } + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *ReceiverApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiverspec.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiverspec.go index d7fc1ba3039..e5f89b53e9b 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiverspec.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/receiverspec.go @@ -4,14 +4,14 @@ package v0alpha1 -// ReceiverSpecApplyConfiguration represents an declarative configuration of the ReceiverSpec type for use +// ReceiverSpecApplyConfiguration represents a declarative configuration of the ReceiverSpec type for use // with apply. type ReceiverSpecApplyConfiguration struct { Integrations []IntegrationApplyConfiguration `json:"integrations,omitempty"` Title *string `json:"title,omitempty"` } -// ReceiverSpecApplyConfiguration constructs an declarative configuration of the ReceiverSpec type for use with +// ReceiverSpecApplyConfiguration constructs a declarative configuration of the ReceiverSpec type for use with // apply. func ReceiverSpec() *ReceiverSpecApplyConfiguration { return &ReceiverSpecApplyConfiguration{} diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeinterval.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeinterval.go index f94c6e8f95f..618f6a4d009 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeinterval.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeinterval.go @@ -10,7 +10,7 @@ import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// TimeIntervalApplyConfiguration represents an declarative configuration of the TimeInterval type for use +// TimeIntervalApplyConfiguration represents a declarative configuration of the TimeInterval type for use // with apply. type TimeIntervalApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` @@ -18,7 +18,7 @@ type TimeIntervalApplyConfiguration struct { Spec *TimeIntervalSpecApplyConfiguration `json:"spec,omitempty"` } -// TimeInterval constructs an declarative configuration of the TimeInterval type for use with +// TimeInterval constructs a declarative configuration of the TimeInterval type for use with // apply. func TimeInterval(name, namespace string) *TimeIntervalApplyConfiguration { b := &TimeIntervalApplyConfiguration{} @@ -194,3 +194,9 @@ func (b *TimeIntervalApplyConfiguration) WithSpec(value *TimeIntervalSpecApplyCo b.Spec = value return b } + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *TimeIntervalApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeintervalspec.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeintervalspec.go index ba3b255ed33..f9f6d4977b7 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeintervalspec.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timeintervalspec.go @@ -4,14 +4,14 @@ package v0alpha1 -// TimeIntervalSpecApplyConfiguration represents an declarative configuration of the TimeIntervalSpec type for use +// TimeIntervalSpecApplyConfiguration represents a declarative configuration of the TimeIntervalSpec type for use // with apply. type TimeIntervalSpecApplyConfiguration struct { Name *string `json:"name,omitempty"` TimeIntervals []IntervalApplyConfiguration `json:"time_intervals,omitempty"` } -// TimeIntervalSpecApplyConfiguration constructs an declarative configuration of the TimeIntervalSpec type for use with +// TimeIntervalSpecApplyConfiguration constructs a declarative configuration of the TimeIntervalSpec type for use with // apply. func TimeIntervalSpec() *TimeIntervalSpecApplyConfiguration { return &TimeIntervalSpecApplyConfiguration{} diff --git a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timerange.go b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timerange.go index 77242ddc317..01e83a9d9da 100644 --- a/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timerange.go +++ b/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1/timerange.go @@ -4,14 +4,14 @@ package v0alpha1 -// TimeRangeApplyConfiguration represents an declarative configuration of the TimeRange type for use +// TimeRangeApplyConfiguration represents a declarative configuration of the TimeRange type for use // with apply. type TimeRangeApplyConfiguration struct { EndTime *string `json:"end_time,omitempty"` StartTime *string `json:"start_time,omitempty"` } -// TimeRangeApplyConfiguration constructs an declarative configuration of the TimeRange type for use with +// TimeRangeApplyConfiguration constructs a declarative configuration of the TimeRange type for use with // apply. func TimeRange() *TimeRangeApplyConfiguration { return &TimeRangeApplyConfiguration{} diff --git a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_receiver.go b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_receiver.go index bf508c34049..c73360086b8 100644 --- a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_receiver.go +++ b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_receiver.go @@ -30,22 +30,24 @@ var receiversKind = v0alpha1.SchemeGroupVersion.WithKind("Receiver") // Get takes name of the receiver, and returns the corresponding receiver object, and an error if there is any. func (c *FakeReceivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.Receiver, err error) { + emptyResult := &v0alpha1.Receiver{} obj, err := c.Fake. - Invokes(testing.NewGetAction(receiversResource, c.ns, name), &v0alpha1.Receiver{}) + Invokes(testing.NewGetActionWithOptions(receiversResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.Receiver), err } // List takes label and field selectors, and returns the list of Receivers that match those selectors. func (c *FakeReceivers) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.ReceiverList, err error) { + emptyResult := &v0alpha1.ReceiverList{} obj, err := c.Fake. - Invokes(testing.NewListAction(receiversResource, receiversKind, c.ns, opts), &v0alpha1.ReceiverList{}) + Invokes(testing.NewListActionWithOptions(receiversResource, receiversKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -64,28 +66,30 @@ func (c *FakeReceivers) List(ctx context.Context, opts v1.ListOptions) (result * // Watch returns a watch.Interface that watches the requested receivers. func (c *FakeReceivers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(receiversResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(receiversResource, c.ns, opts)) } // Create takes the representation of a receiver and creates it. Returns the server's representation of the receiver, and an error, if there is any. func (c *FakeReceivers) Create(ctx context.Context, receiver *v0alpha1.Receiver, opts v1.CreateOptions) (result *v0alpha1.Receiver, err error) { + emptyResult := &v0alpha1.Receiver{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(receiversResource, c.ns, receiver), &v0alpha1.Receiver{}) + Invokes(testing.NewCreateActionWithOptions(receiversResource, c.ns, receiver, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.Receiver), err } // Update takes the representation of a receiver and updates it. Returns the server's representation of the receiver, and an error, if there is any. func (c *FakeReceivers) Update(ctx context.Context, receiver *v0alpha1.Receiver, opts v1.UpdateOptions) (result *v0alpha1.Receiver, err error) { + emptyResult := &v0alpha1.Receiver{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(receiversResource, c.ns, receiver), &v0alpha1.Receiver{}) + Invokes(testing.NewUpdateActionWithOptions(receiversResource, c.ns, receiver, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.Receiver), err } @@ -100,7 +104,7 @@ func (c *FakeReceivers) Delete(ctx context.Context, name string, opts v1.DeleteO // DeleteCollection deletes a collection of objects. func (c *FakeReceivers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(receiversResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(receiversResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v0alpha1.ReceiverList{}) return err @@ -108,11 +112,12 @@ func (c *FakeReceivers) DeleteCollection(ctx context.Context, opts v1.DeleteOpti // Patch applies the patch and returns the patched receiver. func (c *FakeReceivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.Receiver, err error) { + emptyResult := &v0alpha1.Receiver{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(receiversResource, c.ns, name, pt, data, subresources...), &v0alpha1.Receiver{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(receiversResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.Receiver), err } @@ -130,11 +135,12 @@ func (c *FakeReceivers) Apply(ctx context.Context, receiver *alertingnotificatio if name == nil { return nil, fmt.Errorf("receiver.Name must be provided to Apply") } + emptyResult := &v0alpha1.Receiver{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(receiversResource, c.ns, *name, types.ApplyPatchType, data), &v0alpha1.Receiver{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(receiversResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.Receiver), err } diff --git a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_timeinterval.go b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_timeinterval.go index 569c83a433d..08392c1834d 100644 --- a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_timeinterval.go +++ b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/fake/fake_timeinterval.go @@ -30,22 +30,24 @@ var timeintervalsKind = v0alpha1.SchemeGroupVersion.WithKind("TimeInterval") // Get takes name of the timeInterval, and returns the corresponding timeInterval object, and an error if there is any. func (c *FakeTimeIntervals) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.TimeInterval, err error) { + emptyResult := &v0alpha1.TimeInterval{} obj, err := c.Fake. - Invokes(testing.NewGetAction(timeintervalsResource, c.ns, name), &v0alpha1.TimeInterval{}) + Invokes(testing.NewGetActionWithOptions(timeintervalsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.TimeInterval), err } // List takes label and field selectors, and returns the list of TimeIntervals that match those selectors. func (c *FakeTimeIntervals) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.TimeIntervalList, err error) { + emptyResult := &v0alpha1.TimeIntervalList{} obj, err := c.Fake. - Invokes(testing.NewListAction(timeintervalsResource, timeintervalsKind, c.ns, opts), &v0alpha1.TimeIntervalList{}) + Invokes(testing.NewListActionWithOptions(timeintervalsResource, timeintervalsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -64,28 +66,30 @@ func (c *FakeTimeIntervals) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested timeIntervals. func (c *FakeTimeIntervals) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(timeintervalsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(timeintervalsResource, c.ns, opts)) } // Create takes the representation of a timeInterval and creates it. Returns the server's representation of the timeInterval, and an error, if there is any. func (c *FakeTimeIntervals) Create(ctx context.Context, timeInterval *v0alpha1.TimeInterval, opts v1.CreateOptions) (result *v0alpha1.TimeInterval, err error) { + emptyResult := &v0alpha1.TimeInterval{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(timeintervalsResource, c.ns, timeInterval), &v0alpha1.TimeInterval{}) + Invokes(testing.NewCreateActionWithOptions(timeintervalsResource, c.ns, timeInterval, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.TimeInterval), err } // Update takes the representation of a timeInterval and updates it. Returns the server's representation of the timeInterval, and an error, if there is any. func (c *FakeTimeIntervals) Update(ctx context.Context, timeInterval *v0alpha1.TimeInterval, opts v1.UpdateOptions) (result *v0alpha1.TimeInterval, err error) { + emptyResult := &v0alpha1.TimeInterval{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(timeintervalsResource, c.ns, timeInterval), &v0alpha1.TimeInterval{}) + Invokes(testing.NewUpdateActionWithOptions(timeintervalsResource, c.ns, timeInterval, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.TimeInterval), err } @@ -100,7 +104,7 @@ func (c *FakeTimeIntervals) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeTimeIntervals) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(timeintervalsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(timeintervalsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v0alpha1.TimeIntervalList{}) return err @@ -108,11 +112,12 @@ func (c *FakeTimeIntervals) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched timeInterval. func (c *FakeTimeIntervals) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.TimeInterval, err error) { + emptyResult := &v0alpha1.TimeInterval{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(timeintervalsResource, c.ns, name, pt, data, subresources...), &v0alpha1.TimeInterval{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(timeintervalsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.TimeInterval), err } @@ -130,11 +135,12 @@ func (c *FakeTimeIntervals) Apply(ctx context.Context, timeInterval *alertingnot if name == nil { return nil, fmt.Errorf("timeInterval.Name must be provided to Apply") } + emptyResult := &v0alpha1.TimeInterval{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(timeintervalsResource, c.ns, *name, types.ApplyPatchType, data), &v0alpha1.TimeInterval{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(timeintervalsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v0alpha1.TimeInterval), err } diff --git a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/receiver.go b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/receiver.go index 1f99044e245..5b608f6fc2b 100644 --- a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/receiver.go +++ b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/receiver.go @@ -6,9 +6,6 @@ package v0alpha1 import ( "context" - json "encoding/json" - "fmt" - "time" v0alpha1 "github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1" alertingnotificationsv0alpha1 "github.com/grafana/grafana/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1" @@ -16,7 +13,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" ) // ReceiversGetter has a method to return a ReceiverInterface. @@ -41,154 +38,18 @@ type ReceiverInterface interface { // receivers implements ReceiverInterface type receivers struct { - client rest.Interface - ns string + *gentype.ClientWithListAndApply[*v0alpha1.Receiver, *v0alpha1.ReceiverList, *alertingnotificationsv0alpha1.ReceiverApplyConfiguration] } // newReceivers returns a Receivers func newReceivers(c *NotificationsV0alpha1Client, namespace string) *receivers { return &receivers{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithListAndApply[*v0alpha1.Receiver, *v0alpha1.ReceiverList, *alertingnotificationsv0alpha1.ReceiverApplyConfiguration]( + "receivers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v0alpha1.Receiver { return &v0alpha1.Receiver{} }, + func() *v0alpha1.ReceiverList { return &v0alpha1.ReceiverList{} }), } } - -// Get takes name of the receiver, and returns the corresponding receiver object, and an error if there is any. -func (c *receivers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.Receiver, err error) { - result = &v0alpha1.Receiver{} - err = c.client.Get(). - Namespace(c.ns). - Resource("receivers"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Receivers that match those selectors. -func (c *receivers) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.ReceiverList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v0alpha1.ReceiverList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("receivers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested receivers. -func (c *receivers) 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("receivers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a receiver and creates it. Returns the server's representation of the receiver, and an error, if there is any. -func (c *receivers) Create(ctx context.Context, receiver *v0alpha1.Receiver, opts v1.CreateOptions) (result *v0alpha1.Receiver, err error) { - result = &v0alpha1.Receiver{} - err = c.client.Post(). - Namespace(c.ns). - Resource("receivers"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(receiver). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a receiver and updates it. Returns the server's representation of the receiver, and an error, if there is any. -func (c *receivers) Update(ctx context.Context, receiver *v0alpha1.Receiver, opts v1.UpdateOptions) (result *v0alpha1.Receiver, err error) { - result = &v0alpha1.Receiver{} - err = c.client.Put(). - Namespace(c.ns). - Resource("receivers"). - Name(receiver.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(receiver). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the receiver and deletes it. Returns an error if one occurs. -func (c *receivers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("receivers"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *receivers) 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("receivers"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched receiver. -func (c *receivers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.Receiver, err error) { - result = &v0alpha1.Receiver{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("receivers"). - 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 receiver. -func (c *receivers) Apply(ctx context.Context, receiver *alertingnotificationsv0alpha1.ReceiverApplyConfiguration, opts v1.ApplyOptions) (result *v0alpha1.Receiver, err error) { - if receiver == nil { - return nil, fmt.Errorf("receiver provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(receiver) - if err != nil { - return nil, err - } - name := receiver.Name - if name == nil { - return nil, fmt.Errorf("receiver.Name must be provided to Apply") - } - result = &v0alpha1.Receiver{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("receivers"). - Name(*name). - VersionedParams(&patchOpts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/timeinterval.go b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/timeinterval.go index cc3b2c05bd1..a0a12597e00 100644 --- a/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/timeinterval.go +++ b/pkg/generated/clientset/versioned/typed/alerting_notifications/v0alpha1/timeinterval.go @@ -6,9 +6,6 @@ package v0alpha1 import ( "context" - json "encoding/json" - "fmt" - "time" v0alpha1 "github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1" alertingnotificationsv0alpha1 "github.com/grafana/grafana/pkg/generated/applyconfiguration/alerting_notifications/v0alpha1" @@ -16,7 +13,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" ) // TimeIntervalsGetter has a method to return a TimeIntervalInterface. @@ -41,154 +38,18 @@ type TimeIntervalInterface interface { // timeIntervals implements TimeIntervalInterface type timeIntervals struct { - client rest.Interface - ns string + *gentype.ClientWithListAndApply[*v0alpha1.TimeInterval, *v0alpha1.TimeIntervalList, *alertingnotificationsv0alpha1.TimeIntervalApplyConfiguration] } // newTimeIntervals returns a TimeIntervals func newTimeIntervals(c *NotificationsV0alpha1Client, namespace string) *timeIntervals { return &timeIntervals{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithListAndApply[*v0alpha1.TimeInterval, *v0alpha1.TimeIntervalList, *alertingnotificationsv0alpha1.TimeIntervalApplyConfiguration]( + "timeintervals", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v0alpha1.TimeInterval { return &v0alpha1.TimeInterval{} }, + func() *v0alpha1.TimeIntervalList { return &v0alpha1.TimeIntervalList{} }), } } - -// Get takes name of the timeInterval, and returns the corresponding timeInterval object, and an error if there is any. -func (c *timeIntervals) Get(ctx context.Context, name string, options v1.GetOptions) (result *v0alpha1.TimeInterval, err error) { - result = &v0alpha1.TimeInterval{} - err = c.client.Get(). - Namespace(c.ns). - Resource("timeintervals"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TimeIntervals that match those selectors. -func (c *timeIntervals) List(ctx context.Context, opts v1.ListOptions) (result *v0alpha1.TimeIntervalList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v0alpha1.TimeIntervalList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("timeintervals"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested timeIntervals. -func (c *timeIntervals) 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("timeintervals"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a timeInterval and creates it. Returns the server's representation of the timeInterval, and an error, if there is any. -func (c *timeIntervals) Create(ctx context.Context, timeInterval *v0alpha1.TimeInterval, opts v1.CreateOptions) (result *v0alpha1.TimeInterval, err error) { - result = &v0alpha1.TimeInterval{} - err = c.client.Post(). - Namespace(c.ns). - Resource("timeintervals"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(timeInterval). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a timeInterval and updates it. Returns the server's representation of the timeInterval, and an error, if there is any. -func (c *timeIntervals) Update(ctx context.Context, timeInterval *v0alpha1.TimeInterval, opts v1.UpdateOptions) (result *v0alpha1.TimeInterval, err error) { - result = &v0alpha1.TimeInterval{} - err = c.client.Put(). - Namespace(c.ns). - Resource("timeintervals"). - Name(timeInterval.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(timeInterval). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the timeInterval and deletes it. Returns an error if one occurs. -func (c *timeIntervals) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("timeintervals"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *timeIntervals) 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("timeintervals"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched timeInterval. -func (c *timeIntervals) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v0alpha1.TimeInterval, err error) { - result = &v0alpha1.TimeInterval{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("timeintervals"). - 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 timeInterval. -func (c *timeIntervals) Apply(ctx context.Context, timeInterval *alertingnotificationsv0alpha1.TimeIntervalApplyConfiguration, opts v1.ApplyOptions) (result *v0alpha1.TimeInterval, err error) { - if timeInterval == nil { - return nil, fmt.Errorf("timeInterval provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(timeInterval) - if err != nil { - return nil, err - } - name := timeInterval.Name - if name == nil { - return nil, fmt.Errorf("timeInterval.Name must be provided to Apply") - } - result = &v0alpha1.TimeInterval{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("timeintervals"). - Name(*name). - VersionedParams(&patchOpts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/generated/listers/alerting_notifications/v0alpha1/receiver.go b/pkg/generated/listers/alerting_notifications/v0alpha1/receiver.go index 990dbf51ce5..e07d4f20b03 100644 --- a/pkg/generated/listers/alerting_notifications/v0alpha1/receiver.go +++ b/pkg/generated/listers/alerting_notifications/v0alpha1/receiver.go @@ -6,8 +6,8 @@ package v0alpha1 import ( v0alpha1 "github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -24,25 +24,17 @@ type ReceiverLister interface { // receiverLister implements the ReceiverLister interface. type receiverLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v0alpha1.Receiver] } // NewReceiverLister returns a new ReceiverLister. func NewReceiverLister(indexer cache.Indexer) ReceiverLister { - return &receiverLister{indexer: indexer} -} - -// List lists all Receivers in the indexer. -func (s *receiverLister) List(selector labels.Selector) (ret []*v0alpha1.Receiver, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v0alpha1.Receiver)) - }) - return ret, err + return &receiverLister{listers.New[*v0alpha1.Receiver](indexer, v0alpha1.Resource("receiver"))} } // Receivers returns an object that can list and get Receivers. func (s *receiverLister) Receivers(namespace string) ReceiverNamespaceLister { - return receiverNamespaceLister{indexer: s.indexer, namespace: namespace} + return receiverNamespaceLister{listers.NewNamespaced[*v0alpha1.Receiver](s.ResourceIndexer, namespace)} } // ReceiverNamespaceLister helps list and get Receivers. @@ -60,26 +52,5 @@ type ReceiverNamespaceLister interface { // receiverNamespaceLister implements the ReceiverNamespaceLister // interface. type receiverNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Receivers in the indexer for a given namespace. -func (s receiverNamespaceLister) List(selector labels.Selector) (ret []*v0alpha1.Receiver, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v0alpha1.Receiver)) - }) - return ret, err -} - -// Get retrieves the Receiver from the indexer for a given namespace and name. -func (s receiverNamespaceLister) Get(name string) (*v0alpha1.Receiver, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v0alpha1.Resource("receiver"), name) - } - return obj.(*v0alpha1.Receiver), nil + listers.ResourceIndexer[*v0alpha1.Receiver] } diff --git a/pkg/generated/listers/alerting_notifications/v0alpha1/timeinterval.go b/pkg/generated/listers/alerting_notifications/v0alpha1/timeinterval.go index 225a64b84e5..c3a33df619a 100644 --- a/pkg/generated/listers/alerting_notifications/v0alpha1/timeinterval.go +++ b/pkg/generated/listers/alerting_notifications/v0alpha1/timeinterval.go @@ -6,8 +6,8 @@ package v0alpha1 import ( v0alpha1 "github.com/grafana/grafana/pkg/apis/alerting_notifications/v0alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -24,25 +24,17 @@ type TimeIntervalLister interface { // timeIntervalLister implements the TimeIntervalLister interface. type timeIntervalLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v0alpha1.TimeInterval] } // NewTimeIntervalLister returns a new TimeIntervalLister. func NewTimeIntervalLister(indexer cache.Indexer) TimeIntervalLister { - return &timeIntervalLister{indexer: indexer} -} - -// List lists all TimeIntervals in the indexer. -func (s *timeIntervalLister) List(selector labels.Selector) (ret []*v0alpha1.TimeInterval, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v0alpha1.TimeInterval)) - }) - return ret, err + return &timeIntervalLister{listers.New[*v0alpha1.TimeInterval](indexer, v0alpha1.Resource("timeinterval"))} } // TimeIntervals returns an object that can list and get TimeIntervals. func (s *timeIntervalLister) TimeIntervals(namespace string) TimeIntervalNamespaceLister { - return timeIntervalNamespaceLister{indexer: s.indexer, namespace: namespace} + return timeIntervalNamespaceLister{listers.NewNamespaced[*v0alpha1.TimeInterval](s.ResourceIndexer, namespace)} } // TimeIntervalNamespaceLister helps list and get TimeIntervals. @@ -60,26 +52,5 @@ type TimeIntervalNamespaceLister interface { // timeIntervalNamespaceLister implements the TimeIntervalNamespaceLister // interface. type timeIntervalNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all TimeIntervals in the indexer for a given namespace. -func (s timeIntervalNamespaceLister) List(selector labels.Selector) (ret []*v0alpha1.TimeInterval, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v0alpha1.TimeInterval)) - }) - return ret, err -} - -// Get retrieves the TimeInterval from the indexer for a given namespace and name. -func (s timeIntervalNamespaceLister) Get(name string) (*v0alpha1.TimeInterval, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v0alpha1.Resource("timeinterval"), name) - } - return obj.(*v0alpha1.TimeInterval), nil + listers.ResourceIndexer[*v0alpha1.TimeInterval] }