Skip to content

Commit

Permalink
Prepare for release v0.0.9 (#83)
Browse files Browse the repository at this point in the history
ProductLine: KubeDB

Release: v2024.1.26-rc.0

Release-tracker: kubedb/CHANGELOG#82

Signed-off-by: 1gtm <[email protected]>
  • Loading branch information
1gtm authored Jan 27, 2024
1 parent 22edae9 commit b254eda
Show file tree
Hide file tree
Showing 41 changed files with 749 additions and 216 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/elastic/go-elasticsearch/v7 v7.15.1
github.com/elastic/go-elasticsearch/v8 v8.4.0
github.com/go-resty/resty/v2 v2.11.0
github.com/go-sql-driver/mysql v1.7.0
github.com/go-sql-driver/mysql v1.7.1
github.com/lib/pq v1.10.7
github.com/opensearch-project/opensearch-go v1.1.0
github.com/opensearch-project/opensearch-go/v2 v2.2.0
Expand All @@ -21,8 +21,8 @@ require (
k8s.io/apimachinery v0.29.0
k8s.io/klog/v2 v2.110.1
kmodules.xyz/client-go v0.29.6
kmodules.xyz/custom-resources v0.29.0
kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c
kmodules.xyz/custom-resources v0.29.1
kubedb.dev/apimachinery v0.41.0-rc.0
sigs.k8s.io/controller-runtime v0.16.3
xorm.io/xorm v1.3.6
)
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogB
github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-resty/resty/v2 v2.11.0 h1:i7jMfNOJYMp69lq7qozJP+bjgzfAzeOhuGlyDrqxT/8=
github.com/go-resty/resty/v2 v2.11.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
Expand Down Expand Up @@ -574,14 +575,14 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/client-go v0.29.6 h1:xTVq5LZvsPBUTLY7PORq7zveLOj/vpuTDvkpHWOk3RM=
kmodules.xyz/client-go v0.29.6/go.mod h1:pHuzpwzEcDUIGjVVvwz9N8lY+6A7HXwvs2d7NtK7Hho=
kmodules.xyz/custom-resources v0.29.0 h1:RaDM2+wSVXiwIvLqmkTVYpwoH83AC8wruXe2p2rOZNY=
kmodules.xyz/custom-resources v0.29.0/go.mod h1:MzZyXtxdg1PDxGk3RTTO1Xv3KiVqZnIonSwmxVbagOY=
kmodules.xyz/custom-resources v0.29.1 h1:xiNylhs3ILRbcUhxxy306AOy9GMA4Mq7xFIptZKgal4=
kmodules.xyz/custom-resources v0.29.1/go.mod h1:829zDY1EjaxPP52h1T73LZx/vgv8Pld9/uTT/ViZTc0=
kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9H1UFRwB4=
kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI=
kmodules.xyz/offshoot-api v0.29.0 h1:GHLhxxT9jU1N8+FvOCCeJNyU5g0duYS46UGrs6AHNLY=
kmodules.xyz/offshoot-api v0.29.0/go.mod h1:5NxhBblXoDHWStx9HCDJR2KFTwYjEZ7i1Id3jelIunw=
kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c h1:QdnEBPdmd/Z3JOFJKMQ3nCFiJYiWxsuIAqMLgXep880=
kubedb.dev/apimachinery v0.41.0-beta.1.0.20240124061503-ce4799bb0e5c/go.mod h1:IqIwU4I/UfmcMi4X7G01M7XAEFUPehtiFAKZNKwH8Ek=
kubedb.dev/apimachinery v0.41.0-rc.0 h1:229M2WXAQ47ELuwkHCBXOAeDcrGX9lbSbMyk++esRlY=
kubedb.dev/apimachinery v0.41.0-rc.0/go.mod h1:DghpLFmqVyQX0kUcZRTbdV9omaxRwtw9IzdJsPqdqiI=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/go-sql-driver/mysql/AUTHORS

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

13 changes: 13 additions & 0 deletions vendor/github.com/go-sql-driver/mysql/CHANGELOG.md

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

4 changes: 2 additions & 2 deletions vendor/github.com/go-sql-driver/mysql/README.md

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

4 changes: 2 additions & 2 deletions vendor/github.com/go-sql-driver/mysql/connection.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/go-sql-driver/mysql/const.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/go-sql-driver/mysql/errors.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 @@ -81,7 +81,7 @@ func (a AppBinding) Host() (string, error) {
} else if c.URL != nil {
u, err := url.Parse(*c.URL)
if err != nil {
return "", err
return ParseMySQLHost(*c.URL)
}
return u.Host, nil
}
Expand All @@ -99,7 +99,7 @@ func (a AppBinding) Hostname() (string, error) {
} else if c.URL != nil {
u, err := url.Parse(*c.URL)
if err != nil {
return "", err
return ParseMySQLHostname(*c.URL)
}
return u.Hostname(), nil
}
Expand All @@ -111,12 +111,18 @@ func (a AppBinding) Port() (int32, error) {
if c.Service != nil { // preferred source for MYSQL app binding
return c.Service.Port, nil
} else if c.URL != nil {
var port string
u, err := url.Parse(*c.URL)
if err != nil {
return 0, err
port, err = ParseMySQLPort(*c.URL)
if err != nil {
return 0, nil
}
} else {
port = u.Port()
}
port, err := strconv.ParseInt(u.Port(), 10, 32)
return int32(port), err
result, err := strconv.ParseInt(port, 10, 32)
return int32(result), err
}
return 0, errors.New("connection url is missing")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright AppsCode Inc. and Contributors
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 v1alpha1

import (
"net"
"net/url"
"strings"

"github.com/go-sql-driver/mysql"
)

/*
MySQL Go driver (https://github.com/go-sql-driver/mysql) uses a custom connection string (DSN) format.
[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
*/

func (a AppBinding) MySQLDSN() (string, error) {
dsn, err := a.URL()
if err != nil {
return "", err
}
return CanonicalMySQLDSN(dsn)
}

// CanonicalMySQLDSN will convert a regular URL into MySQL DSN format
func CanonicalMySQLDSN(dsn string) (string, error) {
_, err := mysql.ParseDSN(dsn)
if err == nil {
return dsn, nil
}

u, err := url.Parse(dsn)
if err != nil {
return "", err
}

rebuild := mysql.NewConfig()
rebuild.Net = u.Scheme
rebuild.Addr = u.Host
rebuild.DBName = strings.TrimPrefix(u.Path, "/")
if u.User != nil {
rebuild.User = u.User.Username()
if pass, found := u.User.Password(); found {
rebuild.Passwd = pass
}
}
rebuild.Params = map[string]string{}
for k, v := range u.Query() {
rebuild.Params[k] = v[0]
}
return rebuild.FormatDSN(), nil
}

func ParseMySQLHost(dsn string) (string, error) {
cfg, err := mysql.ParseDSN(dsn)
if err != nil {
return "", err
}
return cfg.Addr, err
}

func ParseMySQLHostname(dsn string) (string, error) {
cfg, err := mysql.ParseDSN(dsn)
if err != nil {
return "", err
}
host, _, err := net.SplitHostPort(cfg.Addr)
return host, err
}

func ParseMySQLPort(dsn string) (string, error) {
cfg, err := mysql.ParseDSN(dsn)
if err != nil {
return "", err
}
_, port, err := net.SplitHostPort(cfg.Addr)
return port, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const (
KibanaStatusEndpoint = "/api/status"
KibanaConfigFileName = "kibana.yml"

OpensearchDashboardsConfigDir = "/usr/share/opensearch-elasticsearchs/config"
OpensearchDashboardsTempConfigDir = "/opensearch-elasticsearchs/temp-config"
OpensearchDashboardsCustomConfigDir = "/opensearch-elasticsearchs/custom-config"
OpensearchDashboardsConfigDir = "/usr/share/opensearch-dashboards/config"
OpensearchDashboardsTempConfigDir = "/opensearch-dashboards/temp-config"
OpensearchDashboardsCustomConfigDir = "/opensearch-dashboards/custom-config"
OpensearchDashboardsStatusEndpoint = "/api/status"
OpensearchDasboardsConfigFileName = "opensearch_elasticsearchs.yml"
OpensearchDasboardsConfigFileName = "opensearch_dashboards.yml"

ElasticsearchHostsKey = "elasticsearch.hosts"
ElasticsearchSSLCaKey = "elasticsearch.ssl.certificateAuthorities"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const (
type DashboardVolumeName string

const (
DashboardVolumeCustomConfig DashboardVolumeName = "elasticsearch-custom-config"
DashboardVolumeOperatorGeneratedConfig DashboardVolumeName = "elasticsearch-temp-config"
DashboardVolumeConfig DashboardVolumeName = "elasticsearch-config"
DashboardVolumeCustomConfig DashboardVolumeName = "dashboard-custom-config"
DashboardVolumeOperatorGeneratedConfig DashboardVolumeName = "dashboard-temp-config"
DashboardVolumeConfig DashboardVolumeName = "dashboard-config"
DashboardVolumeServerTLS DashboardVolumeName = "server-tls"
DashboardVolumeDatabaseClient DashboardVolumeName = "database-client"
)
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ func (k *ConnectCluster) ConfigSecretName() string {
return meta_util.NameWithSuffix(k.OffshootName(), "config")
}

func (k *ConnectCluster) GetPersistentSecrets() []string {
var secrets []string
if k.Spec.AuthSecret != nil {
secrets = append(secrets, k.Spec.AuthSecret.Name)
}
if k.Spec.KeystoreCredSecret != nil {
secrets = append(secrets, k.Spec.KeystoreCredSecret.Name)
}
return secrets
}

func (k *ConnectCluster) KafkaClientCredentialsSecretName() string {
return meta_util.NameWithSuffix(k.Name, "kafka-client-cred")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (k *ConnectCluster) ValidateUpdate(old runtime.Object) (admission.Warnings,
if len(allErr) == 0 {
return nil, nil
}
return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "Kafka"}, k.Name, allErr)
return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "ConnectCluster"}, k.Name, allErr)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
Expand Down Expand Up @@ -111,6 +111,12 @@ func (k *ConnectCluster) ValidateCreateOrUpdate() field.ErrorList {
}
}

if k.Spec.TerminationPolicy == api.TerminationPolicyHalt {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"),
k.Name,
"TerminationPolicyHalt is not supported for ConnectCluster"))
}

// number of replicas can not be 0 or less
if k.Spec.Replicas != nil && *k.Spec.Replicas <= 0 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"),
Expand Down
Loading

0 comments on commit b254eda

Please sign in to comment.