Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
postgres-operator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
zalando
postgres-operator
Commits
a1a24dca
Commit
a1a24dca
authored
Feb 23, 2024
by
Felix Kunde
Browse files
Options
Downloads
Patches
Plain Diff
update register files
parent
3c1e5fba
Branches
update-go-and-deps
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
hack/update-codegen.sh
+31
-11
31 additions, 11 deletions
hack/update-codegen.sh
pkg/apis/acid.zalan.do/register.go
+46
-0
46 additions, 0 deletions
pkg/apis/acid.zalan.do/register.go
pkg/apis/zalando.org/register.go
+32
-0
32 additions, 0 deletions
pkg/apis/zalando.org/register.go
with
109 additions
and
11 deletions
hack/update-codegen.sh
+
31
−
11
View file @
a1a24dca
...
...
@@ -4,30 +4,50 @@ set -o errexit
set
-o
nounset
set
-o
pipefail
GENERATED_PACKAGE_ROOT
=
"src/github.com"
OPERATOR_PACKAGE_ROOT
=
"
${
GENERATED_PACKAGE_ROOT
}
/zalando/postgres-operator"
OPERATOR_PACKAGE_ROOT
=
"zalando/postgres-operator"
# TARGET_CODE_DIR=${1-${SCRIPT_ROOT}/pkg}
SCRIPT_ROOT
=
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/..
TARGET_CODE_DIR
=
${
1
-
${
SCRIPT_ROOT
}
/pkg
}
CODEGEN_PKG
=
${
CODEGEN_PKG
:-
$(
cd
"
${
SCRIPT_ROOT
}
"
;
ls
-d
-1
./vendor/k8s.io/code-generator 2>/dev/null
||
echo
../code-generator
)
}
source
"
${
CODEGEN_PKG
}
/kube_codegen.sh"
cleanup
()
{
rm
-rf
"
${
GENERATED_PACKAGE_ROOT
}
"
}
trap
"cleanup"
EXIT SIGINT
# generate the code with:
# --output-base because this script should also be able to run inside the vendor dir of
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
#cleanup() {
# rm -rf "${OPERATOR_PACKAGE_ROOT}"
#}
#trap "cleanup" EXIT SIGINT
kube::codegen::gen_helpers
\
--input-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/apis"
\
--output-base
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../..
/../..
"
\
--output-base
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../.."
\
--boilerplate
"
${
SCRIPT_ROOT
}
/hack/custom-boilerplate.go.txt"
if
[[
-n
"
${
API_KNOWN_VIOLATIONS_DIR
:-}
"
]]
;
then
report_filename
=
"
${
API_KNOWN_VIOLATIONS_DIR
}
/sample_apiserver_violation_exceptions.list"
if
[[
"
${
UPDATE_API_KNOWN_VIOLATIONS
:-}
"
==
"true"
]]
;
then
update_report
=
"--update-report"
fi
fi
kube::codegen::gen_openapi
\
--input-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/apis"
\
--output-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/generated"
\
--output-base
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../.."
\
--report-filename
"
${
report_filename
:-
"/dev/null"
}
"
\
${
update_report
:+
"
${
update_report
}
"
}
\
--boilerplate
"
${
SCRIPT_ROOT
}
/hack/boilerplate.go.txt"
kube::codegen::gen_client
\
--with-watch
\
--with-applyconfig
\
--input-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/apis"
\
--output-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/generated
/client
"
\
--output-base
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../..
/../..
"
\
--output-pkg-root
"
${
OPERATOR_PACKAGE_ROOT
}
/pkg/generated"
\
--output-base
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/../../.."
\
--boilerplate
"
${
SCRIPT_ROOT
}
/hack/custom-boilerplate.go.txt"
#bash "${CODEGEN_PKG}/kube_codegen.sh" client,deepcopy,informer,lister \
...
...
@@ -38,4 +58,4 @@ kube::codegen::gen_client \
#cp -r "${OPERATOR_PACKAGE_ROOT}"/pkg/* "${TARGET_CODE_DIR}"
cleanup
#
cleanup
This diff is collapsed.
Click to expand it.
pkg/apis/acid.zalan.do/register.go
+
46
−
0
View file @
a1a24dca
package
acidzalando
import
(
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const
(
// GroupName is the group name for the operator CRDs
GroupName
=
"acid.zalan.do"
)
var
(
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
// SchemeBuilder : An instance of runtime.SchemeBuilder, global for this package
SchemeBuilder
runtime
.
SchemeBuilder
localSchemeBuilder
=
&
SchemeBuilder
//AddToScheme is localSchemeBuilder.AddToScheme
AddToScheme
=
localSchemeBuilder
.
AddToScheme
//SchemeGroupVersion has GroupName and APIVersion
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
runtime
.
APIVersionInternal
}
)
func
init
()
{
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder
.
Register
(
addKnownTypes
)
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
// Adds the list of known types to api.Scheme.
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
// AddKnownType assumes derives the type kind from the type name, which is always uppercase.
// For our CRDs we use lowercase names historically, therefore we have to supply the name separately.
// TODO: User uppercase CRDResourceKind of our types in the next major API version
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"postgresql"
),
&
Postgresql
{})
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"postgresqlList"
),
&
PostgresqlList
{})
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"PostgresTeam"
),
&
PostgresTeam
{})
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"PostgresTeamList"
),
&
PostgresTeamList
{})
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"OperatorConfiguration"
),
&
OperatorConfiguration
{})
scheme
.
AddKnownTypeWithName
(
SchemeGroupVersion
.
WithKind
(
"OperatorConfigurationList"
),
&
OperatorConfigurationList
{})
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
return
nil
}
This diff is collapsed.
Click to expand it.
pkg/apis/zalando.org/register.go
+
32
−
0
View file @
a1a24dca
package
zalando
import
(
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
const
(
// GroupName is the group name for the operator CRDs
GroupName
=
"zalando.org"
)
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
schema
.
GroupVersion
{
Group
:
GroupName
,
Version
:
runtime
.
APIVersionInternal
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
schema
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
// Resource takes an unqualified resource and returns back a Group qualified GroupResource
func
Resource
(
resource
string
)
schema
.
GroupResource
{
return
SchemeGroupVersion
.
WithResource
(
resource
)
.
GroupResource
()
}
var
(
SchemeBuilder
=
runtime
.
NewSchemeBuilder
(
addKnownTypes
)
AddToScheme
=
SchemeBuilder
.
AddToScheme
)
// Adds the list of known types to the given scheme.
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
error
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
FabricEventStream
{},
&
FabricEventStreamList
{},
)
return
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment