diff --git a/.golangci.yaml b/.golangci.yaml index 72cec9f65..ad831fe5f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -57,6 +57,10 @@ linters-settings: alias: pbAuthenticationV1 - pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1 alias: pbImplAuthenticationV1 + - pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition + alias: pbAuthorizationV0 + - pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0 + alias: pbImplAuthorizationV0 - pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1/definition alias: pbSharedV1 - pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1 diff --git a/.protolint.yaml b/.protolint.yaml new file mode 100644 index 000000000..55515e364 --- /dev/null +++ b/.protolint.yaml @@ -0,0 +1,6 @@ +lint: + rules: + all_default: true + rules_option: + max_line_length: + max_chars: 128 diff --git a/CHANGELOG.md b/CHANGELOG.md index bbac548f0..b3ecd386f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - (Feature) Extract GRPC Server - (Feature) Extract Integration Service - (Documentation) Move ML Extension example under "CRD overview" +- (Feature) Authentication Service V1 +- (Feature) Authorization Service V0 ## [1.2.37](https://github.com/arangodb/kube-arangodb/tree/1.2.37) (2024-01-22) - (Documentation) Improve documentation rendering for GitHub Pages diff --git a/Makefile b/Makefile index 700768b8b..95bf8f510 100644 --- a/Makefile +++ b/Makefile @@ -347,6 +347,14 @@ linter: linter-fix: @$(GOPATH)/bin/golangci-lint run --fix --build-tags "$(GOBUILDTAGS)" $(foreach LINT_EXCLUDE,$(LINT_EXCLUDES),--exclude '$(LINT_EXCLUDE)') ./... +.PHONY: protolint protolint-fix + +protolint: + @$(GOPATH)/bin/protolint lint $(PROTOSOURCES) + +protolint-fix: + @$(GOPATH)/bin/protolint lint --fix $(PROTOSOURCES) + .PHONY: vulncheck vulncheck-optional vulncheck: @echo ">> Checking for known vulnerabilities (required)" @@ -726,6 +734,8 @@ tools-min: update-vendor @GOBIN=$(GOPATH)/bin go install github.com/google/addlicense@6d92264d717064f28b32464f0f9693a5b4ef0239 @echo ">> Fetching yamlfmt" @GOBIN=$(GOPATH)/bin go install github.com/google/yamlfmt/cmd/yamlfmt@v0.10.0 + @echo ">> Fetching protolinter" + @GOBIN=$(GOPATH)/bin go install github.com/yoheimuta/protolint/cmd/protolint@v0.47.5 .PHONY: tools tools: tools-min diff --git a/integrations/authentication/v1/definition/consts.go b/integrations/authentication/v1/definition/consts.go new file mode 100644 index 000000000..616792668 --- /dev/null +++ b/integrations/authentication/v1/definition/consts.go @@ -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 definition + +const ( + Name = "authentication.v1" +) diff --git a/integrations/authentication/v1/definition/definition.pb.go b/integrations/authentication/v1/definition/definition.pb.go index 3ecd6a9f9..9323b29f8 100644 --- a/integrations/authentication/v1/definition/definition.pb.go +++ b/integrations/authentication/v1/definition/definition.pb.go @@ -47,8 +47,8 @@ type ValidateRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Token specifies a token extracted from the request or used currently - Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"` + // token specifies a token extracted from the request or used currently + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` } func (x *ValidateRequest) Reset() { @@ -96,12 +96,12 @@ type ValidateResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // IsValid returns information about the validity of the token - IsValid bool `protobuf:"varint,1,opt,name=IsValid,proto3" json:"IsValid,omitempty"` - // Message message for the validation phase - Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"` - // Details returns token details if the token is valid - Details *ValidateResponseDetails `protobuf:"bytes,3,opt,name=Details,proto3,oneof" json:"Details,omitempty"` + // is_valid returns information about the validity of the token + IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"` + // message message for the validation phase + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + // details returns token details if the token is valid + Details *ValidateResponseDetails `protobuf:"bytes,3,opt,name=details,proto3,oneof" json:"details,omitempty"` } func (x *ValidateResponse) Reset() { @@ -164,10 +164,10 @@ type ValidateResponseDetails struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Lifetime specify the lifetime of the token - Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=Lifetime,proto3" json:"Lifetime,omitempty"` - // User returns the User used in the Token. If a user is not specified, `root` is returned - User string `protobuf:"bytes,2,opt,name=User,proto3" json:"User,omitempty"` + // lifetime specify the lifetime of the token + Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=lifetime,proto3" json:"lifetime,omitempty"` + // user returns the User used in the Token. If a user is not specified, `root` is returned + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` } func (x *ValidateResponseDetails) Reset() { @@ -222,10 +222,10 @@ type CreateTokenRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Lifetime specifies the lifetime of the token as duration. Defaults to 1 hour - Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=Lifetime,proto3,oneof" json:"Lifetime,omitempty"` - // User specify the User for which token should be created. By default, the default user is used (root in most cases) - User *string `protobuf:"bytes,2,opt,name=User,proto3,oneof" json:"User,omitempty"` + // lifetime specifies the lifetime of the token as duration. Defaults to 1 hour + Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=lifetime,proto3,oneof" json:"lifetime,omitempty"` + // user specify the User for which token should be created. By default, the default user is used (root in most cases) + User *string `protobuf:"bytes,2,opt,name=user,proto3,oneof" json:"user,omitempty"` } func (x *CreateTokenRequest) Reset() { @@ -280,12 +280,12 @@ type CreateTokenResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Lifetime specify the lifetime of the token as the duration - Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=Lifetime,proto3" json:"Lifetime,omitempty"` - // User returns the User used in the Token - User string `protobuf:"bytes,2,opt,name=User,proto3" json:"User,omitempty"` - // Token returns the Token as a string - Token string `protobuf:"bytes,3,opt,name=Token,proto3" json:"Token,omitempty"` + // lifetime specify the lifetime of the token as the duration + Lifetime *durationpb.Duration `protobuf:"bytes,1,opt,name=lifetime,proto3" json:"lifetime,omitempty"` + // user returns the User used in the Token + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + // token returns the Token as a string + Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` } func (x *CreateTokenResponse) Reset() { @@ -352,55 +352,56 @@ var file_integrations_authentication_v1_definition_definition_proto_rawDesc = [] 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9a, 0x01, 0x0a, 0x10, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x73, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49, 0x73, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x46, - 0x0a, 0x07, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x27, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x48, 0x00, 0x52, 0x07, 0x44, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x73, 0x22, 0x64, 0x0a, 0x17, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x35, 0x0a, - 0x08, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x4c, 0x69, 0x66, 0x65, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, 0x22, 0x7f, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3a, - 0x0a, 0x08, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, + 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x46, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x27, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x48, 0x00, 0x52, 0x07, 0x64, 0x65, 0x74, + 0x61, 0x69, 0x6c, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x64, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x73, 0x22, 0x64, 0x0a, 0x17, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x35, + 0x0a, 0x08, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x08, 0x4c, - 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x55, 0x73, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, - 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, - 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x22, 0x76, 0x0a, 0x13, 0x43, 0x72, 0x65, + 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x69, 0x66, + 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x7f, 0x0a, 0x12, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x3a, 0x0a, 0x08, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x08, + 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x75, + 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x75, 0x73, 0x65, + 0x72, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, + 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x22, 0x76, 0x0a, 0x13, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x35, 0x0a, 0x08, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, + 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x32, 0xbd, 0x01, 0x0a, 0x10, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x12, 0x4f, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x1f, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x22, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, + 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x61, 0x75, + 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x35, 0x0a, 0x08, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x4c, - 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x32, 0xbd, 0x01, 0x0a, 0x10, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x12, 0x4f, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x12, 0x1f, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x22, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x61, 0x75, 0x74, - 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, - 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, + 0x22, 0x00, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, + 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -426,10 +427,10 @@ var file_integrations_authentication_v1_definition_definition_proto_goTypes = [] (*durationpb.Duration)(nil), // 5: google.protobuf.Duration } var file_integrations_authentication_v1_definition_definition_proto_depIdxs = []int32{ - 2, // 0: authentication.ValidateResponse.Details:type_name -> authentication.ValidateResponseDetails - 5, // 1: authentication.ValidateResponseDetails.Lifetime:type_name -> google.protobuf.Duration - 5, // 2: authentication.CreateTokenRequest.Lifetime:type_name -> google.protobuf.Duration - 5, // 3: authentication.CreateTokenResponse.Lifetime:type_name -> google.protobuf.Duration + 2, // 0: authentication.ValidateResponse.details:type_name -> authentication.ValidateResponseDetails + 5, // 1: authentication.ValidateResponseDetails.lifetime:type_name -> google.protobuf.Duration + 5, // 2: authentication.CreateTokenRequest.lifetime:type_name -> google.protobuf.Duration + 5, // 3: authentication.CreateTokenResponse.lifetime:type_name -> google.protobuf.Duration 0, // 4: authentication.AuthenticationV1.Validate:input_type -> authentication.ValidateRequest 3, // 5: authentication.AuthenticationV1.CreateToken:input_type -> authentication.CreateTokenRequest 1, // 6: authentication.AuthenticationV1.Validate:output_type -> authentication.ValidateResponse diff --git a/integrations/authentication/v1/definition/definition.proto b/integrations/authentication/v1/definition/definition.proto index e68688de2..478c86fe7 100644 --- a/integrations/authentication/v1/definition/definition.proto +++ b/integrations/authentication/v1/definition/definition.proto @@ -20,11 +20,11 @@ syntax = "proto3"; +package authentication; + import "google/protobuf/duration.proto"; -option go_package = "github.com/arangodb/kube-arangodb/integrations/v1/definition"; - -package authentication; +option go_package = "github.com/arangodb/kube-arangodb/integrations/authentication/v1/definition"; // AuthenticationV1 define ServiceInterface for Authentication V1 service AuthenticationV1 { @@ -37,49 +37,49 @@ service AuthenticationV1 { // ValidateRequest defines request for AuthenticationV1 Validate Request message ValidateRequest { - // Token specifies a token extracted from the request or used currently - string Token = 1; + // token specifies a token extracted from the request or used currently + string token = 1; } // ValidateResponse defines response for AuthenticationV1 Validate Request message ValidateResponse { - // IsValid returns information about the validity of the token - bool IsValid = 1; + // is_valid returns information about the validity of the token + bool is_valid = 1; - // Message message for the validation phase - string Message = 2; + // message message for the validation phase + string message = 2; - // Details returns token details if the token is valid - optional ValidateResponseDetails Details = 3; + // details returns token details if the token is valid + optional ValidateResponseDetails details = 3; } // ValidateResponseDetails defines optional response for AuthenticationV1 Validate Request. // Returned only if the Token provided in the request is valid. message ValidateResponseDetails { - // Lifetime specify the lifetime of the token - google.protobuf.Duration Lifetime = 1; + // lifetime specify the lifetime of the token + google.protobuf.Duration lifetime = 1; - // User returns the User used in the Token. If a user is not specified, `root` is returned - string User = 2; + // user returns the User used in the Token. If a user is not specified, `root` is returned + string user = 2; } // CreateTokenRequest defines request for AuthenticationV1 CreateToken Request message CreateTokenRequest { - // Lifetime specifies the lifetime of the token as duration. Defaults to 1 hour - optional google.protobuf.Duration Lifetime = 1; + // lifetime specifies the lifetime of the token as duration. Defaults to 1 hour + optional google.protobuf.Duration lifetime = 1; - // User specify the User for which token should be created. By default, the default user is used (root in most cases) - optional string User = 2; + // user specify the User for which token should be created. By default, the default user is used (root in most cases) + optional string user = 2; } // CreateTokenResponse defines response for AuthenticationV1 CreateToken Request message CreateTokenResponse { - // Lifetime specify the lifetime of the token as the duration - google.protobuf.Duration Lifetime = 1; + // lifetime specify the lifetime of the token as the duration + google.protobuf.Duration lifetime = 1; - // User returns the User used in the Token - string User = 2; + // user returns the User used in the Token + string user = 2; - // Token returns the Token as a string - string Token = 3; -} \ No newline at end of file + // token returns the Token as a string + string token = 3; +} diff --git a/integrations/authentication/v1/implementation.go b/integrations/authentication/v1/implementation.go index 7ffa71a99..856c153fc 100644 --- a/integrations/authentication/v1/implementation.go +++ b/integrations/authentication/v1/implementation.go @@ -68,7 +68,7 @@ type implementation struct { } func (i *implementation) Name() string { - return "authentication.v1" + return pbAuthenticationV1.Name } func (i *implementation) Health() svc.HealthState { diff --git a/integrations/authorization/v0/definition/consts.go b/integrations/authorization/v0/definition/consts.go new file mode 100644 index 000000000..875b03527 --- /dev/null +++ b/integrations/authorization/v0/definition/consts.go @@ -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 definition + +const ( + Name = "authorization.v0" +) diff --git a/integrations/authorization/v0/definition/definition.pb.go b/integrations/authorization/v0/definition/definition.pb.go new file mode 100644 index 000000000..0d562bb8b --- /dev/null +++ b/integrations/authorization/v0/definition/definition.pb.go @@ -0,0 +1,371 @@ +// +// 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 +// + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.21.1 +// source: integrations/authorization/v0/definition/definition.proto + +package definition + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Action define action used for Authorization +type Action int32 + +const ( + // ACTION_ANY_UNSPECIFIED is used when there is no Action defined for call + Action_ACTION_ANY_UNSPECIFIED Action = 0 + // ACTION_LIST define Action List + Action_ACTION_LIST Action = 1 + // ACTION_GET define Action Get + Action_ACTION_GET Action = 2 + // ACTION_CREATE define Action Create + Action_ACTION_CREATE Action = 3 + // ACTION_DELETE define Action Delete + Action_ACTION_DELETE Action = 4 +) + +// Enum value maps for Action. +var ( + Action_name = map[int32]string{ + 0: "ACTION_ANY_UNSPECIFIED", + 1: "ACTION_LIST", + 2: "ACTION_GET", + 3: "ACTION_CREATE", + 4: "ACTION_DELETE", + } + Action_value = map[string]int32{ + "ACTION_ANY_UNSPECIFIED": 0, + "ACTION_LIST": 1, + "ACTION_GET": 2, + "ACTION_CREATE": 3, + "ACTION_DELETE": 4, + } +) + +func (x Action) Enum() *Action { + p := new(Action) + *p = x + return p +} + +func (x Action) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Action) Descriptor() protoreflect.EnumDescriptor { + return file_integrations_authorization_v0_definition_definition_proto_enumTypes[0].Descriptor() +} + +func (Action) Type() protoreflect.EnumType { + return &file_integrations_authorization_v0_definition_definition_proto_enumTypes[0] +} + +func (x Action) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Action.Descriptor instead. +func (Action) EnumDescriptor() ([]byte, []int) { + return file_integrations_authorization_v0_definition_definition_proto_rawDescGZIP(), []int{0} +} + +// CanRequest define Can method Request Body +type CanRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // user define the Requester User + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // action define the Action type + Action Action `protobuf:"varint,2,opt,name=action,proto3,enum=authorization.Action" json:"action,omitempty"` + // api Keeps the information about API, For example training, prediction + Api string `protobuf:"bytes,3,opt,name=api,proto3" json:"api,omitempty"` + // version keeps the information about used API Version, optional + Version *string `protobuf:"bytes,4,opt,name=version,proto3,oneof" json:"version,omitempty"` + // name keeps the information about Resource name, used in Get/Create/Delete requests + Name *string `protobuf:"bytes,5,opt,name=name,proto3,oneof" json:"name,omitempty"` +} + +func (x *CanRequest) Reset() { + *x = CanRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_integrations_authorization_v0_definition_definition_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CanRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CanRequest) ProtoMessage() {} + +func (x *CanRequest) ProtoReflect() protoreflect.Message { + mi := &file_integrations_authorization_v0_definition_definition_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CanRequest.ProtoReflect.Descriptor instead. +func (*CanRequest) Descriptor() ([]byte, []int) { + return file_integrations_authorization_v0_definition_definition_proto_rawDescGZIP(), []int{0} +} + +func (x *CanRequest) GetUser() string { + if x != nil { + return x.User + } + return "" +} + +func (x *CanRequest) GetAction() Action { + if x != nil { + return x.Action + } + return Action_ACTION_ANY_UNSPECIFIED +} + +func (x *CanRequest) GetApi() string { + if x != nil { + return x.Api + } + return "" +} + +func (x *CanRequest) GetVersion() string { + if x != nil && x.Version != nil { + return *x.Version + } + return "" +} + +func (x *CanRequest) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +// CanResponse define Can method Response Body +type CanResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // allowed keeps the information if request is allowed + Allowed bool `protobuf:"varint,1,opt,name=allowed,proto3" json:"allowed,omitempty"` + // message keeps the information about allow/deny + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *CanResponse) Reset() { + *x = CanResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_integrations_authorization_v0_definition_definition_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CanResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CanResponse) ProtoMessage() {} + +func (x *CanResponse) ProtoReflect() protoreflect.Message { + mi := &file_integrations_authorization_v0_definition_definition_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CanResponse.ProtoReflect.Descriptor instead. +func (*CanResponse) Descriptor() ([]byte, []int) { + return file_integrations_authorization_v0_definition_definition_proto_rawDescGZIP(), []int{1} +} + +func (x *CanResponse) GetAllowed() bool { + if x != nil { + return x.Allowed + } + return false +} + +func (x *CanResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_integrations_authorization_v0_definition_definition_proto protoreflect.FileDescriptor + +var file_integrations_authorization_v0_definition_definition_proto_rawDesc = []byte{ + 0x0a, 0x39, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x30, 0x2f, + 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xae, 0x01, 0x0a, 0x0a, 0x43, + 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x2d, 0x0a, + 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, + 0x61, 0x70, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x70, 0x69, 0x12, 0x1d, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x41, 0x0a, 0x0b, 0x43, + 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x6c, 0x6c, + 0x6f, 0x77, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x6b, + 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x16, 0x41, 0x43, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x41, 0x4e, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, + 0x49, 0x53, 0x54, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x47, 0x45, 0x54, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x43, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x04, 0x32, 0x51, 0x0a, 0x0f, 0x41, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x30, 0x12, 0x3e, + 0x0a, 0x03, 0x43, 0x61, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x43, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4c, + 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x61, + 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61, 0x6e, 0x67, + 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, + 0x30, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_integrations_authorization_v0_definition_definition_proto_rawDescOnce sync.Once + file_integrations_authorization_v0_definition_definition_proto_rawDescData = file_integrations_authorization_v0_definition_definition_proto_rawDesc +) + +func file_integrations_authorization_v0_definition_definition_proto_rawDescGZIP() []byte { + file_integrations_authorization_v0_definition_definition_proto_rawDescOnce.Do(func() { + file_integrations_authorization_v0_definition_definition_proto_rawDescData = protoimpl.X.CompressGZIP(file_integrations_authorization_v0_definition_definition_proto_rawDescData) + }) + return file_integrations_authorization_v0_definition_definition_proto_rawDescData +} + +var file_integrations_authorization_v0_definition_definition_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_integrations_authorization_v0_definition_definition_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_integrations_authorization_v0_definition_definition_proto_goTypes = []interface{}{ + (Action)(0), // 0: authorization.Action + (*CanRequest)(nil), // 1: authorization.CanRequest + (*CanResponse)(nil), // 2: authorization.CanResponse +} +var file_integrations_authorization_v0_definition_definition_proto_depIdxs = []int32{ + 0, // 0: authorization.CanRequest.action:type_name -> authorization.Action + 1, // 1: authorization.AuthorizationV0.Can:input_type -> authorization.CanRequest + 2, // 2: authorization.AuthorizationV0.Can:output_type -> authorization.CanResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_integrations_authorization_v0_definition_definition_proto_init() } +func file_integrations_authorization_v0_definition_definition_proto_init() { + if File_integrations_authorization_v0_definition_definition_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_integrations_authorization_v0_definition_definition_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CanRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_integrations_authorization_v0_definition_definition_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CanResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_integrations_authorization_v0_definition_definition_proto_msgTypes[0].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_integrations_authorization_v0_definition_definition_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_integrations_authorization_v0_definition_definition_proto_goTypes, + DependencyIndexes: file_integrations_authorization_v0_definition_definition_proto_depIdxs, + EnumInfos: file_integrations_authorization_v0_definition_definition_proto_enumTypes, + MessageInfos: file_integrations_authorization_v0_definition_definition_proto_msgTypes, + }.Build() + File_integrations_authorization_v0_definition_definition_proto = out.File + file_integrations_authorization_v0_definition_definition_proto_rawDesc = nil + file_integrations_authorization_v0_definition_definition_proto_goTypes = nil + file_integrations_authorization_v0_definition_definition_proto_depIdxs = nil +} diff --git a/integrations/authorization/v0/definition/definition.proto b/integrations/authorization/v0/definition/definition.proto new file mode 100644 index 000000000..22a8e5fc7 --- /dev/null +++ b/integrations/authorization/v0/definition/definition.proto @@ -0,0 +1,73 @@ +// +// 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 +// + +syntax = "proto3"; + +package authorization; + +option go_package = "github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition"; + +// AuthorizationV0 define AuthorizationV0 Interface +service AuthorizationV0 { + // Can validate if specified request is allowed + rpc Can (CanRequest) returns (CanResponse) {} +} + +// Action define action used for Authorization +enum Action { + // ACTION_ANY_UNSPECIFIED is used when there is no Action defined for call + ACTION_ANY_UNSPECIFIED = 0; + + // ACTION_LIST define Action List + ACTION_LIST = 1; + // ACTION_GET define Action Get + ACTION_GET = 2; + // ACTION_CREATE define Action Create + ACTION_CREATE = 3; + // ACTION_DELETE define Action Delete + ACTION_DELETE = 4; +} + +// CanRequest define Can method Request Body +message CanRequest { + // user define the Requester User + string user = 1; + + // action define the Action type + Action action = 2; + + // api Keeps the information about API, For example training, prediction + string api = 3; + + // version keeps the information about used API Version, optional + optional string version = 4; + + // name keeps the information about Resource name, used in Get/Create/Delete requests + optional string name = 5; +} + +// CanResponse define Can method Response Body +message CanResponse { + // allowed keeps the information if request is allowed + bool allowed = 1; + + // message keeps the information about allow/deny + string message = 2; +} diff --git a/integrations/authorization/v0/definition/definition_grpc.pb.go b/integrations/authorization/v0/definition/definition_grpc.pb.go new file mode 100644 index 000000000..a384c3dfd --- /dev/null +++ b/integrations/authorization/v0/definition/definition_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.1 +// source: integrations/authorization/v0/definition/definition.proto + +package definition + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// AuthorizationV0Client is the client API for AuthorizationV0 service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AuthorizationV0Client interface { + // Can validate if specified request is allowed + Can(ctx context.Context, in *CanRequest, opts ...grpc.CallOption) (*CanResponse, error) +} + +type authorizationV0Client struct { + cc grpc.ClientConnInterface +} + +func NewAuthorizationV0Client(cc grpc.ClientConnInterface) AuthorizationV0Client { + return &authorizationV0Client{cc} +} + +func (c *authorizationV0Client) Can(ctx context.Context, in *CanRequest, opts ...grpc.CallOption) (*CanResponse, error) { + out := new(CanResponse) + err := c.cc.Invoke(ctx, "/authorization.AuthorizationV0/Can", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AuthorizationV0Server is the server API for AuthorizationV0 service. +// All implementations must embed UnimplementedAuthorizationV0Server +// for forward compatibility +type AuthorizationV0Server interface { + // Can validate if specified request is allowed + Can(context.Context, *CanRequest) (*CanResponse, error) + mustEmbedUnimplementedAuthorizationV0Server() +} + +// UnimplementedAuthorizationV0Server must be embedded to have forward compatible implementations. +type UnimplementedAuthorizationV0Server struct { +} + +func (UnimplementedAuthorizationV0Server) Can(context.Context, *CanRequest) (*CanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Can not implemented") +} +func (UnimplementedAuthorizationV0Server) mustEmbedUnimplementedAuthorizationV0Server() {} + +// UnsafeAuthorizationV0Server may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AuthorizationV0Server will +// result in compilation errors. +type UnsafeAuthorizationV0Server interface { + mustEmbedUnimplementedAuthorizationV0Server() +} + +func RegisterAuthorizationV0Server(s grpc.ServiceRegistrar, srv AuthorizationV0Server) { + s.RegisterService(&AuthorizationV0_ServiceDesc, srv) +} + +func _AuthorizationV0_Can_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthorizationV0Server).Can(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/authorization.AuthorizationV0/Can", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthorizationV0Server).Can(ctx, req.(*CanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AuthorizationV0_ServiceDesc is the grpc.ServiceDesc for AuthorizationV0 service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AuthorizationV0_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "authorization.AuthorizationV0", + HandlerType: (*AuthorizationV0Server)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Can", + Handler: _AuthorizationV0_Can_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "integrations/authorization/v0/definition/definition.proto", +} diff --git a/integrations/authorization/v0/implementation.go b/integrations/authorization/v0/implementation.go new file mode 100644 index 000000000..fff5d31f5 --- /dev/null +++ b/integrations/authorization/v0/implementation.go @@ -0,0 +1,70 @@ +// +// 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 v0 + +import ( + "context" + "fmt" + + "google.golang.org/grpc" + + pbAuthorizationV0 "github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition" + "github.com/arangodb/kube-arangodb/pkg/util/errors" + "github.com/arangodb/kube-arangodb/pkg/util/svc" +) + +var _ pbAuthorizationV0.AuthorizationV0Server = &implementation{} +var _ svc.Handler = &implementation{} + +func New() svc.Handler { + return newInternal() +} + +func newInternal() *implementation { + return &implementation{} +} + +type implementation struct { + pbAuthorizationV0.UnimplementedAuthorizationV0Server +} + +func (i *implementation) Name() string { + return pbAuthorizationV0.Name +} + +func (i *implementation) Health() svc.HealthState { + return svc.Healthy +} + +func (i *implementation) Register(registrar *grpc.Server) { + pbAuthorizationV0.RegisterAuthorizationV0Server(registrar, i) +} + +func (i *implementation) Can(ctx context.Context, request *pbAuthorizationV0.CanRequest) (*pbAuthorizationV0.CanResponse, error) { + if request == nil { + return nil, errors.Errorf("Request is nil") + } + + return &pbAuthorizationV0.CanResponse{ + Allowed: true, + Message: fmt.Sprintf("Access by user `%s` to resource `%s/%s` has been granted", request.GetUser(), request.GetApi(), request.GetAction()), + }, nil +} diff --git a/integrations/authorization/v0/service_test.go b/integrations/authorization/v0/service_test.go new file mode 100644 index 000000000..43754c212 --- /dev/null +++ b/integrations/authorization/v0/service_test.go @@ -0,0 +1,55 @@ +// +// 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 v0 + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + pbAuthorizationV0 "github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition" + "github.com/arangodb/kube-arangodb/pkg/util/svc" + "github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc" +) + +func Client(t *testing.T, ctx context.Context) pbAuthorizationV0.AuthorizationV0Client { + local := svc.NewService(svc.Configuration{ + Address: "127.0.0.1:0", + }, New()) + + start := local.Start(ctx) + + client := tgrpc.NewGRPCClient(t, ctx, pbAuthorizationV0.NewAuthorizationV0Client, start.Address()) + + return client +} + +func Test_AllowAll(t *testing.T) { + ctx, c := context.WithCancel(context.Background()) + defer c() + + client := Client(t, ctx) + + resp, err := client.Can(ctx, &pbAuthorizationV0.CanRequest{}) + require.NoError(t, err) + require.True(t, resp.Allowed) +} diff --git a/integrations/shared/v1/definition/empty.pb.go b/integrations/shared/v1/definition/empty.pb.go index ef446f063..e2b096a4e 100644 --- a/integrations/shared/v1/definition/empty.pb.go +++ b/integrations/shared/v1/definition/empty.pb.go @@ -40,6 +40,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// Empty contains empty message used by other protos type Empty struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/integrations/shared/v1/definition/empty.proto b/integrations/shared/v1/definition/empty.proto index bc96917de..b4dc93a54 100644 --- a/integrations/shared/v1/definition/empty.proto +++ b/integrations/shared/v1/definition/empty.proto @@ -20,8 +20,10 @@ syntax = "proto3"; -option go_package = "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"; - package shared; -message Empty {} \ No newline at end of file +option go_package = "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"; + +// Empty contains empty message used by other protos +message Empty { +} diff --git a/integrations/shutdown/v1/definition/shutdown.pb.go b/integrations/shutdown/v1/definition/shutdown.pb.go index 78ea62668..665f6d7ef 100644 --- a/integrations/shutdown/v1/definition/shutdown.pb.go +++ b/integrations/shutdown/v1/definition/shutdown.pb.go @@ -49,24 +49,24 @@ var file_integrations_shutdown_v1_definition_shutdown_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x1a, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x3c, 0x0a, - 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x30, 0x0a, 0x0e, 0x53, 0x68, 0x75, - 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0d, 0x2e, 0x73, 0x68, - 0x61, 0x72, 0x65, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x68, 0x61, - 0x72, 0x65, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x47, 0x5a, 0x45, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, - 0x64, 0x62, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x68, - 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x38, 0x0a, + 0x0a, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x56, 0x31, 0x12, 0x2a, 0x0a, 0x08, 0x53, + 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x6b, + 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x68, 0x75, 0x74, 0x64, 0x6f, + 0x77, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_integrations_shutdown_v1_definition_shutdown_proto_goTypes = []interface{}{ (*definition.Empty)(nil), // 0: shared.Empty } var file_integrations_shutdown_v1_definition_shutdown_proto_depIdxs = []int32{ - 0, // 0: shutdown.Shutdown.ShutdownServer:input_type -> shared.Empty - 0, // 1: shutdown.Shutdown.ShutdownServer:output_type -> shared.Empty + 0, // 0: shutdown.ShutdownV1.Shutdown:input_type -> shared.Empty + 0, // 1: shutdown.ShutdownV1.Shutdown:output_type -> shared.Empty 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/integrations/shutdown/v1/definition/shutdown.proto b/integrations/shutdown/v1/definition/shutdown.proto index cea1954ec..f850cc986 100644 --- a/integrations/shutdown/v1/definition/shutdown.proto +++ b/integrations/shutdown/v1/definition/shutdown.proto @@ -20,12 +20,14 @@ syntax = "proto3"; -option go_package = "github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition"; - package shutdown; import "integrations/shared/v1/definition/empty.proto"; -service Shutdown { - rpc ShutdownServer (shared.Empty) returns (shared.Empty) {} -} \ No newline at end of file +option go_package = "github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition"; + +// ShutdownV1 Service implementation +service ShutdownV1 { + // ShutdownServer sends the shutdown request + rpc Shutdown (shared.Empty) returns (shared.Empty) {} +} diff --git a/integrations/shutdown/v1/definition/shutdown_grpc.pb.go b/integrations/shutdown/v1/definition/shutdown_grpc.pb.go index 2c339f029..343470da6 100644 --- a/integrations/shutdown/v1/definition/shutdown_grpc.pb.go +++ b/integrations/shutdown/v1/definition/shutdown_grpc.pb.go @@ -19,86 +19,88 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -// ShutdownClient is the client API for Shutdown service. +// ShutdownV1Client is the client API for ShutdownV1 service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ShutdownClient interface { - ShutdownServer(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*definition.Empty, error) +type ShutdownV1Client interface { + // ShutdownServer sends the shutdown request + Shutdown(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*definition.Empty, error) } -type shutdownClient struct { +type shutdownV1Client struct { cc grpc.ClientConnInterface } -func NewShutdownClient(cc grpc.ClientConnInterface) ShutdownClient { - return &shutdownClient{cc} +func NewShutdownV1Client(cc grpc.ClientConnInterface) ShutdownV1Client { + return &shutdownV1Client{cc} } -func (c *shutdownClient) ShutdownServer(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*definition.Empty, error) { +func (c *shutdownV1Client) Shutdown(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*definition.Empty, error) { out := new(definition.Empty) - err := c.cc.Invoke(ctx, "/shutdown.Shutdown/ShutdownServer", in, out, opts...) + err := c.cc.Invoke(ctx, "/shutdown.ShutdownV1/Shutdown", in, out, opts...) if err != nil { return nil, err } return out, nil } -// ShutdownServer is the server API for Shutdown service. -// All implementations must embed UnimplementedShutdownServer +// ShutdownV1Server is the server API for ShutdownV1 service. +// All implementations must embed UnimplementedShutdownV1Server // for forward compatibility -type ShutdownServer interface { - ShutdownServer(context.Context, *definition.Empty) (*definition.Empty, error) - mustEmbedUnimplementedShutdownServer() +type ShutdownV1Server interface { + // ShutdownServer sends the shutdown request + Shutdown(context.Context, *definition.Empty) (*definition.Empty, error) + mustEmbedUnimplementedShutdownV1Server() } -// UnimplementedShutdownServer must be embedded to have forward compatible implementations. -type UnimplementedShutdownServer struct { +// UnimplementedShutdownV1Server must be embedded to have forward compatible implementations. +type UnimplementedShutdownV1Server struct { } -func (UnimplementedShutdownServer) ShutdownServer(context.Context, *definition.Empty) (*definition.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method ShutdownServer not implemented") +func (UnimplementedShutdownV1Server) Shutdown(context.Context, *definition.Empty) (*definition.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") } -func (UnimplementedShutdownServer) mustEmbedUnimplementedShutdownServer() {} +func (UnimplementedShutdownV1Server) mustEmbedUnimplementedShutdownV1Server() {} -// UnsafeShutdownServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ShutdownServer will +// UnsafeShutdownV1Server may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ShutdownV1Server will // result in compilation errors. -type UnsafeShutdownServer interface { - mustEmbedUnimplementedShutdownServer() +type UnsafeShutdownV1Server interface { + mustEmbedUnimplementedShutdownV1Server() } -func RegisterShutdownServer(s grpc.ServiceRegistrar, srv ShutdownServer) { - s.RegisterService(&Shutdown_ServiceDesc, srv) +func RegisterShutdownV1Server(s grpc.ServiceRegistrar, srv ShutdownV1Server) { + s.RegisterService(&ShutdownV1_ServiceDesc, srv) } -func _Shutdown_ShutdownServer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _ShutdownV1_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(definition.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ShutdownServer).ShutdownServer(ctx, in) + return srv.(ShutdownV1Server).Shutdown(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/shutdown.Shutdown/ShutdownServer", + FullMethod: "/shutdown.ShutdownV1/Shutdown", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ShutdownServer).ShutdownServer(ctx, req.(*definition.Empty)) + return srv.(ShutdownV1Server).Shutdown(ctx, req.(*definition.Empty)) } return interceptor(ctx, in, info, handler) } -// Shutdown_ServiceDesc is the grpc.ServiceDesc for Shutdown service. +// ShutdownV1_ServiceDesc is the grpc.ServiceDesc for ShutdownV1 service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var Shutdown_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "shutdown.Shutdown", - HandlerType: (*ShutdownServer)(nil), +var ShutdownV1_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "shutdown.ShutdownV1", + HandlerType: (*ShutdownV1Server)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "ShutdownServer", - Handler: _Shutdown_ShutdownServer_Handler, + MethodName: "Shutdown", + Handler: _ShutdownV1_Shutdown_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/integrations/shutdown/v1/impl.go b/integrations/shutdown/v1/impl.go index 6e2f4f7ab..3e369e84e 100644 --- a/integrations/shutdown/v1/impl.go +++ b/integrations/shutdown/v1/impl.go @@ -35,11 +35,11 @@ func New(closer context.CancelFunc) svc.Handler { return &impl{closer: closer} } -var _ pbShutdownV1.ShutdownServer = &impl{} +var _ pbShutdownV1.ShutdownV1Server = &impl{} var _ svc.Handler = &impl{} type impl struct { - pbShutdownV1.UnimplementedShutdownServer + pbShutdownV1.UnimplementedShutdownV1Server closer context.CancelFunc } @@ -53,10 +53,10 @@ func (i *impl) Health() svc.HealthState { } func (i *impl) Register(registrar *grpc.Server) { - pbShutdownV1.RegisterShutdownServer(registrar, i) + pbShutdownV1.RegisterShutdownV1Server(registrar, i) } -func (i *impl) ShutdownServer(ctx context.Context, empty *pbSharedV1.Empty) (*pbSharedV1.Empty, error) { +func (i *impl) Shutdown(ctx context.Context, empty *pbSharedV1.Empty) (*pbSharedV1.Empty, error) { go func() { defer i.closer() diff --git a/integrations/shutdown/v1/impl_test.go b/integrations/shutdown/v1/impl_test.go index 0f859f41b..5060cd220 100644 --- a/integrations/shutdown/v1/impl_test.go +++ b/integrations/shutdown/v1/impl_test.go @@ -29,6 +29,7 @@ import ( pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition" pbShutdownV1 "github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition" + "github.com/arangodb/kube-arangodb/pkg/util/closer" "github.com/arangodb/kube-arangodb/pkg/util/svc" "github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc" ) @@ -43,25 +44,16 @@ func Test_ShutdownGRPC(t *testing.T) { start := local.Start(ctx) - require.False(t, isContextDone(ctx)) + require.False(t, closer.IsChannelClosed(ctx.Done())) - client := tgrpc.NewGRPCClient(t, ctx, pbShutdownV1.NewShutdownClient, start.Address()) + client := tgrpc.NewGRPCClient(t, ctx, pbShutdownV1.NewShutdownV1Client, start.Address()) - _, err := client.ShutdownServer(ctx, &pbSharedV1.Empty{}) + _, err := client.Shutdown(ctx, &pbSharedV1.Empty{}) require.NoError(t, err) time.Sleep(time.Second) - require.True(t, isContextDone(ctx)) + require.True(t, closer.IsChannelClosed(ctx.Done())) require.NoError(t, start.Wait()) } - -func isContextDone(ctx context.Context) bool { - select { - case <-ctx.Done(): - return true - default: - return false - } -} diff --git a/integrations/shutdown/v1/service_test.go b/integrations/shutdown/v1/service_test.go new file mode 100644 index 000000000..bd0b61050 --- /dev/null +++ b/integrations/shutdown/v1/service_test.go @@ -0,0 +1,66 @@ +// +// 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 ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + + pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition" + pbShutdownV1 "github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition" + "github.com/arangodb/kube-arangodb/pkg/util/closer" + "github.com/arangodb/kube-arangodb/pkg/util/svc" + "github.com/arangodb/kube-arangodb/pkg/util/tests/tgrpc" +) + +func Client(t *testing.T, ctx context.Context, c context.CancelFunc) pbShutdownV1.ShutdownV1Client { + local := svc.NewService(svc.Configuration{ + Address: "127.0.0.1:0", + }, New(c)) + + start := local.Start(ctx) + + client := tgrpc.NewGRPCClient(t, ctx, pbShutdownV1.NewShutdownV1Client, start.Address()) + + return client +} + +func Test_AllowAll(t *testing.T) { + ctx, c := context.WithCancel(context.Background()) + defer c() + + nctx, nc := context.WithCancel(ctx) + + client := Client(t, ctx, nc) + + require.False(t, closer.IsChannelClosed(nctx.Done())) + + _, err := client.Shutdown(ctx, &pbSharedV1.Empty{}) + require.NoError(t, err) + + time.Sleep(100 * time.Millisecond) + + require.True(t, closer.IsChannelClosed(nctx.Done())) + +} diff --git a/pkg/api/grpc.go b/pkg/api/grpc.go index b633e0746..bd19062df 100644 --- a/pkg/api/grpc.go +++ b/pkg/api/grpc.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-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. @@ -24,12 +24,13 @@ import ( "context" "fmt" + pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition" pb "github.com/arangodb/kube-arangodb/pkg/api/server" "github.com/arangodb/kube-arangodb/pkg/logging" "github.com/arangodb/kube-arangodb/pkg/version" ) -func (s *Server) GetVersion(ctx context.Context, _ *pb.Empty) (*pb.Version, error) { +func (s *Server) GetVersion(ctx context.Context, _ *pbSharedV1.Empty) (*pb.Version, error) { v := version.GetVersionV1() return &pb.Version{ Version: string(v.Version), @@ -41,12 +42,12 @@ func (s *Server) GetVersion(ctx context.Context, _ *pb.Empty) (*pb.Version, erro } var loglevelMap = map[pb.LogLevel]logging.Level{ - pb.LogLevel_TRACE: logging.Trace, - pb.LogLevel_DEBUG: logging.Debug, - pb.LogLevel_INFO: logging.Info, - pb.LogLevel_WARN: logging.Warn, - pb.LogLevel_ERROR: logging.Error, - pb.LogLevel_FATAL: logging.Fatal, + pb.LogLevel_LOG_LEVEL_TRACE_UNSPECIFIED: logging.Trace, + pb.LogLevel_LOG_LEVEL_DEBUG: logging.Debug, + pb.LogLevel_LOG_LEVEL_INFO: logging.Info, + pb.LogLevel_LOG_LEVEL_WARN: logging.Warn, + pb.LogLevel_LOG_LEVEL_ERROR: logging.Error, + pb.LogLevel_LOG_LEVEL_FATAL: logging.Fatal, } func logLevelToGRPC(l logging.Level) pb.LogLevel { @@ -55,10 +56,10 @@ func logLevelToGRPC(l logging.Level) pb.LogLevel { return grpcVal } } - return pb.LogLevel_DEBUG + return pb.LogLevel_LOG_LEVEL_DEBUG } -func (s *Server) GetLogLevel(ctx context.Context, _ *pb.Empty) (*pb.LogLevelConfig, error) { +func (s *Server) GetLogLevel(ctx context.Context, _ *pbSharedV1.Empty) (*pb.LogLevelConfig, error) { l := s.getLogLevelsByTopics() topics := make(map[string]pb.LogLevel, len(l)) @@ -70,15 +71,15 @@ func (s *Server) GetLogLevel(ctx context.Context, _ *pb.Empty) (*pb.LogLevelConf }, nil } -func (s *Server) SetLogLevel(ctx context.Context, cfg *pb.LogLevelConfig) (*pb.Empty, error) { +func (s *Server) SetLogLevel(ctx context.Context, cfg *pb.LogLevelConfig) (*pbSharedV1.Empty, error) { l := make(map[string]logging.Level, len(cfg.Topics)) for topic, grpcLevel := range cfg.Topics { level, ok := loglevelMap[grpcLevel] if !ok { - return &pb.Empty{}, fmt.Errorf("unknown log level %s for topic %s", grpcLevel, topic) + return &pbSharedV1.Empty{}, fmt.Errorf("unknown log level %s for topic %s", grpcLevel, topic) } l[topic] = level } s.setLogLevelsByTopics(l) - return &pb.Empty{}, nil + return &pbSharedV1.Empty{}, nil } diff --git a/pkg/api/server/operator.pb.go b/pkg/api/server/operator.pb.go index ed87a37e0..633c94914 100644 --- a/pkg/api/server/operator.pb.go +++ b/pkg/api/server/operator.pb.go @@ -27,6 +27,7 @@ package server import ( + definition "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -40,34 +41,41 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// LogLevel defined the Log Levels type LogLevel int32 const ( - LogLevel_TRACE LogLevel = 0 - LogLevel_DEBUG LogLevel = 1 - LogLevel_INFO LogLevel = 2 - LogLevel_WARN LogLevel = 3 - LogLevel_ERROR LogLevel = 4 - LogLevel_FATAL LogLevel = 5 + // LOG_LEVEL_TRACE_UNSPECIFIED defines Trace or Undefined log level + LogLevel_LOG_LEVEL_TRACE_UNSPECIFIED LogLevel = 0 + // LOG_LEVEL_DEBUG defines Debug log level + LogLevel_LOG_LEVEL_DEBUG LogLevel = 1 + // LOG_LEVEL_INFO defines Info log level + LogLevel_LOG_LEVEL_INFO LogLevel = 2 + // LOG_LEVEL_WARN defines Warn log level + LogLevel_LOG_LEVEL_WARN LogLevel = 3 + // LOG_LEVEL_ERROR defines Error log level + LogLevel_LOG_LEVEL_ERROR LogLevel = 4 + // LOG_LEVEL_FATAL defines Fatal log level + LogLevel_LOG_LEVEL_FATAL LogLevel = 5 ) // Enum value maps for LogLevel. var ( LogLevel_name = map[int32]string{ - 0: "TRACE", - 1: "DEBUG", - 2: "INFO", - 3: "WARN", - 4: "ERROR", - 5: "FATAL", + 0: "LOG_LEVEL_TRACE_UNSPECIFIED", + 1: "LOG_LEVEL_DEBUG", + 2: "LOG_LEVEL_INFO", + 3: "LOG_LEVEL_WARN", + 4: "LOG_LEVEL_ERROR", + 5: "LOG_LEVEL_FATAL", } LogLevel_value = map[string]int32{ - "TRACE": 0, - "DEBUG": 1, - "INFO": 2, - "WARN": 3, - "ERROR": 4, - "FATAL": 5, + "LOG_LEVEL_TRACE_UNSPECIFIED": 0, + "LOG_LEVEL_DEBUG": 1, + "LOG_LEVEL_INFO": 2, + "LOG_LEVEL_WARN": 3, + "LOG_LEVEL_ERROR": 4, + "LOG_LEVEL_FATAL": 5, } ) @@ -98,60 +106,28 @@ func (LogLevel) EnumDescriptor() ([]byte, []int) { return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{0} } -type Empty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Empty) Reset() { - *x = Empty{} - if protoimpl.UnsafeEnabled { - mi := &file_pkg_api_server_operator_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Empty) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Empty) ProtoMessage() {} - -func (x *Empty) ProtoReflect() protoreflect.Message { - mi := &file_pkg_api_server_operator_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Empty.ProtoReflect.Descriptor instead. -func (*Empty) Descriptor() ([]byte, []int) { - return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{0} -} - +// Version define the version details type Version struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - Build string `protobuf:"bytes,2,opt,name=build,proto3" json:"build,omitempty"` - Edition string `protobuf:"bytes,3,opt,name=edition,proto3" json:"edition,omitempty"` + // version keeps version info + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + // build keeps build info + Build string `protobuf:"bytes,2,opt,name=build,proto3" json:"build,omitempty"` + // edition keeps the Operator edition + Edition string `protobuf:"bytes,3,opt,name=edition,proto3" json:"edition,omitempty"` + // go_version keeps the version of go used in build GoVersion string `protobuf:"bytes,4,opt,name=go_version,json=goVersion,proto3" json:"go_version,omitempty"` + // build_date keeps the build date BuildDate string `protobuf:"bytes,5,opt,name=build_date,json=buildDate,proto3" json:"build_date,omitempty"` } func (x *Version) Reset() { *x = Version{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_api_server_operator_proto_msgTypes[1] + mi := &file_pkg_api_server_operator_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -164,7 +140,7 @@ func (x *Version) String() string { func (*Version) ProtoMessage() {} func (x *Version) ProtoReflect() protoreflect.Message { - mi := &file_pkg_api_server_operator_proto_msgTypes[1] + mi := &file_pkg_api_server_operator_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -177,7 +153,7 @@ func (x *Version) ProtoReflect() protoreflect.Message { // Deprecated: Use Version.ProtoReflect.Descriptor instead. func (*Version) Descriptor() ([]byte, []int) { - return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{1} + return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{0} } func (x *Version) GetVersion() string { @@ -215,18 +191,20 @@ func (x *Version) GetBuildDate() string { return "" } +// LogLevelConfig define the LogLevel Configs type LogLevelConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // topics define map of the topics and corresponding log levels Topics map[string]LogLevel `protobuf:"bytes,1,rep,name=topics,proto3" json:"topics,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=server.LogLevel"` } func (x *LogLevelConfig) Reset() { *x = LogLevelConfig{} if protoimpl.UnsafeEnabled { - mi := &file_pkg_api_server_operator_proto_msgTypes[2] + mi := &file_pkg_api_server_operator_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -239,7 +217,7 @@ func (x *LogLevelConfig) String() string { func (*LogLevelConfig) ProtoMessage() {} func (x *LogLevelConfig) ProtoReflect() protoreflect.Message { - mi := &file_pkg_api_server_operator_proto_msgTypes[2] + mi := &file_pkg_api_server_operator_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -252,7 +230,7 @@ func (x *LogLevelConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use LogLevelConfig.ProtoReflect.Descriptor instead. func (*LogLevelConfig) Descriptor() ([]byte, []int) { - return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{2} + return file_pkg_api_server_operator_proto_rawDescGZIP(), []int{1} } func (x *LogLevelConfig) GetTopics() map[string]LogLevel { @@ -267,46 +245,53 @@ var File_pkg_api_server_operator_proto protoreflect.FileDescriptor var file_pkg_api_server_operator_proto_rawDesc = []byte{ 0x0a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x91, 0x01, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, - 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x6f, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x64, - 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, - 0x44, 0x61, 0x74, 0x65, 0x22, 0x99, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, - 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3a, 0x0a, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x54, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x6f, 0x70, - 0x69, 0x63, 0x73, 0x1a, 0x4b, 0x0a, 0x0b, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, - 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x2a, 0x4a, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, - 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, - 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, - 0x57, 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, - 0x04, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x05, 0x32, 0xaa, 0x01, 0x0a, - 0x08, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x2e, 0x0a, 0x0a, 0x47, 0x65, 0x74, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x0b, 0x47, 0x65, 0x74, - 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, - 0x00, 0x12, 0x36, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, - 0x12, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, - 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x1a, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x76, 0x31, 0x2f, + 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x01, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, + 0x67, 0x6f, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x67, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x61, 0x74, 0x65, 0x22, 0x99, 0x01, 0x0a, 0x0e, 0x4c, + 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3a, 0x0a, + 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x1a, 0x4b, 0x0a, 0x0b, 0x54, 0x6f, 0x70, + 0x69, 0x63, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x92, 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x1f, 0x0a, 0x1b, 0x4c, 0x4f, 0x47, 0x5f, 0x4c, 0x45, 0x56, 0x45, 0x4c, + 0x5f, 0x54, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x4f, 0x47, 0x5f, 0x4c, 0x45, 0x56, 0x45, + 0x4c, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x4c, 0x4f, 0x47, + 0x5f, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x12, 0x0a, + 0x0e, 0x4c, 0x4f, 0x47, 0x5f, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x10, + 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x4f, 0x47, 0x5f, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x45, + 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x4f, 0x47, 0x5f, 0x4c, 0x45, + 0x56, 0x45, 0x4c, 0x5f, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x05, 0x32, 0xaa, 0x01, 0x0a, 0x08, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x2e, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4c, + 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, + 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x00, + 0x12, 0x36, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, + 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x0d, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, + 0x6b, 0x75, 0x62, 0x65, 0x2d, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x2f, 0x70, 0x6b, + 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -322,23 +307,23 @@ func file_pkg_api_server_operator_proto_rawDescGZIP() []byte { } var file_pkg_api_server_operator_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_pkg_api_server_operator_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_pkg_api_server_operator_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_pkg_api_server_operator_proto_goTypes = []interface{}{ - (LogLevel)(0), // 0: server.LogLevel - (*Empty)(nil), // 1: server.Empty - (*Version)(nil), // 2: server.Version - (*LogLevelConfig)(nil), // 3: server.LogLevelConfig - nil, // 4: server.LogLevelConfig.TopicsEntry + (LogLevel)(0), // 0: server.LogLevel + (*Version)(nil), // 1: server.Version + (*LogLevelConfig)(nil), // 2: server.LogLevelConfig + nil, // 3: server.LogLevelConfig.TopicsEntry + (*definition.Empty)(nil), // 4: shared.Empty } var file_pkg_api_server_operator_proto_depIdxs = []int32{ - 4, // 0: server.LogLevelConfig.topics:type_name -> server.LogLevelConfig.TopicsEntry + 3, // 0: server.LogLevelConfig.topics:type_name -> server.LogLevelConfig.TopicsEntry 0, // 1: server.LogLevelConfig.TopicsEntry.value:type_name -> server.LogLevel - 1, // 2: server.Operator.GetVersion:input_type -> server.Empty - 1, // 3: server.Operator.GetLogLevel:input_type -> server.Empty - 3, // 4: server.Operator.SetLogLevel:input_type -> server.LogLevelConfig - 2, // 5: server.Operator.GetVersion:output_type -> server.Version - 3, // 6: server.Operator.GetLogLevel:output_type -> server.LogLevelConfig - 1, // 7: server.Operator.SetLogLevel:output_type -> server.Empty + 4, // 2: server.Operator.GetVersion:input_type -> shared.Empty + 4, // 3: server.Operator.GetLogLevel:input_type -> shared.Empty + 2, // 4: server.Operator.SetLogLevel:input_type -> server.LogLevelConfig + 1, // 5: server.Operator.GetVersion:output_type -> server.Version + 2, // 6: server.Operator.GetLogLevel:output_type -> server.LogLevelConfig + 4, // 7: server.Operator.SetLogLevel:output_type -> shared.Empty 5, // [5:8] is the sub-list for method output_type 2, // [2:5] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -353,18 +338,6 @@ func file_pkg_api_server_operator_proto_init() { } if !protoimpl.UnsafeEnabled { file_pkg_api_server_operator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Empty); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pkg_api_server_operator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Version); i { case 0: return &v.state @@ -376,7 +349,7 @@ func file_pkg_api_server_operator_proto_init() { return nil } } - file_pkg_api_server_operator_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_pkg_api_server_operator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LogLevelConfig); i { case 0: return &v.state @@ -395,7 +368,7 @@ func file_pkg_api_server_operator_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pkg_api_server_operator_proto_rawDesc, NumEnums: 1, - NumMessages: 4, + NumMessages: 3, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/api/server/operator.proto b/pkg/api/server/operator.proto index c71d129d0..39e480267 100644 --- a/pkg/api/server/operator.proto +++ b/pkg/api/server/operator.proto @@ -20,35 +20,56 @@ syntax = "proto3"; -option go_package = "github.com/arangodb/kube-arangodb/pkg/api/server"; - package server; +import "integrations/shared/v1/definition/empty.proto"; + +option go_package = "github.com/arangodb/kube-arangodb/pkg/api/server"; + +// Operator defined Operator service service Operator { - rpc GetVersion (Empty) returns (Version) {} - rpc GetLogLevel (Empty) returns (LogLevelConfig) {} - rpc SetLogLevel (LogLevelConfig) returns (Empty) {} + // GetVersion returns Operator version + rpc GetVersion (shared.Empty) returns (Version) {} + + // GetLogLevel returns Operator LogLevels + rpc GetLogLevel (shared.Empty) returns (LogLevelConfig) {} + + // SetLogLevel sets Operator LogLevels + rpc SetLogLevel (LogLevelConfig) returns (shared.Empty) {} } -message Empty {} - +// Version define the version details message Version { + // version keeps version info string version = 1; + // build keeps build info string build = 2; + // edition keeps the Operator edition string edition = 3; + // go_version keeps the version of go used in build string go_version = 4; + // build_date keeps the build date string build_date = 5; } +// LogLevel defined the Log Levels enum LogLevel { - TRACE = 0; - DEBUG = 1; - INFO = 2; - WARN = 3; - ERROR = 4; - FATAL = 5; + // LOG_LEVEL_TRACE_UNSPECIFIED defines Trace or Undefined log level + LOG_LEVEL_TRACE_UNSPECIFIED = 0; + // LOG_LEVEL_DEBUG defines Debug log level + LOG_LEVEL_DEBUG = 1; + // LOG_LEVEL_INFO defines Info log level + LOG_LEVEL_INFO = 2; + // LOG_LEVEL_WARN defines Warn log level + LOG_LEVEL_WARN = 3; + // LOG_LEVEL_ERROR defines Error log level + LOG_LEVEL_ERROR = 4; + // LOG_LEVEL_FATAL defines Fatal log level + LOG_LEVEL_FATAL = 5; } +// LogLevelConfig define the LogLevel Configs message LogLevelConfig { + // topics define map of the topics and corresponding log levels map topics = 1; } diff --git a/pkg/api/server/operator_grpc.pb.go b/pkg/api/server/operator_grpc.pb.go index 49aebc0e8..7bf0b016d 100644 --- a/pkg/api/server/operator_grpc.pb.go +++ b/pkg/api/server/operator_grpc.pb.go @@ -8,6 +8,7 @@ package server import ( context "context" + definition "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -22,9 +23,12 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type OperatorClient interface { - GetVersion(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Version, error) - GetLogLevel(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*LogLevelConfig, error) - SetLogLevel(ctx context.Context, in *LogLevelConfig, opts ...grpc.CallOption) (*Empty, error) + // GetVersion returns Operator version + GetVersion(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*Version, error) + // GetLogLevel returns Operator LogLevels + GetLogLevel(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*LogLevelConfig, error) + // SetLogLevel sets Operator LogLevels + SetLogLevel(ctx context.Context, in *LogLevelConfig, opts ...grpc.CallOption) (*definition.Empty, error) } type operatorClient struct { @@ -35,7 +39,7 @@ func NewOperatorClient(cc grpc.ClientConnInterface) OperatorClient { return &operatorClient{cc} } -func (c *operatorClient) GetVersion(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Version, error) { +func (c *operatorClient) GetVersion(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*Version, error) { out := new(Version) err := c.cc.Invoke(ctx, "/server.Operator/GetVersion", in, out, opts...) if err != nil { @@ -44,7 +48,7 @@ func (c *operatorClient) GetVersion(ctx context.Context, in *Empty, opts ...grpc return out, nil } -func (c *operatorClient) GetLogLevel(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*LogLevelConfig, error) { +func (c *operatorClient) GetLogLevel(ctx context.Context, in *definition.Empty, opts ...grpc.CallOption) (*LogLevelConfig, error) { out := new(LogLevelConfig) err := c.cc.Invoke(ctx, "/server.Operator/GetLogLevel", in, out, opts...) if err != nil { @@ -53,8 +57,8 @@ func (c *operatorClient) GetLogLevel(ctx context.Context, in *Empty, opts ...grp return out, nil } -func (c *operatorClient) SetLogLevel(ctx context.Context, in *LogLevelConfig, opts ...grpc.CallOption) (*Empty, error) { - out := new(Empty) +func (c *operatorClient) SetLogLevel(ctx context.Context, in *LogLevelConfig, opts ...grpc.CallOption) (*definition.Empty, error) { + out := new(definition.Empty) err := c.cc.Invoke(ctx, "/server.Operator/SetLogLevel", in, out, opts...) if err != nil { return nil, err @@ -66,9 +70,12 @@ func (c *operatorClient) SetLogLevel(ctx context.Context, in *LogLevelConfig, op // All implementations must embed UnimplementedOperatorServer // for forward compatibility type OperatorServer interface { - GetVersion(context.Context, *Empty) (*Version, error) - GetLogLevel(context.Context, *Empty) (*LogLevelConfig, error) - SetLogLevel(context.Context, *LogLevelConfig) (*Empty, error) + // GetVersion returns Operator version + GetVersion(context.Context, *definition.Empty) (*Version, error) + // GetLogLevel returns Operator LogLevels + GetLogLevel(context.Context, *definition.Empty) (*LogLevelConfig, error) + // SetLogLevel sets Operator LogLevels + SetLogLevel(context.Context, *LogLevelConfig) (*definition.Empty, error) mustEmbedUnimplementedOperatorServer() } @@ -76,13 +83,13 @@ type OperatorServer interface { type UnimplementedOperatorServer struct { } -func (UnimplementedOperatorServer) GetVersion(context.Context, *Empty) (*Version, error) { +func (UnimplementedOperatorServer) GetVersion(context.Context, *definition.Empty) (*Version, error) { return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented") } -func (UnimplementedOperatorServer) GetLogLevel(context.Context, *Empty) (*LogLevelConfig, error) { +func (UnimplementedOperatorServer) GetLogLevel(context.Context, *definition.Empty) (*LogLevelConfig, error) { return nil, status.Errorf(codes.Unimplemented, "method GetLogLevel not implemented") } -func (UnimplementedOperatorServer) SetLogLevel(context.Context, *LogLevelConfig) (*Empty, error) { +func (UnimplementedOperatorServer) SetLogLevel(context.Context, *LogLevelConfig) (*definition.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method SetLogLevel not implemented") } func (UnimplementedOperatorServer) mustEmbedUnimplementedOperatorServer() {} @@ -99,7 +106,7 @@ func RegisterOperatorServer(s grpc.ServiceRegistrar, srv OperatorServer) { } func _Operator_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) + in := new(definition.Empty) if err := dec(in); err != nil { return nil, err } @@ -111,13 +118,13 @@ func _Operator_GetVersion_Handler(srv interface{}, ctx context.Context, dec func FullMethod: "/server.Operator/GetVersion", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OperatorServer).GetVersion(ctx, req.(*Empty)) + return srv.(OperatorServer).GetVersion(ctx, req.(*definition.Empty)) } return interceptor(ctx, in, info, handler) } func _Operator_GetLogLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) + in := new(definition.Empty) if err := dec(in); err != nil { return nil, err } @@ -129,7 +136,7 @@ func _Operator_GetLogLevel_Handler(srv interface{}, ctx context.Context, dec fun FullMethod: "/server.Operator/GetLogLevel", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OperatorServer).GetLogLevel(ctx, req.(*Empty)) + return srv.(OperatorServer).GetLogLevel(ctx, req.(*definition.Empty)) } return interceptor(ctx, in, info, handler) } diff --git a/pkg/integrations/authentication_v1.go b/pkg/integrations/authentication_v1.go index 3bac99342..b7aa60719 100644 --- a/pkg/integrations/authentication_v1.go +++ b/pkg/integrations/authentication_v1.go @@ -26,6 +26,7 @@ import ( "github.com/spf13/cobra" pbImplAuthenticationV1 "github.com/arangodb/kube-arangodb/integrations/authentication/v1" + pbAuthenticationV1 "github.com/arangodb/kube-arangodb/integrations/authentication/v1/definition" "github.com/arangodb/kube-arangodb/pkg/util/svc" ) @@ -59,7 +60,7 @@ func (a *authenticationV1) Handler(ctx context.Context) (svc.Handler, error) { } func (a *authenticationV1) Name() string { - return "authentication.v1" + return pbAuthenticationV1.Name } func (a *authenticationV1) Description() string { diff --git a/pkg/integrations/authorization_v0.go b/pkg/integrations/authorization_v0.go new file mode 100644 index 000000000..7cb0efce1 --- /dev/null +++ b/pkg/integrations/authorization_v0.go @@ -0,0 +1,56 @@ +// +// 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 integrations + +import ( + "context" + + "github.com/spf13/cobra" + + pbImplAuthorizationV0 "github.com/arangodb/kube-arangodb/integrations/authorization/v0" + pbAuthorizationV0 "github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition" + "github.com/arangodb/kube-arangodb/pkg/util/svc" +) + +func init() { + register(func() Integration { + return &authorizationV0{} + }) +} + +type authorizationV0 struct { +} + +func (a authorizationV0) Name() string { + return pbAuthorizationV0.Name +} + +func (a authorizationV0) Description() string { + return "Enable AuthorizationV0 Integration Service" +} + +func (a authorizationV0) Register(cmd *cobra.Command, arg ArgGen) error { + return nil +} + +func (a authorizationV0) Handler(ctx context.Context) (svc.Handler, error) { + return pbImplAuthorizationV0.New(), nil +} diff --git a/pkg/util/close.go b/pkg/util/closer/close.go similarity index 84% rename from pkg/util/close.go rename to pkg/util/closer/close.go index 8e5b04e9a..36f07a492 100644 --- a/pkg/util/close.go +++ b/pkg/util/closer/close.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-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. @@ -18,7 +18,7 @@ // Copyright holder is ArangoDB GmbH, Cologne, Germany // -package util +package closer import "sync" @@ -52,3 +52,12 @@ func CloseOnce(c Close) Close { close: c, } } + +func IsChannelClosed[T any](in <-chan T) bool { + select { + case <-in: + return true + default: + return false + } +} diff --git a/pkg/util/http/requests.go b/pkg/util/http/requests.go index 0adc3c049..319d321e8 100644 --- a/pkg/util/http/requests.go +++ b/pkg/util/http/requests.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2023-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. @@ -24,7 +24,7 @@ import ( "encoding/json" "net/http" - "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/closer" "github.com/arangodb/kube-arangodb/pkg/util/errors" ) @@ -39,7 +39,7 @@ func RequestInvoke[T interface{}](invoker RequestInvoker, request *http.Request) } if body := resp.Body; body != nil { - c := util.CloseOnce(body) + c := closer.CloseOnce(body) defer c.Close() var obj T