Skip to content

Commit a3ee668

Browse files
authored
[Feature] Authentication Service V1 (#1592)
1 parent 6b68e58 commit a3ee668

33 files changed

+2427
-103
lines changed

.golangci.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ linters-settings:
5353
alias: pbShutdownV1
5454
- pkg: github.com/arangodb/kube-arangodb/integrations/shutdown/v1
5555
alias: pbImplShutdownV1
56+
- pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1/definition
57+
alias: pbAuthenticationV1
58+
- pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1
59+
alias: pbImplAuthenticationV1
5660
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1/definition
5761
alias: pbSharedV1
5862
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1

Makefile

+35-26
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,40 @@ endif
223223

224224
BINNAME := $(PROJECT)
225225
BIN := $(BINDIR)/$(BINNAME)
226-
VBIN_LINUX_AMD64 := $(BINDIR)/$(RELEASE_MODE)/linux/amd64/$(BINNAME)
227-
VBIN_LINUX_ARM64 := $(BINDIR)/$(RELEASE_MODE)/linux/arm64/$(BINNAME)
228226

229227
BIN_OPS_NAME := $(PROJECT)_ops
230228
BIN_OPS := $(BINDIR)/$(BIN_OPS_NAME)
231-
VBIN_OPS_LINUX_AMD64 := $(BINDIR)/$(RELEASE_MODE)/linux/amd64/$(BIN_OPS_NAME)
232-
VBIN_OPS_LINUX_ARM64 := $(BINDIR)/$(RELEASE_MODE)/linux/arm64/$(BIN_OPS_NAME)
233229

234-
VBIN_OPS_DARWIN_AMD64 := $(BINDIR)/$(RELEASE_MODE)/darwin/amd64/$(BIN_OPS_NAME)
235-
VBIN_OPS_DARWIN_ARM64 := $(BINDIR)/$(RELEASE_MODE)/darwin/arm64/$(BIN_OPS_NAME)
230+
BIN_INT_NAME := $(PROJECT)_integration
231+
BIN_INT := $(BINDIR)/$(BIN_INT_NAME)
232+
233+
define binary
234+
$(eval _OS:=$(call UPPER_ENV,$1))
235+
$(eval _ARCH:=$(call UPPER_ENV,$2))
236+
VBIN_$(_OS)_$(_ARCH) := $(BINDIR)/$(RELEASE_MODE)/$1/$2/$(BINNAME)
237+
VBIN_OPS_$(_OS)_$(_ARCH) := $(BINDIR)/$(RELEASE_MODE)/$1/$2/$(BIN_OPS_NAME)
238+
VBIN_INT_$(_OS)_$(_ARCH) := $(BINDIR)/$(RELEASE_MODE)/$1/$2/$(BIN_INT_NAME)
239+
240+
$$(VBIN_$(_OS)_$(_ARCH)): $$(SOURCES) dashboard/assets.go VERSION
241+
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/$1/$2
242+
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build $${GOBUILDARGS} --tags "$$(GOBUILDTAGS)" $$(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$$(GOBUILDGCFLAGS)" -ldflags "$$(GOBUILDLDFLAGS)" -o $$@ ./cmd/main
243+
244+
$$(VBIN_OPS_$(_OS)_$(_ARCH)): $$(SOURCES) dashboard/assets.go VERSION
245+
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/$1/$2
246+
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build $${GOBUILDARGS} --tags "$$(GOBUILDTAGS)" $$(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$$(GOBUILDGCFLAGS)" -ldflags "$$(GOBUILDLDFLAGS)" -o $$@ ./cmd/main-ops
247+
248+
$$(VBIN_INT_$(_OS)_$(_ARCH)): $$(SOURCES) dashboard/assets.go VERSION
249+
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/$1/$2
250+
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build $${GOBUILDARGS} --tags "$$(GOBUILDTAGS)" $$(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$$(GOBUILDGCFLAGS)" -ldflags "$$(GOBUILDLDFLAGS)" -o $$@ ./cmd/main-int
251+
252+
bin-all: $$(VBIN_$(_OS)_$(_ARCH)) $$(VBIN_OPS_$(_OS)_$(_ARCH)) $$(VBIN_INT_$(_OS)_$(_ARCH))
253+
254+
endef
255+
256+
$(eval $(call binary,linux,amd64))
257+
$(eval $(call binary,linux,arm64))
258+
$(eval $(call binary,darwin,amd64))
259+
$(eval $(call binary,darwin,arm64))
236260

237261
ifdef VERBOSE
238262
TESTVERBOSEOPTIONS := -v
@@ -421,27 +445,12 @@ dashboard/assets.go:
421445
$(DASHBOARDBUILDIMAGE)
422446
$(GOASSETSBUILDER) -s /dashboard/build/ -o dashboard/assets.go -p dashboard dashboard/build
423447

424-
.PHONY: bin bin-all
425-
bin: $(BIN)
426-
bin-all: $(BIN) $(VBIN_LINUX_AMD64) $(VBIN_LINUX_ARM64)
427-
428-
$(VBIN_LINUX_AMD64): $(SOURCES) dashboard/assets.go VERSION
429-
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/amd64
430-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_LINUX_AMD64) ./cmd/main
431-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_OPS_LINUX_AMD64) ./cmd/main-ops
432-
433-
$(VBIN_LINUX_ARM64): $(SOURCES) dashboard/assets.go VERSION
434-
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/arm64
435-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_LINUX_ARM64) ./cmd/main
436-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_OPS_LINUX_ARM64) ./cmd/main-ops
448+
# Binaries
437449

438-
bin-ops-all: $(VBIN_LINUX_AMD64) $(VBIN_LINUX_ARM64)
439-
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/darwin/amd64
440-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_OPS_DARWIN_AMD64) ./cmd/main-ops
441-
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/darwin/arm64
442-
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -gcflags=all="$(GOBUILDGCFLAGS)" -ldflags "$(GOBUILDLDFLAGS)" -o $(VBIN_OPS_DARWIN_ARM64) ./cmd/main-ops
450+
.PHONY: bin
451+
bin: $(BIN)
443452

444-
$(BIN): $(VBIN_LINUX_AMD64)
453+
$(BIN): $(VBIN_LINUX_AMD64) $(VBIN_OPS_LINUX_AMD64) $(VBIN_INT_LINUX_AMD64)
445454
@cp "$(VBIN_LINUX_AMD64)" "$(BIN)"
446455
@cp "$(VBIN_OPS_LINUX_AMD64)" "$(BIN_OPS)"
447456

@@ -817,7 +826,7 @@ check-community:
817826
@$(MAKE) _check RELEASE_MODE=community
818827

819828
_check: sync-crds
820-
@$(MAKE) fmt yamlfmt license-verify linter run-unit-tests bin vulncheck-optional
829+
@$(MAKE) fmt yamlfmt license-verify linter run-unit-tests bin-all vulncheck-optional
821830

822831
generate: generate-internal generate-proto fmt yamlfmt
823832

