Skip to content
Snippets Groups Projects
Commit a1a24dca authored by Felix Kunde's avatar Felix Kunde
Browse files

update register files

parent 3c1e5fba
No related tags found
No related merge requests found
......@@ -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
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
}
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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment