From 29501b2cfe9e2d749f33fdce8f5ade3d3a244468 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 16 Feb 2023 13:24:31 +0100 Subject: [PATCH 1/4] make the default settings bundles part of the config --- .bingo/Variables.mk | 6 ++ .bingo/protoc-go-inject-tag.mod | 5 + .bingo/protoc-go-inject-tag.sum | 2 + .bingo/variables.env | 2 + .make/protobuf.mk | 1 + .../ocis/messages/settings/v0/settings.pb.go | 98 ++++++++--------- .../ocis/messages/settings/v0/settings.proto | 100 +++++++++--------- services/settings/Makefile | 3 +- services/settings/pkg/config/config.go | 8 +- .../pkg/config/defaults/defaultconfig.go | 2 + services/settings/pkg/store/metadata/store.go | 2 +- 11 files changed, 125 insertions(+), 104 deletions(-) create mode 100644 .bingo/protoc-go-inject-tag.mod create mode 100644 .bingo/protoc-go-inject-tag.sum diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk index 49fca0b623..2dfa10bf8d 100644 --- a/.bingo/Variables.mk +++ b/.bingo/Variables.mk @@ -101,6 +101,12 @@ $(PROTOC_GEN_OPENAPIV2): $(BINGO_DIR)/protoc-gen-openapiv2.mod @echo "(re)installing $(GOBIN)/protoc-gen-openapiv2-v2.13.0" @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=protoc-gen-openapiv2.mod -o=$(GOBIN)/protoc-gen-openapiv2-v2.13.0 "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" +PROTOC_GO_INJECT_TAG := $(GOBIN)/protoc-go-inject-tag-v1.4.0 +$(PROTOC_GO_INJECT_TAG): $(BINGO_DIR)/protoc-go-inject-tag.mod + @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. + @echo "(re)installing $(GOBIN)/protoc-go-inject-tag-v1.4.0" + @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=protoc-go-inject-tag.mod -o=$(GOBIN)/protoc-go-inject-tag-v1.4.0 "github.com/favadi/protoc-go-inject-tag" + REFLEX := $(GOBIN)/reflex-v0.3.1 $(REFLEX): $(BINGO_DIR)/reflex.mod @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. diff --git a/.bingo/protoc-go-inject-tag.mod b/.bingo/protoc-go-inject-tag.mod new file mode 100644 index 0000000000..db8d3426ff --- /dev/null +++ b/.bingo/protoc-go-inject-tag.mod @@ -0,0 +1,5 @@ +module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT + +go 1.19 + +require github.com/favadi/protoc-go-inject-tag v1.4.0 diff --git a/.bingo/protoc-go-inject-tag.sum b/.bingo/protoc-go-inject-tag.sum new file mode 100644 index 0000000000..6426930445 --- /dev/null +++ b/.bingo/protoc-go-inject-tag.sum @@ -0,0 +1,2 @@ +github.com/favadi/protoc-go-inject-tag v1.4.0 h1:K3KXxbgRw5WT4f43LbglARGz/8jVsDOS7uMjG4oNvXY= +github.com/favadi/protoc-go-inject-tag v1.4.0/go.mod h1:AZ+PK+QDKUOLlBRG0rYiKkUX5Hw7+7GTFzlU99GFSbQ= diff --git a/.bingo/variables.env b/.bingo/variables.env index b46f897254..2044ef4112 100644 --- a/.bingo/variables.env +++ b/.bingo/variables.env @@ -36,5 +36,7 @@ PROTOC_GEN_MICROWEB="${GOBIN}/protoc-gen-microweb-v0.0.0-20220808092353-b5d6c396 PROTOC_GEN_OPENAPIV2="${GOBIN}/protoc-gen-openapiv2-v2.13.0" +PROTOC_GO_INJECT_TAG="${GOBIN}/protoc-go-inject-tag-v1.4.0" + REFLEX="${GOBIN}/reflex-v0.3.1" diff --git a/.make/protobuf.mk b/.make/protobuf.mk index 54092c2569..e2f19031f4 100644 --- a/.make/protobuf.mk +++ b/.make/protobuf.mk @@ -11,6 +11,7 @@ protoc-deps: $(BINGO) @cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb @cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 @cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc + @cd ../.. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/favadi/protoc-go-inject-tag .PHONY: buf-generate buf-generate: $(BUF) protoc-deps $(SHA1_LOCK_FILE) diff --git a/protogen/gen/ocis/messages/settings/v0/settings.pb.go b/protogen/gen/ocis/messages/settings/v0/settings.pb.go index 70600cb9f1..ae11049bab 100644 --- a/protogen/gen/ocis/messages/settings/v0/settings.pb.go +++ b/protogen/gen/ocis/messages/settings/v0/settings.pb.go @@ -489,13 +489,13 @@ type Bundle struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Type Bundle_Type `protobuf:"varint,3,opt,name=type,proto3,enum=ocis.messages.settings.v0.Bundle_Type" json:"type,omitempty"` - Extension string `protobuf:"bytes,4,opt,name=extension,proto3" json:"extension,omitempty"` - DisplayName string `protobuf:"bytes,5,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` - Settings []*Setting `protobuf:"bytes,6,rep,name=settings,proto3" json:"settings,omitempty"` - Resource *Resource `protobuf:"bytes,7,opt,name=resource,proto3" json:"resource,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` // @gotags: yaml:"id" + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` // @gotags: yaml:"name" + Type Bundle_Type `protobuf:"varint,3,opt,name=type,proto3,enum=ocis.messages.settings.v0.Bundle_Type" json:"type,omitempty" yaml:"type"` // @gotags: yaml:"type" + Extension string `protobuf:"bytes,4,opt,name=extension,proto3" json:"extension,omitempty" yaml:"extension"` // @gotags: yaml:"extension" + DisplayName string `protobuf:"bytes,5,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty" yaml:"display_name"` // @gotags: yaml:"display_name" + Settings []*Setting `protobuf:"bytes,6,rep,name=settings,proto3" json:"settings,omitempty" yaml:"settings"` // @gotags: yaml:"settings" + Resource *Resource `protobuf:"bytes,7,opt,name=resource,proto3" json:"resource,omitempty" yaml:"resource"` // @gotags: yaml:"resource" } func (x *Bundle) Reset() { @@ -584,10 +584,10 @@ type Setting struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - DisplayName string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"` - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` // @gotags: yaml:"id" + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` // @gotags: yaml:"name" + DisplayName string `protobuf:"bytes,3,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty" yaml:"display_name"` // @gotags: yaml:"display_name" + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` // @gotags: yaml:"description" // Types that are assignable to Value: // // *Setting_IntValue @@ -597,7 +597,7 @@ type Setting struct { // *Setting_MultiChoiceValue // *Setting_PermissionValue Value isSetting_Value `protobuf_oneof:"value"` - Resource *Resource `protobuf:"bytes,11,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *Resource `protobuf:"bytes,11,opt,name=resource,proto3" json:"resource,omitempty" yaml:"resource"` // @gotags: yaml:"resource" } func (x *Setting) Reset() { @@ -721,27 +721,27 @@ type isSetting_Value interface { } type Setting_IntValue struct { - IntValue *Int `protobuf:"bytes,5,opt,name=int_value,json=intValue,proto3,oneof"` + IntValue *Int `protobuf:"bytes,5,opt,name=int_value,json=intValue,proto3,oneof" yaml:"int_value"` // @gotags: yaml:"int_value" } type Setting_StringValue struct { - StringValue *String `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof"` + StringValue *String `protobuf:"bytes,6,opt,name=string_value,json=stringValue,proto3,oneof" yaml:"string_value"` // @gotags: yaml:"string_value" } type Setting_BoolValue struct { - BoolValue *Bool `protobuf:"bytes,7,opt,name=bool_value,json=boolValue,proto3,oneof"` + BoolValue *Bool `protobuf:"bytes,7,opt,name=bool_value,json=boolValue,proto3,oneof" yaml:"bool_value"` // @gotags: yaml:"bool_value" } type Setting_SingleChoiceValue struct { - SingleChoiceValue *SingleChoiceList `protobuf:"bytes,8,opt,name=single_choice_value,json=singleChoiceValue,proto3,oneof"` + SingleChoiceValue *SingleChoiceList `protobuf:"bytes,8,opt,name=single_choice_value,json=singleChoiceValue,proto3,oneof" yaml:"single_choice_value"` // @gotags: yaml:"single_choice_value" } type Setting_MultiChoiceValue struct { - MultiChoiceValue *MultiChoiceList `protobuf:"bytes,9,opt,name=multi_choice_value,json=multiChoiceValue,proto3,oneof"` + MultiChoiceValue *MultiChoiceList `protobuf:"bytes,9,opt,name=multi_choice_value,json=multiChoiceValue,proto3,oneof" yaml:"multi_choice_value"` // @gotags: yaml:"multi_choice_value" } type Setting_PermissionValue struct { - PermissionValue *Permission `protobuf:"bytes,10,opt,name=permission_value,json=permissionValue,proto3,oneof"` + PermissionValue *Permission `protobuf:"bytes,10,opt,name=permission_value,json=permissionValue,proto3,oneof" yaml:"permission_value"` // @gotags: yaml:"permission_value" } func (*Setting_IntValue) isSetting_Value() {} @@ -761,11 +761,11 @@ type Int struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Default int64 `protobuf:"varint,1,opt,name=default,proto3" json:"default,omitempty"` - Min int64 `protobuf:"varint,2,opt,name=min,proto3" json:"min,omitempty"` - Max int64 `protobuf:"varint,3,opt,name=max,proto3" json:"max,omitempty"` - Step int64 `protobuf:"varint,4,opt,name=step,proto3" json:"step,omitempty"` - Placeholder string `protobuf:"bytes,5,opt,name=placeholder,proto3" json:"placeholder,omitempty"` + Default int64 `protobuf:"varint,1,opt,name=default,proto3" json:"default,omitempty" yaml:"default"` // @gotags: yaml:"default" + Min int64 `protobuf:"varint,2,opt,name=min,proto3" json:"min,omitempty" yaml:"min"` // @gotags: yaml:"min" + Max int64 `protobuf:"varint,3,opt,name=max,proto3" json:"max,omitempty" yaml:"max"` // @gotags: yaml:"max" + Step int64 `protobuf:"varint,4,opt,name=step,proto3" json:"step,omitempty" yaml:"step"` // @gotags: yaml:"step" + Placeholder string `protobuf:"bytes,5,opt,name=placeholder,proto3" json:"placeholder,omitempty" yaml:"placeholder"` // @gotags: yaml:"placeholder" } func (x *Int) Reset() { @@ -840,11 +840,11 @@ type String struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Default string `protobuf:"bytes,1,opt,name=default,proto3" json:"default,omitempty"` - Required bool `protobuf:"varint,2,opt,name=required,proto3" json:"required,omitempty"` - MinLength int32 `protobuf:"varint,3,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` - MaxLength int32 `protobuf:"varint,4,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` - Placeholder string `protobuf:"bytes,5,opt,name=placeholder,proto3" json:"placeholder,omitempty"` + Default string `protobuf:"bytes,1,opt,name=default,proto3" json:"default,omitempty" yaml:"default"` // @gotags: yaml:"default" + Required bool `protobuf:"varint,2,opt,name=required,proto3" json:"required,omitempty" yaml:"required"` // @gotags: yaml:"required" + MinLength int32 `protobuf:"varint,3,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty" yaml:"min_length"` // @gotags: yaml:"min_length" + MaxLength int32 `protobuf:"varint,4,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty" yaml:"max_length"` // @gotags: yaml:"max_length" + Placeholder string `protobuf:"bytes,5,opt,name=placeholder,proto3" json:"placeholder,omitempty" yaml:"placeholder"` // @gotags: yaml:"placeholder" } func (x *String) Reset() { @@ -919,8 +919,8 @@ type Bool struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Default bool `protobuf:"varint,1,opt,name=default,proto3" json:"default,omitempty"` - Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` + Default bool `protobuf:"varint,1,opt,name=default,proto3" json:"default,omitempty" yaml:"default"` // @gotags: yaml:"default" + Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty" yaml:"label"` // @gotags: yaml:"label" } func (x *Bool) Reset() { @@ -974,7 +974,7 @@ type SingleChoiceList struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Options []*ListOption `protobuf:"bytes,1,rep,name=options,proto3" json:"options,omitempty"` + Options []*ListOption `protobuf:"bytes,1,rep,name=options,proto3" json:"options,omitempty" yaml:"options"` // @gotags: yaml:"options" } func (x *SingleChoiceList) Reset() { @@ -1021,7 +1021,7 @@ type MultiChoiceList struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Options []*ListOption `protobuf:"bytes,1,rep,name=options,proto3" json:"options,omitempty"` + Options []*ListOption `protobuf:"bytes,1,rep,name=options,proto3" json:"options,omitempty" yaml:"options"` // @gotags: yaml:"options" } func (x *MultiChoiceList) Reset() { @@ -1068,9 +1068,9 @@ type ListOption struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Value *ListOptionValue `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` - Default bool `protobuf:"varint,2,opt,name=default,proto3" json:"default,omitempty"` - DisplayValue string `protobuf:"bytes,3,opt,name=display_value,json=displayValue,proto3" json:"display_value,omitempty"` + Value *ListOptionValue `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty" yaml:"value"` // @gotags: yaml:"value" + Default bool `protobuf:"varint,2,opt,name=default,proto3" json:"default,omitempty" yaml:"default"` // @gotags: yaml:"default" + DisplayValue string `protobuf:"bytes,3,opt,name=display_value,json=displayValue,proto3" json:"display_value,omitempty" yaml:"display_value"` // @gotags: yaml:"display_value" } func (x *ListOption) Reset() { @@ -1131,8 +1131,8 @@ type Permission struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Operation Permission_Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=ocis.messages.settings.v0.Permission_Operation" json:"operation,omitempty"` - Constraint Permission_Constraint `protobuf:"varint,2,opt,name=constraint,proto3,enum=ocis.messages.settings.v0.Permission_Constraint" json:"constraint,omitempty"` + Operation Permission_Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=ocis.messages.settings.v0.Permission_Operation" json:"operation,omitempty" yaml:"operation"` // @gotags: yaml:"operation" + Constraint Permission_Constraint `protobuf:"varint,2,opt,name=constraint,proto3,enum=ocis.messages.settings.v0.Permission_Constraint" json:"constraint,omitempty" yaml:"constraint"` // @gotags: yaml:"constraint" } func (x *Permission) Reset() { @@ -1187,12 +1187,12 @@ type Value struct { unknownFields protoimpl.UnknownFields // id is the id of the Value. It is generated on saving it. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - BundleId string `protobuf:"bytes,2,opt,name=bundle_id,json=bundleId,proto3" json:"bundle_id,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` // @gotags: yaml:"id" + BundleId string `protobuf:"bytes,2,opt,name=bundle_id,json=bundleId,proto3" json:"bundle_id,omitempty" yaml:"bundle_id"` // @gotags: yaml:"bundle_id" // setting_id is the id of the setting from within its bundle. - SettingId string `protobuf:"bytes,3,opt,name=setting_id,json=settingId,proto3" json:"setting_id,omitempty"` - AccountUuid string `protobuf:"bytes,4,opt,name=account_uuid,json=accountUuid,proto3" json:"account_uuid,omitempty"` - Resource *Resource `protobuf:"bytes,5,opt,name=resource,proto3" json:"resource,omitempty"` + SettingId string `protobuf:"bytes,3,opt,name=setting_id,json=settingId,proto3" json:"setting_id,omitempty" yaml:"settings_id"` // @gotags: yaml:"settings_id" + AccountUuid string `protobuf:"bytes,4,opt,name=account_uuid,json=accountUuid,proto3" json:"account_uuid,omitempty" yaml:"account_uuid"` // @gotags: yaml:"account_uuid" + Resource *Resource `protobuf:"bytes,5,opt,name=resource,proto3" json:"resource,omitempty" yaml:"resource"` // @gotags: yaml:"resource" // Types that are assignable to Value: // // *Value_BoolValue @@ -1309,19 +1309,19 @@ type isValue_Value interface { } type Value_BoolValue struct { - BoolValue bool `protobuf:"varint,6,opt,name=bool_value,json=boolValue,proto3,oneof"` + BoolValue bool `protobuf:"varint,6,opt,name=bool_value,json=boolValue,proto3,oneof" yaml:"bool_value"` // @gotags: yaml:"bool_value" } type Value_IntValue struct { - IntValue int64 `protobuf:"varint,7,opt,name=int_value,json=intValue,proto3,oneof"` + IntValue int64 `protobuf:"varint,7,opt,name=int_value,json=intValue,proto3,oneof" yaml:"int_value"` // @gotags: yaml:"int_value" } type Value_StringValue struct { - StringValue string `protobuf:"bytes,8,opt,name=string_value,json=stringValue,proto3,oneof"` + StringValue string `protobuf:"bytes,8,opt,name=string_value,json=stringValue,proto3,oneof" yaml:"string_value"` // @gotags: yaml:"string_value" } type Value_ListValue struct { - ListValue *ListValue `protobuf:"bytes,9,opt,name=list_value,json=listValue,proto3,oneof"` + ListValue *ListValue `protobuf:"bytes,9,opt,name=list_value,json=listValue,proto3,oneof" yaml:"list_value"` // @gotags: yaml:"list_value" } func (*Value_BoolValue) isValue_Value() {} @@ -1337,7 +1337,7 @@ type ListValue struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Values []*ListOptionValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + Values []*ListOptionValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty" yaml:"values"` // @gotags: yaml:"values" } func (x *ListValue) Reset() { @@ -1449,11 +1449,11 @@ type isListOptionValue_Option interface { } type ListOptionValue_StringValue struct { - StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3,oneof"` + StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3,oneof" yaml:"string_value"` // @gotags: yaml:"string_value" } type ListOptionValue_IntValue struct { - IntValue int64 `protobuf:"varint,2,opt,name=int_value,json=intValue,proto3,oneof"` + IntValue int64 `protobuf:"varint,2,opt,name=int_value,json=intValue,proto3,oneof" yaml:"int_value"` // @gotags: yaml:"int_value" } func (*ListOptionValue_StringValue) isListOptionValue_Option() {} diff --git a/protogen/proto/ocis/messages/settings/v0/settings.proto b/protogen/proto/ocis/messages/settings/v0/settings.proto index 5bf93c96b9..d73ad61f22 100644 --- a/protogen/proto/ocis/messages/settings/v0/settings.proto +++ b/protogen/proto/ocis/messages/settings/v0/settings.proto @@ -59,65 +59,65 @@ message Bundle { TYPE_UNKNOWN = 0; TYPE_DEFAULT = 1; TYPE_ROLE = 2; - } - string id = 1; - string name = 2; - Type type = 3; - string extension = 4; - string display_name = 5; - repeated Setting settings = 6; - Resource resource = 7; + }; + string id = 1; // @gotags: yaml:"id" + string name = 2; // @gotags: yaml:"name" + Type type = 3; // @gotags: yaml:"type" + string extension = 4; // @gotags: yaml:"extension" + string display_name = 5; // @gotags: yaml:"display_name" + repeated Setting settings = 6; // @gotags: yaml:"settings" + Resource resource = 7; // @gotags: yaml:"resource" } message Setting { - string id = 1; - string name = 2; - string display_name = 3; - string description = 4; + string id = 1; // @gotags: yaml:"id" + string name = 2; // @gotags: yaml:"name" + string display_name = 3; // @gotags: yaml:"display_name" + string description = 4; // @gotags: yaml:"description" oneof value { - Int int_value = 5; - String string_value = 6; - Bool bool_value = 7; - SingleChoiceList single_choice_value = 8; - MultiChoiceList multi_choice_value = 9; - Permission permission_value = 10; + Int int_value = 5; // @gotags: yaml:"int_value" + String string_value = 6; // @gotags: yaml:"string_value" + Bool bool_value = 7; // @gotags: yaml:"bool_value" + SingleChoiceList single_choice_value = 8; // @gotags: yaml:"single_choice_value" + MultiChoiceList multi_choice_value = 9; // @gotags: yaml:"multi_choice_value" + Permission permission_value = 10; // @gotags: yaml:"permission_value" } - Resource resource = 11; + Resource resource = 11; // @gotags: yaml:"resource" } message Int { - int64 default = 1; - int64 min = 2; - int64 max = 3; - int64 step = 4; - string placeholder = 5; + int64 default = 1; // @gotags: yaml:"default" + int64 min = 2; // @gotags: yaml:"min" + int64 max = 3; // @gotags: yaml:"max" + int64 step = 4; // @gotags: yaml:"step" + string placeholder = 5; // @gotags: yaml:"placeholder" } message String { - string default = 1; - bool required = 2; - int32 min_length = 3; - int32 max_length = 4; - string placeholder = 5; + string default = 1; // @gotags: yaml:"default" + bool required = 2; // @gotags: yaml:"required" + int32 min_length = 3; // @gotags: yaml:"min_length" + int32 max_length = 4; // @gotags: yaml:"max_length" + string placeholder = 5; // @gotags: yaml:"placeholder" } message Bool { - bool default = 1; - string label = 2; + bool default = 1; // @gotags: yaml:"default" + string label = 2; // @gotags: yaml:"label" } message SingleChoiceList { - repeated ListOption options = 1; + repeated ListOption options = 1; // @gotags: yaml:"options" } message MultiChoiceList { - repeated ListOption options = 1; + repeated ListOption options = 1; // @gotags: yaml:"options" } message ListOption { - ListOptionValue value = 1; - bool default = 2; - string display_value = 3; + ListOptionValue value = 1; // @gotags: yaml:"value" + bool default = 2; // @gotags: yaml:"default" + string display_value = 3; // @gotags: yaml:"display_value" } message Permission { @@ -130,14 +130,14 @@ message Permission { OPERATION_WRITE = 5;// WRITE is a combination of CREATE and UPDATE OPERATION_READWRITE = 6;// READWRITE is a combination of READ and WRITE } - Operation operation = 1; + Operation operation = 1; // @gotags: yaml:"operation" enum Constraint { CONSTRAINT_UNKNOWN = 0; CONSTRAINT_OWN = 1; CONSTRAINT_SHARED = 2; CONSTRAINT_ALL = 3; } - Constraint constraint = 2; + Constraint constraint = 2; // @gotags: yaml:"constraint" } // --- @@ -146,27 +146,27 @@ message Permission { message Value { // id is the id of the Value. It is generated on saving it. - string id = 1; - string bundle_id = 2; + string id = 1; // @gotags: yaml:"id" + string bundle_id = 2; // @gotags: yaml:"bundle_id" // setting_id is the id of the setting from within its bundle. - string setting_id = 3; - string account_uuid = 4; - Resource resource = 5; + string setting_id = 3; // @gotags: yaml:"settings_id" + string account_uuid = 4; // @gotags: yaml:"account_uuid" + Resource resource = 5; // @gotags: yaml:"resource" oneof value { - bool bool_value = 6; - int64 int_value = 7; - string string_value = 8; - ListValue list_value = 9; + bool bool_value = 6; // @gotags: yaml:"bool_value" + int64 int_value = 7; // @gotags: yaml:"int_value" + string string_value = 8; // @gotags: yaml:"string_value" + ListValue list_value = 9; // @gotags: yaml:"list_value" } } message ListValue { - repeated ListOptionValue values = 1; + repeated ListOptionValue values = 1; // @gotags: yaml:"values" } message ListOptionValue { oneof option { - string string_value = 1; - int64 int_value = 2; + string string_value = 1; // @gotags: yaml:"string_value" + int64 int_value = 2; // @gotags: yaml:"int_value" } } diff --git a/services/settings/Makefile b/services/settings/Makefile index 54787569f3..0cf036a73f 100644 --- a/services/settings/Makefile +++ b/services/settings/Makefile @@ -35,7 +35,8 @@ ci-node-generate: include ../../.make/protobuf.mk .PHONY: protobuf -protobuf: buf-generate +protobuf: buf-generate $(BINGO) + cd ../../protogen/gen/ && $(PROTOC_GO_INJECT_TAG) -input="ocis/messages/settings/v0/*.pb.go" ############ licenses ############ .PHONY: ci-node-check-licenses diff --git a/services/settings/pkg/config/config.go b/services/settings/pkg/config/config.go index be17a238a8..390c740af0 100644 --- a/services/settings/pkg/config/config.go +++ b/services/settings/pkg/config/config.go @@ -4,6 +4,7 @@ import ( "context" "github.com/owncloud/ocis/v2/ocis-pkg/shared" + settingsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0" ) // Config combines all available configuration parts. @@ -21,9 +22,10 @@ type Config struct { GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` - StoreType string `yaml:"store_type" env:"SETTINGS_STORE_TYPE" desc:"Store type configures the persistency driver. Supported values are \"metadata\" and \"filesystem\"."` - DataPath string `yaml:"data_path" env:"SETTINGS_DATA_PATH" desc:"The directory where the filesystem storage will store ocis settings. If not definied, the root directory derives from $OCIS_BASE_DATA_PATH:/settings."` - Metadata Metadata `yaml:"metadata_config"` + StoreType string `yaml:"store_type" env:"SETTINGS_STORE_TYPE" desc:"Store type configures the persistency driver. Supported values are \"metadata\" and \"filesystem\"."` + DataPath string `yaml:"data_path" env:"SETTINGS_DATA_PATH" desc:"The directory where the filesystem storage will store ocis settings. If not definied, the root directory derives from $OCIS_BASE_DATA_PATH:/settings."` + Metadata Metadata `yaml:"metadata_config"` + Bundles []*settingsmsg.Bundle `yaml:"bundles"` AdminUserID string `yaml:"admin_user_id" env:"OCIS_ADMIN_USER_ID;SETTINGS_ADMIN_USER_ID" desc:"ID of the user that should receive admin privileges. Consider that the UUID can be encoded in some LDAP deployment configurations like in .ldif files. These need to be decoded beforehand."` diff --git a/services/settings/pkg/config/defaults/defaultconfig.go b/services/settings/pkg/config/defaults/defaultconfig.go index de1ac0f850..6215963d4a 100644 --- a/services/settings/pkg/config/defaults/defaultconfig.go +++ b/services/settings/pkg/config/defaults/defaultconfig.go @@ -7,6 +7,7 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/settings/pkg/config" + rdefaults "github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults" ) func FullDefaultConfig() *config.Config { @@ -51,6 +52,7 @@ func DefaultConfig() *config.Config { StorageAddress: "127.0.0.1:9215", SystemUserIDP: "internal", }, + Bundles: rdefaults.GenerateBundlesDefaultRoles(), } } diff --git a/services/settings/pkg/store/metadata/store.go b/services/settings/pkg/store/metadata/store.go index 654c3bba4c..38a2cb02b8 100644 --- a/services/settings/pkg/store/metadata/store.go +++ b/services/settings/pkg/store/metadata/store.go @@ -112,7 +112,7 @@ func (s *Store) initMetadataClient(mdc MetadataClient) error { } } - for _, p := range defaults.GenerateBundlesDefaultRoles() { + for _, p := range s.cfg.Bundles { b, err := json.Marshal(p) if err != nil { return err From 0986a4b501f6da75f9c4ab617e44c0e82b8e83dd Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 16 Feb 2023 13:30:07 +0100 Subject: [PATCH 2/4] add changelog --- changelog/unreleased/configure-bundles.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/configure-bundles.md diff --git a/changelog/unreleased/configure-bundles.md b/changelog/unreleased/configure-bundles.md new file mode 100644 index 0000000000..c69b9845ef --- /dev/null +++ b/changelog/unreleased/configure-bundles.md @@ -0,0 +1,5 @@ +Enhancement: Make the settings bundles part of the service config + +We added the settings bundles to the config. The default roles are still unchanged. You can now override the defaults by replacing the whole bundles list via the yaml config files. An example can be found in the Service Configuration documentation. + +https://github.com/owncloud/ocis/pull/5589 From b85387f707ec0a3285178688795fa5e036659cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 16 Feb 2023 13:41:33 +0100 Subject: [PATCH 3/4] Update protogen/proto/ocis/messages/settings/v0/settings.proto --- protogen/proto/ocis/messages/settings/v0/settings.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protogen/proto/ocis/messages/settings/v0/settings.proto b/protogen/proto/ocis/messages/settings/v0/settings.proto index d73ad61f22..af3cd0fd82 100644 --- a/protogen/proto/ocis/messages/settings/v0/settings.proto +++ b/protogen/proto/ocis/messages/settings/v0/settings.proto @@ -149,7 +149,7 @@ message Value { string id = 1; // @gotags: yaml:"id" string bundle_id = 2; // @gotags: yaml:"bundle_id" // setting_id is the id of the setting from within its bundle. - string setting_id = 3; // @gotags: yaml:"settings_id" + string setting_id = 3; // @gotags: yaml:"setting_id" string account_uuid = 4; // @gotags: yaml:"account_uuid" Resource resource = 5; // @gotags: yaml:"resource" oneof value { From 552f3b3058e7854611f09df67f0db57652372eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 16 Feb 2023 13:54:41 +0100 Subject: [PATCH 4/4] Update services/settings/Makefile --- services/settings/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/settings/Makefile b/services/settings/Makefile index 0cf036a73f..05982ea700 100644 --- a/services/settings/Makefile +++ b/services/settings/Makefile @@ -35,7 +35,7 @@ ci-node-generate: include ../../.make/protobuf.mk .PHONY: protobuf -protobuf: buf-generate $(BINGO) +protobuf: buf-generate $(PROTOC_GO_INJECT_TAG) cd ../../protogen/gen/ && $(PROTOC_GO_INJECT_TAG) -input="ocis/messages/settings/v0/*.pb.go" ############ licenses ############