Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Keycloak provisioning #126

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ generate-stackgres-crds:
go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --package=v1 -generate=types -o apis/stackgres/v1/sgcluster.gen.go apis/stackgres/v1/sgcluster.yaml
perl -i -0pe 's/\*struct\s\{\n\s\sAdditionalProperties\smap\[string\]string\s`json:"-"`\n\s}/map\[string\]string/gms' apis/stackgres/v1/sgcluster.gen.go

# curl ${STACKGRES_CRD_URL}/SGPoolingConfig.yaml?inline=false -o apis/stackgres/v1/sgpoolconfigs_crd.yaml
# yq -i e apis/stackgres/v1/sgpoolconfigs.yaml --expression ".components.schemas.SGPoolingConfigSpec=load(\"apis/stackgres/v1/sgpoolconfigs_crd.yaml\").spec.versions[0].schema.openAPIV3Schema.properties.spec"
# yq -i e apis/stackgres/v1/sgpoolconfigs.yaml --expression ".components.schemas.SGPoolingConfigStatus=load(\"apis/stackgres/v1/sgpoolconfigs_crd.yaml\").spec.versions[0].schema.openAPIV3Schema.properties.status"
# go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --package=v1 -generate=types -o apis/stackgres/v1/sgpoolconfigs.gen.go apis/stackgres/v1/sgpoolconfigs.yaml
# perl -i -0pe 's/\*struct\s\{\n\s\sAdditionalProperties\smap\[string\]string\s`json:"-"`\n\s}/map\[string\]string/gms' apis/stackgres/v1/sgpoolconfigs.gen.go

Comment on lines +95 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it still necessary? or just left for future us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future us. It probably makes sense if I add a comment though.

tl;dr: the generator for the pool configs doesn't work very well, as it relies on map[string]string which the go tooling can't handle. I guess it works with java though. So I had to replace parts of the generated code.

go run sigs.k8s.io/controller-tools/cmd/controller-gen object paths=./apis/stackgres/v1/...
rm apis/stackgres/v1/*_crd.yaml

Expand Down Expand Up @@ -191,7 +197,9 @@ get-crds:
./hack/get_crds.sh https://github.com/vshn/provider-minio provider-minio apis/minio/v1 apis/minio
./hack/get_crds.sh https://github.com/crossplane-contrib/provider-helm provider-helm apis/release apis/helm

# API bootstrapping
.PHONY: bootstrap
bootstrap:
.PHONY: api-bootstrap
api-bootstrap:
go run ./hack/bootstrap/template.go ${API_FILE}

.PHONY: bootstrap
bootstrap: api-bootstrap generate ## API bootstrapping, create a new claim/composite API ready to be used
2 changes: 2 additions & 0 deletions apis/stackgres/v1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ func init() {
&SGClusterList{},
&SGPostgresConfig{},
&SGPostgesConfigList{},
&SGPoolingConfigList{},
&SGPoolingConfig{},
)
}
28 changes: 28 additions & 0 deletions apis/stackgres/v1/sgpoolconfigs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:object:root=true

// SGPoolingConfig is the API for creating pgbouncer configs clusters.
type SGPoolingConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the desired state of a VSHNPostgreSQL.
Spec SGPoolingConfigSpec `json:"spec"`

// Status reflects the observed state of a VSHNPostgreSQL.
Status SGPoolingConfigStatus `json:"status,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like copy-paste issue in comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I'll change the postgresql references.

}

// +kubebuilder:object:root=true

type SGPoolingConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []SGPoolingConfig `json:"items"`
}
75 changes: 75 additions & 0 deletions apis/stackgres/v1/sgpoolconfigs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
openapi: "3.0.2"
paths:
"/spec":
get:
responses:
"200":
content:
"application/json":
schema:
"$ref": "#/components/schemas/SGPoolingConfigSpec"
"/status":
get:
responses:
"200":
content:
"application/json":
schema:
"$ref": "#/components/schemas/SGPoolingConfigStatus"
components:
schemas:
SGPoolingConfigSpec:
type: object
properties:
pgBouncer:
type: object
description: |
Connection pooling configuration based on PgBouncer.
properties:
pgbouncer.ini:
type: object
description: |
The `pgbouncer.ini` parameters the configuration contains, represented as an object where the keys are valid names for the `pgbouncer.ini` configuration file parameters.

Check [pgbouncer configuration](https://www.pgbouncer.org/config.html#generic-settings) for more information about supported parameters.
properties:
pgbouncer:
type: object
additionalProperties: true
description: |
The `pgbouncer.ini` (Section [pgbouncer]) parameters the configuration contains, represented as an object where the keys are valid names for the `pgbouncer.ini` configuration file parameters.

Check [pgbouncer configuration](https://www.pgbouncer.org/config.html#generic-settings) for more information about supported parameters
databases:
type: object
additionalProperties:
type: object
additionalProperties: true
description: |
The `pgbouncer.ini` (Section [databases]) parameters the configuration contains, represented as an object where the keys are valid names for the `pgbouncer.ini` configuration file parameters.

Check [pgbouncer configuration](https://www.pgbouncer.org/config.html#section-databases) for more information about supported parameters.
users:
type: object
additionalProperties:
type: object
additionalProperties: true
description: |
The `pgbouncer.ini` (Section [users]) parameters the configuration contains, represented as an object where the keys are valid names for the `pgbouncer.ini` configuration file parameters.

Check [pgbouncer configuration](https://www.pgbouncer.org/config.html#section-users) for more information about supported parameters.
SGPoolingConfigStatus:
type: object
properties:
pgBouncer:
type: object
description: |
Connection pooling configuration status based on PgBouncer.
properties:
defaultParameters:
type: object
additionalProperties:
type: string
description: |
The `pgbouncer.ini` default parameters parameters which are used if not set.
required: ["defaultParameters"]
50 changes: 50 additions & 0 deletions apis/stackgres/v1/sgpoolconfigs_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 154 additions & 1 deletion apis/stackgres/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading