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

Remove pkg/serverconfig, merge to apis. #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
62 changes: 53 additions & 9 deletions apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"strconv"
"strings"

"github.com/Jeffail/gabs"
"github.com/k8ssandra/cass-operator/pkg/serverconfig"
gabs "github.com/Jeffail/gabs/v2"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -78,9 +77,7 @@ type CassandraUser struct {
}

// CassandraDatacenterSpec defines the desired state of a CassandraDatacenter
// +k8s:openapi-gen=true
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:XPreserveUnknownFields
// +kubebuilder:object:generate=true
type CassandraDatacenterSpec struct {
// Desired number of Cassandra server nodes
// +kubebuilder:validation:Minimum=1
Expand All @@ -105,7 +102,6 @@ type CassandraDatacenterSpec struct {

// Config for the server, in YAML format
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:XPreserveUnknownFields
Config json.RawMessage `json:"config,omitempty"`

// ConfigSecret is the name of a secret that contains configuration for Cassandra. The
Expand Down Expand Up @@ -372,7 +368,7 @@ func NewDatacenterConditionWithReason(conditionType DatacenterConditionType, sta
}

// CassandraDatacenterStatus defines the observed state of CassandraDatacenter
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type CassandraDatacenterStatus struct {
Conditions []DatacenterCondition `json:"conditions,omitempty"`

Expand Down Expand Up @@ -417,7 +413,7 @@ type CassandraDatacenterStatus struct {
}

// CassandraDatacenter is the Schema for the cassandradatacenters API
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=cassandradatacenters,scope=Namespaced,shortName=cassdc;cassdcs
Expand Down Expand Up @@ -676,7 +672,7 @@ func (dc *CassandraDatacenter) GetConfigAsJSON(config []byte) (string, error) {
internodeSSL = dc.Spec.Networking.NodePort.InternodeSSL
}

modelValues := serverconfig.GetModelValues(
modelValues := GetModelValues(
seeds,
dc.Spec.ClusterName,
dc.Name,
Expand Down Expand Up @@ -881,3 +877,51 @@ func SplitRacks(nodeCount, rackCount int) []int {

return topology
}

// +kubebuilder:object:generate=false
type NodeConfig map[string]interface{}

// GetModelValues will gather the cluster model values for cluster and datacenter
func GetModelValues(
seeds []string,
clusterName string,
dcName string,
graphEnabled int,
solrEnabled int,
sparkEnabled int,
nativePort int,
nativeSSLPort int,
internodePort int,
internodeSSLPort int) NodeConfig {

seedsString := strings.Join(seeds, ",")

// Note: the operator does not currently support graph, solr, and spark
modelValues := NodeConfig{
"cluster-info": NodeConfig{
"name": clusterName,
"seeds": seedsString,
},
"datacenter-info": NodeConfig{
"name": dcName,
"graph-enabled": graphEnabled,
"solr-enabled": solrEnabled,
"spark-enabled": sparkEnabled,
},
"cassandra-yaml": NodeConfig{},
}

if nativeSSLPort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["native_transport_port_ssl"] = nativeSSLPort
} else if nativePort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["native_transport_port"] = nativePort
}

if internodeSSLPort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["ssl_storage_port"] = internodeSSLPort
} else if internodePort != 0 {
modelValues["cassandra-yaml"].(NodeConfig)["storage_port"] = internodePort
}

return modelValues
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright DataStax, Inc.
// Please see the included license file for details.

package serverconfig
package v1beta1

import (
"reflect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8046,7 +8046,6 @@ spec:
- size
- storageConfig
type: object
x-kubernetes-preserve-unknown-fields: true
status:
description: CassandraDatacenterStatus defines the observed state of CassandraDatacenter
properties:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/k8ssandra/cass-operator
go 1.18

require (
github.com/Jeffail/gabs v1.4.0
github.com/davecgh/go-spew v1.1.1
github.com/go-logr/logr v1.2.3
github.com/google/uuid v1.1.2
Expand All @@ -22,6 +21,7 @@ require (
)

require (
github.com/Jeffail/gabs/v2 v2.6.1
github.com/onsi/ginkgo/v2 v2.2.0
go.uber.org/zap v1.19.1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUM
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
github.com/Jeffail/gabs/v2 v2.6.1 h1:wwbE6nTQTwIMsMxzi6XFQQYRZ6wDc1mSdxoAN+9U4Gk=
github.com/Jeffail/gabs/v2 v2.6.1/go.mod h1:xCn81vdHKxFUuWWAaD5jCTQDNPBMh5pPs9IJ+NcziBI=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down
56 changes: 0 additions & 56 deletions pkg/serverconfig/configgen.go

This file was deleted.