Skip to content

Commit 3be0b4d

Browse files
committed
convert to v2
1 parent 88c1432 commit 3be0b4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+10475
-4633
lines changed

cmd/admin.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import (
2020
repo_module "code.gitea.io/gitea/modules/repository"
2121
"code.gitea.io/gitea/modules/setting"
2222

23-
"github.com/urfave/cli"
23+
"github.com/urfave/cli/v2"
2424
)
2525

2626
var (
2727
// CmdAdmin represents the available admin sub-command.
2828
CmdAdmin = cli.Command{
2929
Name: "admin",
3030
Usage: "Command line interface to perform common administrative operations",
31-
Subcommands: []cli.Command{
32-
subcmdCreateUser,
33-
subcmdChangePassword,
34-
subcmdRepoSyncReleases,
35-
subcmdRegenerate,
36-
subcmdAuth,
31+
Subcommands: []*cli.Command{
32+
&subcmdCreateUser,
33+
&subcmdChangePassword,
34+
&subcmdRepoSyncReleases,
35+
&subcmdRegenerate,
36+
&subcmdAuth,
3737
},
3838
}
3939

@@ -42,40 +42,40 @@ var (
4242
Usage: "Create a new user in database",
4343
Action: runCreateUser,
4444
Flags: []cli.Flag{
45-
cli.StringFlag{
45+
&cli.StringFlag{
4646
Name: "name",
4747
Usage: "Username. DEPRECATED: use username instead",
4848
},
49-
cli.StringFlag{
49+
&cli.StringFlag{
5050
Name: "username",
5151
Usage: "Username",
5252
},
53-
cli.StringFlag{
53+
&cli.StringFlag{
5454
Name: "password",
5555
Usage: "User password",
5656
},
57-
cli.StringFlag{
57+
&cli.StringFlag{
5858
Name: "email",
5959
Usage: "User email address",
6060
},
61-
cli.BoolFlag{
61+
&cli.BoolFlag{
6262
Name: "admin",
6363
Usage: "User is an admin",
6464
},
65-
cli.BoolFlag{
65+
&cli.BoolFlag{
6666
Name: "random-password",
6767
Usage: "Generate a random password for the user",
6868
},
69-
cli.BoolFlag{
69+
&cli.BoolFlag{
7070
Name: "must-change-password",
7171
Usage: "Set this option to false to prevent forcing the user to change their password after initial login, (Default: true)",
7272
},
73-
cli.IntFlag{
73+
&cli.IntFlag{
7474
Name: "random-password-length",
7575
Usage: "Length of the random password to be generated",
7676
Value: 12,
7777
},
78-
cli.BoolFlag{
78+
&cli.BoolFlag{
7979
Name: "access-token",
8080
Usage: "Generate access token for the user",
8181
},
@@ -87,12 +87,12 @@ var (
8787
Usage: "Change a user's password",
8888
Action: runChangePassword,
8989
Flags: []cli.Flag{
90-
cli.StringFlag{
90+
&cli.StringFlag{
9191
Name: "username,u",
9292
Value: "",
9393
Usage: "The user to change password for",
9494
},
95-
cli.StringFlag{
95+
&cli.StringFlag{
9696
Name: "password,p",
9797
Value: "",
9898
Usage: "New password to set for user",
@@ -109,9 +109,9 @@ var (
109109
subcmdRegenerate = cli.Command{
110110
Name: "regenerate",
111111
Usage: "Regenerate specific files",
112-
Subcommands: []cli.Command{
113-
microcmdRegenHooks,
114-
microcmdRegenKeys,
112+
Subcommands: []*cli.Command{
113+
&microcmdRegenHooks,
114+
&microcmdRegenKeys,
115115
},
116116
}
117117

@@ -130,15 +130,15 @@ var (
130130
subcmdAuth = cli.Command{
131131
Name: "auth",
132132
Usage: "Modify external auth providers",
133-
Subcommands: []cli.Command{
134-
microcmdAuthAddOauth,
135-
microcmdAuthUpdateOauth,
136-
cmdAuthAddLdapBindDn,
137-
cmdAuthUpdateLdapBindDn,
138-
cmdAuthAddLdapSimpleAuth,
139-
cmdAuthUpdateLdapSimpleAuth,
140-
microcmdAuthList,
141-
microcmdAuthDelete,
133+
Subcommands: []*cli.Command{
134+
&microcmdAuthAddOauth,
135+
&microcmdAuthUpdateOauth,
136+
&cmdAuthAddLdapBindDn,
137+
&cmdAuthUpdateLdapBindDn,
138+
&cmdAuthAddLdapSimpleAuth,
139+
&cmdAuthUpdateLdapSimpleAuth,
140+
&microcmdAuthList,
141+
&microcmdAuthDelete,
142142
},
143143
}
144144

@@ -147,27 +147,27 @@ var (
147147
Usage: "List auth sources",
148148
Action: runListAuth,
149149
Flags: []cli.Flag{
150-
cli.IntFlag{
150+
&cli.IntFlag{
151151
Name: "min-width",
152152
Usage: "Minimal cell width including any padding for the formatted table",
153153
Value: 0,
154154
},
155-
cli.IntFlag{
155+
&cli.IntFlag{
156156
Name: "tab-width",
157157
Usage: "width of tab characters in formatted table (equivalent number of spaces)",
158158
Value: 8,
159159
},
160-
cli.IntFlag{
160+
&cli.IntFlag{
161161
Name: "padding",
162162
Usage: "padding added to a cell before computing its width",
163163
Value: 1,
164164
},
165-
cli.StringFlag{
165+
&cli.StringFlag{
166166
Name: "pad-char",
167167
Usage: `ASCII char used for padding if padchar == '\\t', the Writer will assume that the width of a '\\t' in the formatted output is tabwidth, and cells are left-aligned independent of align_left (for correct-looking results, tabwidth must correspond to the tab width in the viewer displaying the result)`,
168168
Value: "\t",
169169
},
170-
cli.BoolFlag{
170+
&cli.BoolFlag{
171171
Name: "vertical-bars",
172172
Usage: "Set to true to print vertical bars between columns",
173173
},
@@ -182,57 +182,57 @@ var (
182182
microcmdAuthDelete = cli.Command{
183183
Name: "delete",
184184
Usage: "Delete specific auth source",
185-
Flags: []cli.Flag{idFlag},
185+
Flags: []cli.Flag{&idFlag},
186186
Action: runDeleteAuth,
187187
}
188188

189189
oauthCLIFlags = []cli.Flag{
190-
cli.StringFlag{
190+
&cli.StringFlag{
191191
Name: "name",
192192
Value: "",
193193
Usage: "Application Name",
194194
},
195-
cli.StringFlag{
195+
&cli.StringFlag{
196196
Name: "provider",
197197
Value: "",
198198
Usage: "OAuth2 Provider",
199199
},
200-
cli.StringFlag{
200+
&cli.StringFlag{
201201
Name: "key",
202202
Value: "",
203203
Usage: "Client ID (Key)",
204204
},
205-
cli.StringFlag{
205+
&cli.StringFlag{
206206
Name: "secret",
207207
Value: "",
208208
Usage: "Client Secret",
209209
},
210-
cli.StringFlag{
210+
&cli.StringFlag{
211211
Name: "auto-discover-url",
212212
Value: "",
213213
Usage: "OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider)",
214214
},
215-
cli.StringFlag{
215+
&cli.StringFlag{
216216
Name: "use-custom-urls",
217217
Value: "false",
218218
Usage: "Use custom URLs for GitLab/GitHub OAuth endpoints",
219219
},
220-
cli.StringFlag{
220+
&cli.StringFlag{
221221
Name: "custom-auth-url",
222222
Value: "",
223223
Usage: "Use a custom Authorization URL (option for GitLab/GitHub)",
224224
},
225-
cli.StringFlag{
225+
&cli.StringFlag{
226226
Name: "custom-token-url",
227227
Value: "",
228228
Usage: "Use a custom Token URL (option for GitLab/GitHub)",
229229
},
230-
cli.StringFlag{
230+
&cli.StringFlag{
231231
Name: "custom-profile-url",
232232
Value: "",
233233
Usage: "Use a custom Profile URL (option for GitLab/GitHub)",
234234
},
235-
cli.StringFlag{
235+
&cli.StringFlag{
236236
Name: "custom-email-url",
237237
Value: "",
238238
Usage: "Use a custom Email URL (option for GitHub)",
@@ -243,7 +243,7 @@ var (
243243
Name: "update-oauth",
244244
Usage: "Update existing Oauth authentication source",
245245
Action: runUpdateOauth,
246-
Flags: append(oauthCLIFlags[:1], append([]cli.Flag{idFlag}, oauthCLIFlags[1:]...)...),
246+
Flags: append(oauthCLIFlags[:1], append([]cli.Flag{&idFlag}, oauthCLIFlags[1:]...)...),
247247
}
248248

249249
microcmdAuthAddOauth = cli.Command{

cmd/admin_auth_ldap.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"code.gitea.io/gitea/models"
1212
"code.gitea.io/gitea/modules/auth/ldap"
1313

14-
"github.com/urfave/cli"
14+
"github.com/urfave/cli/v2"
1515
)
1616

1717
type (
@@ -25,96 +25,96 @@ type (
2525

2626
var (
2727
commonLdapCLIFlags = []cli.Flag{
28-
cli.StringFlag{
28+
&cli.StringFlag{
2929
Name: "name",
3030
Usage: "Authentication name.",
3131
},
32-
cli.BoolFlag{
32+
&cli.BoolFlag{
3333
Name: "not-active",
3434
Usage: "Deactivate the authentication source.",
3535
},
36-
cli.StringFlag{
36+
&cli.StringFlag{
3737
Name: "security-protocol",
3838
Usage: "Security protocol name.",
3939
},
40-
cli.BoolFlag{
40+
&cli.BoolFlag{
4141
Name: "skip-tls-verify",
4242
Usage: "Disable TLS verification.",
4343
},
44-
cli.StringFlag{
44+
&cli.StringFlag{
4545
Name: "host",
4646
Usage: "The address where the LDAP server can be reached.",
4747
},
48-
cli.IntFlag{
48+
&cli.IntFlag{
4949
Name: "port",
5050
Usage: "The port to use when connecting to the LDAP server.",
5151
},
52-
cli.StringFlag{
52+
&cli.StringFlag{
5353
Name: "user-search-base",
5454
Usage: "The LDAP base at which user accounts will be searched for.",
5555
},
56-
cli.StringFlag{
56+
&cli.StringFlag{
5757
Name: "user-filter",
5858
Usage: "An LDAP filter declaring how to find the user record that is attempting to authenticate.",
5959
},
60-
cli.StringFlag{
60+
&cli.StringFlag{
6161
Name: "admin-filter",
6262
Usage: "An LDAP filter specifying if a user should be given administrator privileges.",
6363
},
64-
cli.StringFlag{
64+
&cli.StringFlag{
6565
Name: "restricted-filter",
6666
Usage: "An LDAP filter specifying if a user should be given restricted status.",
6767
},
68-
cli.BoolFlag{
68+
&cli.BoolFlag{
6969
Name: "allow-deactivate-all",
7070
Usage: "Allow empty search results to deactivate all users.",
7171
},
72-
cli.StringFlag{
72+
&cli.StringFlag{
7373
Name: "username-attribute",
7474
Usage: "The attribute of the user’s LDAP record containing the user name.",
7575
},
76-
cli.StringFlag{
76+
&cli.StringFlag{
7777
Name: "firstname-attribute",
7878
Usage: "The attribute of the user’s LDAP record containing the user’s first name.",
7979
},
80-
cli.StringFlag{
80+
&cli.StringFlag{
8181
Name: "surname-attribute",
8282
Usage: "The attribute of the user’s LDAP record containing the user’s surname.",
8383
},
84-
cli.StringFlag{
84+
&cli.StringFlag{
8585
Name: "email-attribute",
8686
Usage: "The attribute of the user’s LDAP record containing the user’s email address.",
8787
},
88-
cli.StringFlag{
88+
&cli.StringFlag{
8989
Name: "public-ssh-key-attribute",
9090
Usage: "The attribute of the user’s LDAP record containing the user’s public ssh key.",
9191
},
9292
}
9393

9494
ldapBindDnCLIFlags = append(commonLdapCLIFlags,
95-
cli.StringFlag{
95+
&cli.StringFlag{
9696
Name: "bind-dn",
9797
Usage: "The DN to bind to the LDAP server with when searching for the user.",
9898
},
99-
cli.StringFlag{
99+
&cli.StringFlag{
100100
Name: "bind-password",
101101
Usage: "The password for the Bind DN, if any.",
102102
},
103-
cli.BoolFlag{
103+
&cli.BoolFlag{
104104
Name: "attributes-in-bind",
105105
Usage: "Fetch attributes in bind DN context.",
106106
},
107-
cli.BoolFlag{
107+
&cli.BoolFlag{
108108
Name: "synchronize-users",
109109
Usage: "Enable user synchronization.",
110110
},
111-
cli.UintFlag{
111+
&cli.UintFlag{
112112
Name: "page-size",
113113
Usage: "Search page size.",
114114
})
115115

116116
ldapSimpleAuthCLIFlags = append(commonLdapCLIFlags,
117-
cli.StringFlag{
117+
&cli.StringFlag{
118118
Name: "user-dn",
119119
Usage: "The user’s DN.",
120120
})
@@ -134,7 +134,7 @@ var (
134134
Action: func(c *cli.Context) error {
135135
return newAuthService().updateLdapBindDn(c)
136136
},
137-
Flags: append([]cli.Flag{idFlag}, ldapBindDnCLIFlags...),
137+
Flags: append([]cli.Flag{&idFlag}, ldapBindDnCLIFlags...),
138138
}
139139

140140
cmdAuthAddLdapSimpleAuth = cli.Command{
@@ -152,7 +152,7 @@ var (
152152
Action: func(c *cli.Context) error {
153153
return newAuthService().updateLdapSimpleAuth(c)
154154
},
155-
Flags: append([]cli.Flag{idFlag}, ldapSimpleAuthCLIFlags...),
155+
Flags: append([]cli.Flag{&idFlag}, ldapSimpleAuthCLIFlags...),
156156
}
157157
)
158158

cmd/admin_auth_ldap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/auth/ldap"
1212

1313
"github.com/stretchr/testify/assert"
14-
"github.com/urfave/cli"
14+
"github.com/urfave/cli/v2"
1515
)
1616

1717
func TestAddLdapBindDn(t *testing.T) {

0 commit comments

Comments
 (0)