Skip to content

Commit

Permalink
Merge pull request #13 from amazeeio/postgres
Browse files Browse the repository at this point in the history
Add support for PostgreSQL
  • Loading branch information
shreddedbacon authored Sep 25, 2020
2 parents 345b43e + 279f442 commit 5d1bde7
Show file tree
Hide file tree
Showing 54 changed files with 1,979 additions and 94 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY apis/ apis/
COPY controllers/ controllers/

# Build
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ operator-test:

clean:
docker-compose down
kind delete cluster --name ${KIND_NAME}
kind delete cluster --name ${KIND_NAME}

local-circle:
circleci build -v $(shell pwd):/workdir
1 change: 1 addition & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ resources:
kind: MariaDBProvider
version: v1
version: "2"
multigroup: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions apis/postgres/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1 contains API Schema definitions for the postgres v1 API group
// +kubebuilder:object:generate=true
// +groupName=postgres.amazee.io
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "postgres.amazee.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
85 changes: 85 additions & 0 deletions apis/postgres/v1/postgresqlconsumer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// PostgreSQLConsumerSpec defines the desired state of PostgreSQLConsumer
type PostgreSQLConsumerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// These are the spec options for consumers
Environment string `json:"environment,omitempty"`
Provider PostgreSQLConsumerProvider `json:"provider,omitempty"`
Consumer PostgreSQLConsumerData `json:"consumer,omitempty"`
}

// PostgreSQLConsumerData defines the provider link for this consumer
type PostgreSQLConsumerData struct {
Database string `json:"database,omitempty"`
Password string `json:"password,omitempty"`
Username string `json:"username,omitempty"`
Services PostgreSQLConsumerServices `json:"services,omitempty"`
}

// PostgreSQLConsumerServices defines the provider link for this consumer
type PostgreSQLConsumerServices struct {
Primary string `json:"primary,omitempty"`
}

// PostgreSQLConsumerProvider defines the provider link for this consumer
type PostgreSQLConsumerProvider struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Hostname string `json:"hostname,omitempty"`
Port string `json:"port,omitempty"`
}

// PostgreSQLConsumerStatus defines the observed state of PostgreSQLConsumer
type PostgreSQLConsumerStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true

// PostgreSQLConsumer is the Schema for the postgresqlconsumers API
type PostgreSQLConsumer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PostgreSQLConsumerSpec `json:"spec,omitempty"`
Status PostgreSQLConsumerStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// PostgreSQLConsumerList contains a list of PostgreSQLConsumer
type PostgreSQLConsumerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PostgreSQLConsumer `json:"items"`
}

func init() {
SchemeBuilder.Register(&PostgreSQLConsumer{}, &PostgreSQLConsumerList{})
}
69 changes: 69 additions & 0 deletions apis/postgres/v1/postgresqlprovider_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// PostgreSQLProviderSpec defines the desired state of PostgreSQLProvider
type PostgreSQLProviderSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// These are the spec options for providers
Environment string `json:"environment,omitempty"`
Hostname string `json:"hostname,omitempty"`
Password string `json:"password,omitempty"`
Port string `json:"port,omitempty"`
Username string `json:"user,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Type string `json:"type,omitempty"`
}

// PostgreSQLProviderStatus defines the observed state of PostgreSQLProvider
type PostgreSQLProviderStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true

// PostgreSQLProvider is the Schema for the postgresqlproviders API
type PostgreSQLProvider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PostgreSQLProviderSpec `json:"spec,omitempty"`
Status PostgreSQLProviderStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// PostgreSQLProviderList contains a list of PostgreSQLProvider
type PostgreSQLProviderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PostgreSQLProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&PostgreSQLProvider{}, &PostgreSQLProviderList{})
}
Loading

0 comments on commit 5d1bde7

Please sign in to comment.