Skip to content

Commit b140430

Browse files
authored
[Refactor] Split API and Core cross-dependency (#942)
1 parent 89f067b commit b140430

File tree

94 files changed

+645
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+645
-583
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- (Refactor) Configurable throttle inspector
1515
- (Bugfix) Skip Replace operation on DBServer if they need to be scaled down
1616
- (Feature) Upgrade procedure steps
17+
- (Refactor) Remove API and Core cross-dependency
1718

1819
## [1.2.8](https://github.com/arangodb/kube-arangodb/tree/1.2.8) (2022-02-24)
1920
- Do not check License V2 on Community images

cmd/admin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/arangodb/go-driver/jwt"
4444
"github.com/arangodb/go-driver/v2/connection"
4545
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
46+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
4647
"github.com/arangodb/kube-arangodb/pkg/util/constants"
4748
"github.com/arangodb/kube-arangodb/pkg/util/errors"
4849
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
@@ -222,10 +223,10 @@ func getDeploymentAndCredentials(ctx context.Context,
222223
// getArangoEndpoint returns ArangoDB endpoint with scheme and port for the given dnsName.
223224
func getArangoEndpoint(secure bool, dnsName string) string {
224225
if secure {
225-
return "https://" + net.JoinHostPort(dnsName, strconv.Itoa(k8sutil.ArangoPort))
226+
return "https://" + net.JoinHostPort(dnsName, strconv.Itoa(shared.ArangoPort))
226227
}
227228

228-
return "http://" + net.JoinHostPort(dnsName, strconv.Itoa(k8sutil.ArangoPort))
229+
return "http://" + net.JoinHostPort(dnsName, strconv.Itoa(shared.ArangoPort))
229230
}
230231

231232
// getAgencyLeader returns the leader ID of the agency.

cmd/lifecycle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/spf13/cobra"
3939
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4040

41+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
4142
"github.com/arangodb/kube-arangodb/pkg/util/constants"
4243
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
4344
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
@@ -187,7 +188,7 @@ type cmdLifecyclePreStopRunPort struct {
187188

188189
// Wait until port 8529 is closed.
189190
func (c *cmdLifecyclePreStopRunPort) run(cmd *cobra.Command, args []string) error {
190-
address := net.JoinHostPort("127.0.0.1", strconv.Itoa(k8sutil.ArangoPort))
191+
address := net.JoinHostPort("127.0.0.1", strconv.Itoa(shared.ArangoPort))
191192

192193
// Get environment
193194
namespace := os.Getenv(constants.EnvOperatorPodNamespace)

cmd/lifecycle_probes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import (
2929
"path"
3030

3131
"github.com/arangodb/go-driver/jwt"
32+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
3233
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
3334
"github.com/arangodb/kube-arangodb/pkg/util/constants"
34-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3535
"github.com/pkg/errors"
3636
"github.com/rs/zerolog/log"
3737
"github.com/spf13/cobra"
@@ -57,7 +57,7 @@ func init() {
5757
f.BoolVarP(&probeInput.SSL, "ssl", "", false, "Determines if SSL is enabled")
5858
f.BoolVarP(&probeInput.Auth, "auth", "", false, "Determines if authentication is enabled")
5959
f.StringVarP(&probeInput.Endpoint, "endpoint", "", "/_api/version", "Endpoint (path) to call for lifecycle probe")
60-
f.StringVarP(&probeInput.JWTPath, "jwt", "", k8sutil.ClusterJWTSecretVolumeMountDir, "Path to the JWT tokens")
60+
f.StringVarP(&probeInput.JWTPath, "jwt", "", shared.ClusterJWTSecretVolumeMountDir, "Path to the JWT tokens")
6161
}
6262

6363
func probeClient() *http.Client {
@@ -80,7 +80,7 @@ func probeEndpoint(endpoint string) string {
8080
proto = "https"
8181
}
8282

83-
return fmt.Sprintf("%s://%s:%d%s", proto, "127.0.0.1", k8sutil.ArangoPort, endpoint)
83+
return fmt.Sprintf("%s://%s:%d%s", proto, "127.0.0.1", shared.ArangoPort, endpoint)
8484
}
8585

8686
func readJWTFile(file string) ([]byte, error) {

pkg/apis/deployment/v1/architecture.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ package v1
2323
import (
2424
"runtime"
2525

26-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
27-
26+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2827
"github.com/pkg/errors"
2928
core "k8s.io/api/core/v1"
3029
)
@@ -77,7 +76,7 @@ func (a ArangoDeploymentArchitectureType) AsNodeSelectorRequirement() core.NodeS
7776
return core.NodeSelectorTerm{
7877
MatchExpressions: []core.NodeSelectorRequirement{
7978
{
80-
Key: k8sutil.NodeArchAffinityLabel,
79+
Key: shared.NodeArchAffinityLabel,
8180
Operator: "In",
8281
Values: []string{string(a)},
8382
},
@@ -90,7 +89,7 @@ func GetArchsFromNodeSelector(selectors []core.NodeSelectorTerm) map[ArangoDeplo
9089
for _, selector := range selectors {
9190
if selector.MatchExpressions != nil {
9291
for _, req := range selector.MatchExpressions {
93-
if req.Key == k8sutil.NodeArchAffinityLabel || req.Key == k8sutil.NodeArchAffinityLabelBeta {
92+
if req.Key == shared.NodeArchAffinityLabel || req.Key == shared.NodeArchAffinityLabelBeta {
9493
for _, arch := range req.Values {
9594
result[ArangoDeploymentArchitectureType(arch)] = true
9695
}

pkg/apis/deployment/v1/authentication_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
package v1
2222

2323
import (
24+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2425
"github.com/arangodb/kube-arangodb/pkg/util"
2526
"github.com/arangodb/kube-arangodb/pkg/util/errors"
26-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
2727
)
2828

2929
// AuthenticationSpec holds authentication specific configuration settings
@@ -53,7 +53,7 @@ func (s AuthenticationSpec) Validate(required bool) error {
5353
return errors.WithStack(errors.Wrap(ValidationError, "JWT secret is required"))
5454
}
5555
if s.IsAuthenticated() {
56-
if err := k8sutil.ValidateResourceName(s.GetJWTSecretName()); err != nil {
56+
if err := shared.ValidateResourceName(s.GetJWTSecretName()); err != nil {
5757
return errors.WithStack(err)
5858
}
5959
}

pkg/apis/deployment/v1/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package v1
2323
import (
2424
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2525

26-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
26+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2727
)
2828

2929
const (
@@ -76,7 +76,7 @@ func (s PasswordSecretNameList) GetSecretName(user string) PasswordSecretName {
7676

7777
// getSecretNameForUserPassword returns the default secret name for the given user
7878
func getSecretNameForUserPassword(deploymentname, username string) PasswordSecretName {
79-
return PasswordSecretName(k8sutil.FixupResourceName(deploymentname + "-" + username + "-password"))
79+
return PasswordSecretName(shared.FixupResourceName(deploymentname + "-" + username + "-password"))
8080
}
8181

8282
// Validate the specification.
@@ -92,7 +92,7 @@ func (b *BootstrapSpec) Validate() error {
9292
return errors.Newf("magic value None not allowed for %s", username)
9393
}
9494
} else {
95-
if err := k8sutil.ValidateResourceName(string(secretname)); err != nil {
95+
if err := shared.ValidateResourceName(string(secretname)); err != nil {
9696
return errors.WithStack(err)
9797
}
9898
}

pkg/apis/deployment/v1/deployment_metrics_spec.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
package v1
2323

2424
import (
25+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2526
"github.com/arangodb/kube-arangodb/pkg/util"
26-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
2727
v1 "k8s.io/api/core/v1"
2828
)
2929

@@ -44,9 +44,9 @@ func (m MetricsMode) New() *MetricsMode {
4444
func (m MetricsMode) GetMetricsEndpoint() string {
4545
switch m {
4646
case MetricsModeInternal:
47-
return k8sutil.ArangoExporterInternalEndpoint
47+
return shared.ArangoExporterInternalEndpoint
4848
default:
49-
return k8sutil.ArangoExporterDefaultEndpoint
49+
return shared.ArangoExporterDefaultEndpoint
5050
}
5151
}
5252

@@ -94,7 +94,7 @@ func (s *MetricsSpec) IsTLS() bool {
9494

9595
func (s *MetricsSpec) GetPort() uint16 {
9696
if s == nil || s.Port == nil {
97-
return k8sutil.ArangoExporterPort
97+
return shared.ArangoExporterPort
9898
}
9999

100100
return *s.Port
@@ -156,7 +156,7 @@ func (s *MetricsSpec) SetDefaultsFrom(source MetricsSpec) {
156156
func (s *MetricsSpec) Validate() error {
157157

158158
if s.HasJWTTokenSecretName() {
159-
if err := k8sutil.ValidateResourceName(s.GetJWTTokenSecretName()); err != nil {
159+
if err := shared.ValidateResourceName(s.GetJWTTokenSecretName()); err != nil {
160160
return err
161161
}
162162
}

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828

2929
core "k8s.io/api/core/v1"
3030

31+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
3132
"github.com/arangodb/kube-arangodb/pkg/handlers/utils"
3233
"github.com/arangodb/kube-arangodb/pkg/util"
3334
"github.com/arangodb/kube-arangodb/pkg/util/errors"
34-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3535
)
3636

3737
var (
@@ -547,12 +547,12 @@ func (s DeploymentSpec) Checksum() (string, error) {
547547
func (s DeploymentSpec) GetCoreContainers(group ServerGroup) utils.StringList {
548548
groupSpec := s.GetServerGroupSpec(group)
549549
if len(groupSpec.SidecarCoreNames) == 0 {
550-
return utils.StringList{k8sutil.ServerContainerName}
550+
return utils.StringList{shared.ServerContainerName}
551551
}
552552

553553
result := make(utils.StringList, 0, len(groupSpec.SidecarCoreNames)+1)
554-
if !utils.StringList(groupSpec.SidecarCoreNames).Has(k8sutil.ServerContainerName) {
555-
result = append(result, k8sutil.ServerContainerName)
554+
if !utils.StringList(groupSpec.SidecarCoreNames).Has(shared.ServerContainerName) {
555+
result = append(result, shared.ServerContainerName)
556556
}
557557
result = append(result, groupSpec.SidecarCoreNames...)
558558

pkg/apis/deployment/v1/license_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
package v1
2222

2323
import (
24+
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2425
"github.com/arangodb/kube-arangodb/pkg/util"
25-
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
2626
)
2727

2828
// LicenseSpec holds the license related information
@@ -43,7 +43,7 @@ func (s LicenseSpec) GetSecretName() string {
4343
// Validate validates the LicenseSpec
4444
func (s LicenseSpec) Validate() error {
4545
if s.HasSecretName() {
46-
if err := k8sutil.ValidateResourceName(s.GetSecretName()); err != nil {
46+
if err := shared.ValidateResourceName(s.GetSecretName()); err != nil {
4747
return err
4848
}
4949
}

0 commit comments

Comments
 (0)