cmd/cmd.go

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func init() {
184184
var deprecatedStr string
185185

186186
f := cmdMain.Flags()
187+
187188
f.StringVar(&serverOptions.host, "server.host", defaultServerHost, "Host to listen on")
188189
f.IntVar(&serverOptions.port, "server.port", defaultServerPort, "Port to listen on")
189190
f.StringVar(&serverOptions.tlsSecretName, "server.tls-secret-name", "", "Name of secret containing tls.crt & tls.key for HTTPS server (if empty, self-signed certificate is used)")

cmd/integration.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020

2121
package cmd
2222

23-
import "github.com/arangodb/kube-arangodb/cmd/integrations"
23+
import (
24+
"github.com/spf13/cobra"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/integrations"
27+
)
2428

2529
func init() {
26-
if err := integrations.Register(&cmdMain); err != nil {
30+
subCommand := &cobra.Command{
31+
Use: "integration",
32+
}
33+
34+
if err := integrations.Register(subCommand); err != nil {
2735
panic(err.Error())
2836
}
37+
38+
cmdMain.AddCommand(subCommand)
2939
}

cmd/main-int/main_int.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package main
22+
23+
import (
24+
goflag "flag"
25+
"os"
26+
27+
"github.com/spf13/cobra"
28+
flag "github.com/spf13/pflag"
29+
30+
"github.com/arangodb/kube-arangodb/pkg/integrations"
31+
)
32+
33+
var (
34+
cmd = cobra.Command{
35+
Use: "arangodb_int",
36+
RunE: func(cmd *cobra.Command, args []string) error {
37+
return cmd.Usage()
38+
},
39+
}
40+
)
41+
42+
func init() {
43+
if err := integrations.Register(&cmd); err != nil {
44+
panic(err.Error())
45+
}
46+
}
47+
48+
func Execute() int {
49+
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
50+
51+
if err := cmd.Execute(); err != nil {
52+
return 1
53+
}
54+
55+
return 0
56+
}
57+
58+
func main() {
59+
os.Exit(Execute())
60+
}

go.mod

+13-13
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ require (
3636
github.com/fsnotify/fsnotify v1.7.0
3737
github.com/gin-gonic/gin v1.9.1
3838
github.com/golang-jwt/jwt v3.2.2+incompatible
39-
github.com/google/uuid v1.3.1
39+
github.com/google/uuid v1.4.0
4040
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
4141
github.com/josephburnett/jd v1.6.1
4242
github.com/julienschmidt/httprouter v1.3.0
43-
github.com/magiconair/properties v1.8.5
43+
github.com/magiconair/properties v1.8.7
4444
github.com/pkg/errors v0.9.1
4545
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.44.1
4646
github.com/prometheus-operator/prometheus-operator/pkg/client v0.0.0-00010101000000-000000000000
@@ -49,13 +49,13 @@ require (
4949
github.com/prometheus/prom2json v1.3.3
5050
github.com/robfig/cron v1.2.0
5151
github.com/rs/zerolog v1.19.0
52-
github.com/spf13/cobra v1.7.0
52+
github.com/spf13/cobra v1.8.0
5353
github.com/spf13/pflag v1.0.5
5454
github.com/stretchr/testify v1.8.4
55-
golang.org/x/sync v0.4.0
55+
golang.org/x/sync v0.6.0
5656
golang.org/x/sys v0.16.0
5757
golang.org/x/text v0.14.0
58-
golang.org/x/time v0.3.0
58+
golang.org/x/time v0.5.0
5959
google.golang.org/grpc v1.60.1
6060
google.golang.org/protobuf v1.32.0
6161
gopkg.in/yaml.v3 v3.0.1
@@ -74,7 +74,7 @@ require (
7474
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
7575
github.com/cespare/xxhash/v2 v2.2.0 // indirect
7676
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
77-
github.com/davecgh/go-spew v1.1.1 // indirect
77+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
7878
github.com/dchest/siphash v1.2.2 // indirect
7979
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
8080
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
@@ -109,19 +109,19 @@ require (
109109
github.com/modern-go/reflect2 v1.0.2 // indirect
110110
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
111111
github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible // indirect
112-
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
113-
github.com/pmezard/go-difflib v1.0.0 // indirect
112+
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
113+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
114114
github.com/prometheus/common v0.44.0 // indirect
115115
github.com/prometheus/procfs v0.10.1 // indirect
116116
github.com/stretchr/objx v0.4.0 // indirect
117117
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
118118
github.com/ugorji/go/codec v1.2.11 // indirect
119119
golang.org/x/arch v0.3.0 // indirect
120-
golang.org/x/crypto v0.17.0 // indirect
121-
golang.org/x/net v0.19.0 // indirect
122-
golang.org/x/oauth2 v0.13.0 // indirect
123-
golang.org/x/term v0.15.0 // indirect
124-
golang.org/x/tools v0.12.0 // indirect
120+
golang.org/x/crypto v0.18.0 // indirect
121+
golang.org/x/net v0.20.0 // indirect
122+
golang.org/x/oauth2 v0.15.0 // indirect
123+
golang.org/x/term v0.16.0 // indirect
124+
golang.org/x/tools v0.17.0 // indirect
125125
google.golang.org/appengine v1.6.8 // indirect
126126
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
127127
gopkg.in/inf.v0 v0.9.1 // indirect

0 commit comments

Comments
 (0)