Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/feat tenants users #23

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
version: "22.2"
- name: Install protoc-gen-grpc-gateway
run: |
git clone https://github.com/geebytes/grpc-gateway.git
git clone --recursive https://github.com/geebytes/grpc-gateway.git
cd grpc-gateway
go install ./protoc-gen-grpc-gateway
- name: Test
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"go.formatTool": "goimports",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"go.testTimeout": "60s"
}
6 changes: 3 additions & 3 deletions cmd/begonia/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func readInitAPP(env string) {
addr = gw.Addr

}
func RegisterEndpoint(env,name string, endpoints []string, pbFile string, opts ...client.EndpointOption) {
func RegisterEndpoint(env, name string, endpoints []string, pbFile string, opts ...client.EndpointOption) {
readInitAPP(env)
pb, err := os.ReadFile(pbFile)
if err != nil {
Expand Down Expand Up @@ -103,7 +103,7 @@ func RegisterEndpoint(env,name string, endpoints []string, pbFile string, opts .
log.Printf("#####################Add Endpoint Success#####################")
log.Printf("#####################ID:%s####################################", rsp.Id)
}
func UpdateEndpoint(env,id string, mask []string, opts ...client.EndpointOption) {
func UpdateEndpoint(env, id string, mask []string, opts ...client.EndpointOption) {
readInitAPP(env)
apiClient := client.NewEndpointAPI(addr, accessKey, secret)
log.Printf("#####################Update Endpoint###########################")
Expand All @@ -120,7 +120,7 @@ func UpdateEndpoint(env,id string, mask []string, opts ...client.EndpointOption)
log.Printf("#####################Update Endpoint %s Success#####################", id)

}
func DeleteEndpoint(env,id string) {
func DeleteEndpoint(env, id string) {
readInitAPP(env)
apiClient := client.NewEndpointAPI(addr, accessKey, secret)
log.Printf("#####################Delete Endpoint:%s#####################", id)
Expand Down
22 changes: 16 additions & 6 deletions cmd/begonia/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewEndpointDelCmd() *cobra.Command {
id, _ := cmd.Flags().GetString("id")
env, _ := cmd.Flags().GetString("env")

DeleteEndpoint(env,id)
DeleteEndpoint(env, id)
},
}
cmd.Flags().StringP("id", "i", "", "ID Of Your Service")
Expand All @@ -96,9 +96,9 @@ func NewEndpointAddCmd() *cobra.Command {
tags, _ := cmd.Flags().GetStringArray("tags")
balance, _ := cmd.Flags().GetString("balance")
endpoints, _ := cmd.Flags().GetStringArray("endpoint")
env,_:=cmd.Flags().GetString("env")
env, _ := cmd.Flags().GetString("env")

RegisterEndpoint(env,name, endpoints, desc, client.WithBalance(strings.ToUpper(balance)), client.WithTags(tags))
RegisterEndpoint(env, name, endpoints, desc, client.WithBalance(strings.ToUpper(balance)), client.WithTags(tags))
},
}
cmd = newWriteEndpointCmd(cmd)
Expand Down Expand Up @@ -134,7 +134,7 @@ func NewEndpointUpdateCmd() *cobra.Command {
options = append(options, client.WithName(name))
mask = append(mask, "name")
}

if cmd.Flags().Changed("desc") {
options = append(options, client.WithDescription(desc))
mask = append(mask, "description")
Expand All @@ -158,8 +158,8 @@ func NewEndpointUpdateCmd() *cobra.Command {
options = append(options, client.WithEndpoints(meta))
mask = append(mask, "endpoints")
}
env,_:=cmd.Flags().GetString("env")
UpdateEndpoint(env,id, mask, options...)
env, _ := cmd.Flags().GetString("env")
UpdateEndpoint(env, id, mask, options...)
},
}
cmd = newWriteEndpointCmd(cmd)
Expand Down Expand Up @@ -205,4 +205,14 @@ func main() {
if err := cmd.Execute(); err != nil {
log.Fatalf("failed to start begonia: %v", err)
}
// env, _ := cmd.Flags().GetString("env")
// cnf, err := cmd.Flags().GetString("config")
// if err != nil {
// log.Fatalf("failed to get config: %v", err)
// }
// config := config.ReadConfigWithDir("dev", "/data/work/begonia-org/begonia/config/settings.yml")
// worker := internal.New(config, gateway.Log, "127.0.0.1:12138")
// hd, _ := os.UserHomeDir()
// _ = os.WriteFile(hd+"/.begonia/gateway.json", []byte(fmt.Sprintf(`{"addr":"http://%s"}`, "127.0.0.1:12138")), 0666)
// worker.Start()
}
13 changes: 7 additions & 6 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ file:
engines:
- name: "FILE_ENGINE_MINIO"
endpoint: "127.0.0.1:9000"
accessKey: "7OdVJK1alV8cpRMeBLBW"
secretKey: "2GNNRqqElReC1KnV3kX9jSjyLU4kwOaTZEqDS2vH"
accessKey: "rLV2Jjj2UbMWSJOhTOtZ"
secretKey: "OVyJOILwx4iVE0EVJB4CKB65j7xlhjT5q1aGCv5t"
- name: "FILE_ENGINE_LOCAL"
endpoint: "/data/work/begonia-org/begonia/upload"
protos:
Expand Down Expand Up @@ -70,11 +70,12 @@ gateway:
- "example.com"
plugins:
local:
logger: 1
exception: 0
# 优先级越大越先执行
exception: 4
logger: 3
http: 2
params_validator: 3
auth: 4
auth: 1
params_validator: 0
# only_api_key_auth: 4
rpc:
# - server:
Expand Down
Loading
Loading