Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
c3f381c8
Commit
c3f381c8
authored
Aug 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add instance url to profile
parent
9a27fdf8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
42 deletions
+59
-42
main.go
bin/memos/main.go
+16
-18
apidocs.swagger.yaml
docs/apidocs.swagger.yaml
+3
-0
workspace_service.proto
proto/api/v1/workspace_service.proto
+2
-0
workspace_service.pb.go
proto/gen/api/v1/workspace_service.pb.go
+35
-24
profile.go
server/profile/profile.go
+2
-0
workspace_service.go
server/router/api/v1/workspace_service.go
+1
-0
No files found.
bin/memos/main.go
View file @
c3f381c8
...
...
@@ -44,6 +44,7 @@ var (
DSN
:
viper
.
GetString
(
"dsn"
),
Public
:
viper
.
GetBool
(
"public"
),
PasswordAuth
:
viper
.
GetBool
(
"password-auth"
),
InstanceURL
:
viper
.
GetString
(
"instance-url"
),
Version
:
version
.
GetCurrentVersion
(
viper
.
GetString
(
"mode"
)),
}
if
err
:=
instanceProfile
.
Validate
();
err
!=
nil
{
...
...
@@ -107,9 +108,7 @@ var (
func
init
()
{
viper
.
SetDefault
(
"mode"
,
"demo"
)
viper
.
SetDefault
(
"driver"
,
"sqlite"
)
viper
.
SetDefault
(
"addr"
,
""
)
viper
.
SetDefault
(
"port"
,
8081
)
viper
.
SetDefault
(
"public"
,
false
)
viper
.
SetDefault
(
"password-auth"
,
true
)
rootCmd
.
PersistentFlags
()
.
String
(
"mode"
,
"demo"
,
`mode of server, can be "prod" or "dev" or "demo"`
)
...
...
@@ -120,37 +119,33 @@ func init() {
rootCmd
.
PersistentFlags
()
.
String
(
"dsn"
,
""
,
"database source name(aka. DSN)"
)
rootCmd
.
PersistentFlags
()
.
Bool
(
"public"
,
false
,
""
)
rootCmd
.
PersistentFlags
()
.
Bool
(
"password-auth"
,
true
,
""
)
rootCmd
.
PersistentFlags
()
.
String
(
"instance-url"
,
""
,
"the url of your memos instance"
)
err
:=
viper
.
BindPFlag
(
"mode"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"mode"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"mode"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"mode"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"addr"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"addr"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"addr"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"addr"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"port"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"port"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"port"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"port"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"data"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"data"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"data"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"data"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"driver"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"driver"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"driver"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"driver"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"dsn"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"dsn"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"dsn"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"dsn"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"public"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"public"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"public"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"public"
));
err
!=
nil
{
panic
(
err
)
}
err
=
viper
.
BindPFlag
(
"password-auth"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"password-auth"
))
if
err
!=
nil
{
if
err
:=
viper
.
BindPFlag
(
"password-auth"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"password-auth"
));
err
!=
nil
{
panic
(
err
)
}
if
err
:=
viper
.
BindPFlag
(
"instance-url"
,
rootCmd
.
PersistentFlags
()
.
Lookup
(
"instance-url"
));
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -159,6 +154,9 @@ func init() {
if
err
:=
viper
.
BindEnv
(
"password-auth"
,
"MEMOS_PASSWORD_AUTH"
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
viper
.
BindEnv
(
"instance-url"
,
"MEMOS_INSTANCE_URL"
);
err
!=
nil
{
panic
(
err
)
}
}
func
printGreetings
(
profile
*
profile
.
Profile
)
{
...
...
docs/apidocs.swagger.yaml
View file @
c3f381c8
...
...
@@ -3154,3 +3154,6 @@ definitions:
passwordAuth
:
type
:
boolean
description
:
password_auth is a flag whether the instance allows password authentication.
instanceUrl
:
type
:
string
description
:
instance_url is the URL of the instance.
proto/api/v1/workspace_service.proto
View file @
c3f381c8
...
...
@@ -25,6 +25,8 @@ message WorkspaceProfile {
bool
public
=
4
;
// password_auth is a flag whether the instance allows password authentication.
bool
password_auth
=
5
;
// instance_url is the URL of the instance.
string
instance_url
=
6
;
}
message
GetWorkspaceProfileRequest
{}
proto/gen/api/v1/workspace_service.pb.go
View file @
c3f381c8
...
...
@@ -37,6 +37,8 @@ type WorkspaceProfile struct {
Public
bool
`protobuf:"varint,4,opt,name=public,proto3" json:"public,omitempty"`
// password_auth is a flag whether the instance allows password authentication.
PasswordAuth
bool
`protobuf:"varint,5,opt,name=password_auth,json=passwordAuth,proto3" json:"password_auth,omitempty"`
// instance_url is the URL of the instance.
InstanceUrl
string
`protobuf:"bytes,6,opt,name=instance_url,json=instanceUrl,proto3" json:"instance_url,omitempty"`
}
func
(
x
*
WorkspaceProfile
)
Reset
()
{
...
...
@@ -106,6 +108,13 @@ func (x *WorkspaceProfile) GetPasswordAuth() bool {
return
false
}
func
(
x
*
WorkspaceProfile
)
GetInstanceUrl
()
string
{
if
x
!=
nil
{
return
x
.
InstanceUrl
}
return
""
}
type
GetWorkspaceProfileRequest
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
...
...
@@ -151,7 +160,7 @@ var file_api_v1_workspace_service_proto_rawDesc = []byte{
0x63
,
0x65
,
0x5f
,
0x73
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x1a
,
0x1c
,
0x67
,
0x6f
,
0x6f
,
0x67
,
0x6c
,
0x65
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x61
,
0x6e
,
0x6e
,
0x6f
,
0x74
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x
93
,
0x01
,
0x0a
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x
b6
,
0x01
,
0x0a
,
0x10
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x6f
,
0x77
,
0x6e
,
0x65
,
0x72
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x05
,
0x6f
,
0x77
,
0x6e
,
0x65
,
0x72
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
...
...
@@ -161,30 +170,32 @@ var file_api_v1_workspace_service_proto_rawDesc = []byte{
0x04
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x06
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x12
,
0x23
,
0x0a
,
0x0d
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x5f
,
0x61
,
0x75
,
0x74
,
0x68
,
0x18
,
0x05
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x0c
,
0x70
,
0x61
,
0x73
,
0x73
,
0x77
,
0x6f
,
0x72
,
0x64
,
0x41
,
0x75
,
0x74
,
0x68
,
0x
22
,
0x1c
,
0x0a
,
0x1a
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x
63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x
32
,
0x97
,
0x01
,
0x0a
,
0x10
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x7
2
,
0x76
,
0x69
,
0x63
,
0x65
,
0x12
,
0x82
,
0x01
,
0x0a
,
0x13
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6
b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x12
,
0x28
,
0x2e
,
0x6
d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x2e
,
0x47
,
0x65
,
0x74
,
0x74
,
0x68
,
0x
12
,
0x21
,
0x0a
,
0x0c
,
0x69
,
0x6e
,
0x73
,
0x74
,
0x61
,
0x6e
,
0x63
,
0x65
,
0x5f
,
0x75
,
0x
72
,
0x6c
,
0x18
,
0x06
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0b
,
0x69
,
0x6e
,
0x73
,
0x74
,
0x61
,
0x6e
,
0x
63
,
0x65
,
0x55
,
0x72
,
0x6c
,
0x22
,
0x1c
,
0x0a
,
0x1a
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x7
3
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x6
5
,
0x73
,
0x74
,
0x32
,
0x97
,
0x01
,
0x0a
,
0x10
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x6
5
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x12
,
0x82
,
0x01
,
0x0a
,
0x13
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x1a
,
0x1e
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x2e
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x22
,
0x21
,
0x82
,
0xd3
,
0xe4
,
0x93
,
0x02
,
0x1b
,
0x12
,
0x19
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x31
,
0x2f
,
0x77
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x42
,
0xad
,
0x01
,
0x0a
,
0x10
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x42
,
0x15
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x30
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x31
,
0x3b
,
0x61
,
0x70
,
0x69
,
0x76
,
0x31
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x41
,
0x58
,
0xaa
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x41
,
0x70
,
0x69
,
0x2e
,
0x56
,
0x31
,
0xca
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x31
,
0xe2
,
0x02
,
0x18
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x31
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0e
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x41
,
0x70
,
0x69
,
0x3a
,
0x3a
,
0x56
,
0x31
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
0x12
,
0x28
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x2e
,
0x47
,
0x65
,
0x74
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x1a
,
0x1e
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x2e
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x22
,
0x21
,
0x82
,
0xd3
,
0xe4
,
0x93
,
0x02
,
0x1b
,
0x12
,
0x19
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x31
,
0x2f
,
0x77
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x42
,
0xad
,
0x01
,
0x0a
,
0x10
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x31
,
0x42
,
0x15
,
0x57
,
0x6f
,
0x72
,
0x6b
,
0x73
,
0x70
,
0x61
,
0x63
,
0x65
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x30
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x31
,
0x3b
,
0x61
,
0x70
,
0x69
,
0x76
,
0x31
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x41
,
0x58
,
0xaa
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x41
,
0x70
,
0x69
,
0x2e
,
0x56
,
0x31
,
0xca
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x31
,
0xe2
,
0x02
,
0x18
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x31
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0e
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x41
,
0x70
,
0x69
,
0x3a
,
0x3a
,
0x56
,
0x31
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
(
...
...
server/profile/profile.go
View file @
c3f381c8
...
...
@@ -31,6 +31,8 @@ type Profile struct {
Public
bool
// PasswordAuth is the flag whether the instance uses password authentication.
PasswordAuth
bool
// InstanceURL is the url of your memos instance.
InstanceURL
string
}
func
(
p
*
Profile
)
IsDev
()
bool
{
...
...
server/router/api/v1/workspace_service.go
View file @
c3f381c8
...
...
@@ -17,6 +17,7 @@ func (s *APIV1Service) GetWorkspaceProfile(ctx context.Context, _ *v1pb.GetWorks
Mode
:
s
.
Profile
.
Mode
,
Public
:
s
.
Profile
.
Public
,
PasswordAuth
:
s
.
Profile
.
PasswordAuth
,
InstanceUrl
:
s
.
Profile
.
InstanceURL
,
}
owner
,
err
:=
s
.
GetInstanceOwner
(
ctx
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment