Skip to content

Commit

Permalink
MsSQL -> MSSQL
Browse files Browse the repository at this point in the history
Signed-off-by: Neaj Morshad <[email protected]>
  • Loading branch information
Neaj-Morshad-101 committed Apr 22, 2024
1 parent c2de281 commit 2a752ba
Show file tree
Hide file tree
Showing 51 changed files with 3,096 additions and 1,619 deletions.
20 changes: 10 additions & 10 deletions mssql/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import (

type KubeDBClientBuilder struct {
kc client.Client
db *api.MsSQL
db *api.MSSQL
url string
podName string
ctx context.Context
}

func NewKubeDBClientBuilder(kc client.Client, db *api.MsSQL) *KubeDBClientBuilder {
func NewKubeDBClientBuilder(kc client.Client, db *api.MSSQL) *KubeDBClientBuilder {
return &KubeDBClientBuilder{
kc: kc,
db: db,
Expand All @@ -58,7 +58,7 @@ func (o *KubeDBClientBuilder) WithContext(ctx context.Context) *KubeDBClientBuil
return o
}

func (o *KubeDBClientBuilder) GetMsSQLXormClient() (*XormClient, error) {
func (o *KubeDBClientBuilder) GetMSSQLXormClient() (*XormClient, error) {
if o.ctx == nil {
o.ctx = context.Background()
}
Expand All @@ -67,7 +67,7 @@ func (o *KubeDBClientBuilder) GetMsSQLXormClient() (*XormClient, error) {
return nil, err
}

engine, err := xorm.NewEngine(api.ResourceSingularMsSQL, connector)
engine, err := xorm.NewEngine(api.ResourceSingularMSSQL, connector)
if err != nil {
return nil, err
}
Expand All @@ -87,7 +87,7 @@ func (o *KubeDBClientBuilder) getURL() string {
return fmt.Sprintf("%s.%s.%s.svc", o.podName, o.db.GoverningServiceName(), o.db.Namespace)
}

func (o *KubeDBClientBuilder) getMsSQLSACredentials() (string, string, error) {
func (o *KubeDBClientBuilder) getMSSQLSACredentials() (string, string, error) {
db := o.db
var secretName string
if db.Spec.AuthSecret != nil {
Expand All @@ -110,7 +110,7 @@ func (o *KubeDBClientBuilder) getMsSQLSACredentials() (string, string, error) {
}

func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
user, pass, err := o.getMsSQLSACredentials()
user, pass, err := o.getMSSQLSACredentials()
if err != nil {
return "", err
}
Expand All @@ -124,7 +124,7 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
//if o.db.Spec.RequireSSL && o.db.Spec.TLS != nil {
// // get client-secret
// var clientSecret core.Secret
// err := o.kc.Get(o.ctx, client.ObjectKey{Namespace: o.db.GetNamespace(), Name: o.db.GetCertSecretName(api.MsSQLClientCert)}, &clientSecret)
// err := o.kc.Get(o.ctx, client.ObjectKey{Namespace: o.db.GetNamespace(), Name: o.db.GetCertSecretName(api.MSSQLClientCert)}, &clientSecret)
// if err != nil {
// return "", err
// }
Expand All @@ -143,13 +143,13 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) {
//
// // tls custom setup
// if o.db.Spec.RequireSSL {
// mssql_driver.RegisterTLSConfig(api.MsSQLTLSConfigCustom, &tls.Config{
// mssql_driver.RegisterTLSConfig(api.MSSQLTLSConfigCustom, &tls.Config{
// RootCAs: certPool,
// Certificates: clientCert,
// })
// tlsConfig = fmt.Sprintf("tls=%s", api.MsSQLTLSConfigCustom)
// tlsConfig = fmt.Sprintf("tls=%s", api.MSSQLTLSConfigCustom)
// } else {
// tlsConfig = fmt.Sprintf("tls=%s", api.MsSQLTLSConfigSkipVerify)
// tlsConfig = fmt.Sprintf("tls=%s", api.MSSQLTLSConfigSkipVerify)
// }
//}

Expand Down
44 changes: 44 additions & 0 deletions vendor/kmodules.xyz/offshoot-api/api/v1/openapi_generated.go

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

19 changes: 19 additions & 0 deletions vendor/kmodules.xyz/offshoot-api/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,25 @@ type ServicePort struct {
NodePort int32 `json:"nodePort,omitempty"`
}

// GatewayPort contains information on Gateway service's port.
type GatewayPort struct {
// The name of this port within the gateway service.
// +optional
Name string `json:"name,omitempty"`

// The port that will be exposed by the gateway service.
Port int32 `json:"port"`

// Number of the port to access the backend service.
// +optional
BackendServicePort int32 `json:"backendServicePort,omitempty"`

// The port on each node on which this gateway service is exposed when type is
// NodePort or LoadBalancer.
// +optional
NodePort int32 `json:"nodePort,omitempty"`
}

// Beware of MergeServicePorts
// ref: https://github.com/kmodules/client-go/blob/03dac1aea5084354127990a10d0b0e7529460dd5/core/v1/service.go#L103-L136
func PatchServicePorts(cur []core.ServicePort, desired []ServicePort) []core.ServicePort {
Expand Down
16 changes: 16 additions & 0 deletions vendor/kmodules.xyz/offshoot-api/api/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,39 @@ import (
"kmodules.xyz/client-go/apiextensions"
)

func (m MsSQLVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMsSQLVersion))
func (m MSSQLVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMSSQLVersion))
}

var _ apis.ResourceInfo = &MsSQLVersion{}
var _ apis.ResourceInfo = &MSSQLVersion{}

func (m MsSQLVersion) ResourceFQN() string {
return fmt.Sprintf("%s.%s", ResourcePluralMsSQLVersion, catalog.GroupName)
func (m MSSQLVersion) ResourceFQN() string {
return fmt.Sprintf("%s.%s", ResourcePluralMSSQLVersion, catalog.GroupName)
}

func (m MsSQLVersion) ResourceShortCode() string {
return ResourceCodeMsSQLVersion
func (m MSSQLVersion) ResourceShortCode() string {
return ResourceCodeMSSQLVersion
}

func (m MsSQLVersion) ResourceKind() string {
return ResourceKindMsSQLVersion
func (m MSSQLVersion) ResourceKind() string {
return ResourceKindMSSQLVersion
}

func (m MsSQLVersion) ResourceSingular() string {
return ResourceSingularMsSQLVersion
func (m MSSQLVersion) ResourceSingular() string {
return ResourceSingularMSSQLVersion
}

func (m MsSQLVersion) ResourcePlural() string {
return ResourcePluralMsSQLVersion
func (m MSSQLVersion) ResourcePlural() string {
return ResourcePluralMSSQLVersion
}

func (m MsSQLVersion) ValidateSpecs() error {
func (m MSSQLVersion) ValidateSpecs() error {
if m.Spec.Version == "" || m.Spec.DB.Image == "" || m.Spec.Coordinator.Image == "" {
return fmt.Errorf(`at least one of the following specs is not set for MsSQLVersion "%v":
return fmt.Errorf(`at least one of the following specs is not set for MSSQLVersion "%v":
spec.version,
spec.coordinator.image,
spec.initContainer.image`, m.Name)
}
// TODO: add m.spec.exporter.image check FOR monitoring
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ import (
appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1"
)

// 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.

// TODO:
// set scope=Cluster for MsSQLVersion struct

const (
ResourceCodeMsSQLVersion = "msversion"
ResourceKindMsSQLVersion = "MsSQLVersion"
ResourceSingularMsSQLVersion = "mssqlversion"
ResourcePluralMsSQLVersion = "mssqlversions"
ResourceCodeMSSQLVersion = "msversion"
ResourceKindMSSQLVersion = "MSSQLVersion"
ResourceSingularMSSQLVersion = "mssqlversion"
ResourcePluralMSSQLVersion = "mssqlversions"
)

// +genclient
Expand All @@ -41,28 +35,28 @@ const (
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=mssqlversions,singular=mssqlversion,shortName=msversion,categories={datastore,kubedb,appscode}
// +kubebuilder:resource:path=mssqlversions,singular=mssqlversion,scope=Cluster,shortName=msversion,categories={datastore,kubedb,appscode}
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
// +kubebuilder:printcolumn:name="DB_IMAGE",type="string",JSONPath=".spec.db.image"
// +kubebuilder:printcolumn:name="Deprecated",type="boolean",JSONPath=".spec.deprecated"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type MsSQLVersion struct {
type MSSQLVersion struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MsSQLVersionSpec `json:"spec,omitempty"`
Spec MSSQLVersionSpec `json:"spec,omitempty"`
}

// MsSQLVersionSpec defines the desired state of MsSQL Version
type MsSQLVersionSpec struct {
// MSSQLVersionSpec defines the desired state of MSSQL Version
type MSSQLVersionSpec struct {
// Version
Version string `json:"version"`
// Database Image
DB MsSQLVersionDatabase `json:"db"`
DB MSSQLVersionDatabase `json:"db"`
// Coordinator Image
// +optional
Coordinator MsSQLCoordinator `json:"coordinator,omitempty"`
Coordinator MSSQLCoordinator `json:"coordinator,omitempty"`
// Init container Image
InitContainer MsSQLInitContainer `json:"initContainer"`
InitContainer MSSQLInitContainer `json:"initContainer"`
// Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded.
// +optional
Deprecated bool `json:"deprecated,omitempty"`
Expand All @@ -71,45 +65,45 @@ type MsSQLVersionSpec struct {
Stash appcat.StashAddonSpec `json:"stash,omitempty"`
// SecurityContext is for the additional config for the DB container
// +optional
SecurityContext MsSQLSecurityContext `json:"securityContext"`
SecurityContext MSSQLSecurityContext `json:"securityContext"`
// PSP names
// +optional
PodSecurityPolicies MsSQLVersionPodSecurityPolicy `json:"podSecurityPolicies"`
PodSecurityPolicies MSSQLVersionPodSecurityPolicy `json:"podSecurityPolicies"`
// update constraints
UpdateConstraints UpdateConstraints `json:"updateConstraints,omitempty"`
}

// MsSQLVersionDatabase is the MsSQL Database image
type MsSQLVersionDatabase struct {
// MSSQLVersionDatabase is the MSSQL Database image
type MSSQLVersionDatabase struct {
Image string `json:"image"`
}

// MsSQLCoordinator is the MSSQL coordinator Container image
type MsSQLCoordinator struct {
// MSSQLCoordinator is the MSSQL coordinator Container image
type MSSQLCoordinator struct {
Image string `json:"image"`
}

// MsSQLInitContainer is the MsSQL Container initializer
type MsSQLInitContainer struct {
// MSSQLInitContainer is the MSSQL Container initializer
type MSSQLInitContainer struct {
Image string `json:"image"`
}

// MsSQLVersionPodSecurityPolicy is the MsSQL pod security policies
type MsSQLVersionPodSecurityPolicy struct {
// MSSQLVersionPodSecurityPolicy is the MSSQL pod security policies
type MSSQLVersionPodSecurityPolicy struct {
DatabasePolicyName string `json:"databasePolicyName"`
}

// MsSQLSecurityContext is for additional configuration for the MSSQL database container
type MsSQLSecurityContext struct {
// MSSQLSecurityContext is for additional configuration for the MSSQL database container
type MSSQLSecurityContext struct {
RunAsUser *int64 `json:"runAsUser,omitempty"`
RunAsGroup *int64 `json:"runAsGroup,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// MsSQLVersionList contains a list of MsSQLVersion
type MsSQLVersionList struct {
// MSSQLVersionList contains a list of MSSQLVersion
type MSSQLVersionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MsSQLVersion `json:"items"`
Items []MSSQLVersion `json:"items"`
}
Loading

0 comments on commit 2a752ba

Please sign in to comment.