Skip to content

Commit

Permalink
[Feature] ConfigV1 Integration Service
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow committed Aug 26, 2024
1 parent e97e425 commit c6212ad
Show file tree
Hide file tree
Showing 37 changed files with 2,385 additions and 57 deletions.
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ linters-settings:
alias: pbAuthorizationV0
- pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0
alias: pbImplAuthorizationV0
- pkg: github.com/arangodb/kube-arangodb/integrations/config/v1/definition
alias: pbConfigV1
- pkg: github.com/arangodb/kube-arangodb/integrations/config/v1
alias: pbImplConfigV1
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1/definition
alias: pbSharedV1
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- (Maintenance) Switch to ubuntu:24.04 base image
- (Feature) Gateway Group for ArangoDeployment
- (Feature) Gateway config loader
- (Feature) ConfigV1 Integration Service

## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries
Expand Down
14 changes: 2 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -726,19 +726,9 @@ manifest-verify-helm-ee: manifests-verify-env-reset
.PHONY: run-unit-tests
run-unit-tests: $(SOURCES)
go test --count=1 --tags "$(GOBUILDTAGS)" $(TESTVERBOSEOPTIONS) \
$(REPOPATH)/pkg/apis/shared/... \
$(REPOPATH)/pkg/apis/backup/... \
$(REPOPATH)/pkg/apis/deployment/... \
$(REPOPATH)/pkg/apis/replication/... \
$(REPOPATH)/pkg/apis/storage/... \
$(REPOPATH)/pkg/apis/ml/... \
$(REPOPATH)/pkg/deployment/... \
$(REPOPATH)/pkg/storage/... \
$(REPOPATH)/pkg/crd/... \
$(REPOPATH)/pkg/util/... \
$(REPOPATH)/pkg/generated/metric_descriptions/... \
$(REPOPATH)/pkg/... \
$(REPOPATH)/cmd/... \
$(REPOPATH)/pkg/handlers/...
$(REPOPATH)/integrations/...

# Release building

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Flags:
--kubernetes.max-batch-size int Size of batch during objects read (default 256)
--kubernetes.qps float32 Number of queries per second for k8s API (default 15)
--log.format string Set log format. Allowed values: 'pretty', 'JSON'. If empty, default format is used (default "pretty")
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, http, inspector, integrations, k8s-client, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, server, server-authentication (default [info])
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, http, inspector, integration-config-v1, integrations, k8s-client, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, server, server-authentication (default [info])
--log.sampling If true, operator will try to minimize duplication of logging events (default true)
--memory-limit uint Define memory limit for hard shutdown and the dump of goroutines. Used for testing
--metrics.excluded-prefixes stringArray List of the excluded metrics prefixes
Expand Down
9 changes: 5 additions & 4 deletions integrations/authentication/v1/implementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ func Test_Basic(t *testing.T) {
ctx, c := context.WithCancel(context.Background())
defer c()

s, err := newInternal(ctx, Configuration{
Path: directory,
TTL: time.Duration(0),
})
s, err := newInternal(ctx, NewConfiguration().With(func(c Configuration) Configuration {
c.Path = directory
c.TTL = 0
return c
}))
require.NoError(t, err)

// Create token
Expand Down
40 changes: 40 additions & 0 deletions integrations/config/v1/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

type Config struct {
Modules ModuleDefinitions `json:"modules,omitempty"`
}

func (c *Config) Init() {
for k := range c.Modules {
m := c.Modules[k]
m.Name = k
c.Modules[k] = m
}
}

type ModuleDefinitions map[string]ModuleDefinition

type ModuleDefinition struct {
Name string `json:"-"`
Path string `json:"path"`
}
80 changes: 80 additions & 0 deletions integrations/config/v1/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

import (
"fmt"
"os"
"testing"

"github.com/stretchr/testify/require"
)

func Test_ConfigCreation(t *testing.T) {
create := func(config Config) error {
_, err := New(config)
return err
}

dir := t.TempDir()

require.NoError(t, os.WriteFile(fmt.Sprintf("%s/file", dir), []byte{}, 0644))

require.EqualError(t, create(Config{}), "Requires at least 1 module")

require.EqualError(t, create(Config{
Modules: map[string]ModuleDefinition{
"test": {},
},
}), "Path for module `test` cannot be empty")

require.EqualError(t, create(Config{
Modules: map[string]ModuleDefinition{
"test": {
Path: "some/relative/path",
},
},
}), "Path `some/relative/path` for module `test` needs to be absolute")

require.EqualError(t, create(Config{
Modules: map[string]ModuleDefinition{
"test": {
Path: fmt.Sprintf("%s/non-existent", dir),
},
},
}), fmt.Sprintf("Path `%s/non-existent` for module `test` does not exists", dir))

require.EqualError(t, create(Config{
Modules: map[string]ModuleDefinition{
"test": {
Path: fmt.Sprintf("%s/file", dir),
},
},
}), fmt.Sprintf("Path `%s/file` for module `test` is not a directory", dir))

require.NoError(t, create(Config{
Modules: map[string]ModuleDefinition{
"test": {
Path: dir,
},
},
}))
}
25 changes: 25 additions & 0 deletions integrations/config/v1/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

const (
Name = "config.v1"
)
Loading

0 comments on commit c6212ad

Please sign in to comment.