Skip to content

Commit

Permalink
feat: add env vars for all cli flags and add api-server help to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Jun 3, 2022
1 parent b19361d commit 07d9721
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 27 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ GLOBAL OPTIONS:
--version, -v print the version (default: false)
```

### API Server

```help
NAME:
main api-server - dockit api server
USAGE:
main api-server [command options] [arguments...]
OPTIONS:
--node-id value Unique ID of the Node (this should be increased for each replica) 0-1023 (1024 will select a random number between 0-1023) (default: 1024) [$DOCKIT_NODE_ID, $NODE_ID]
--pki-generate whether or not to generate PKI if false, you must specify --pki-file (default: true) [$DOCKIT_PKI_GENERATE, $PKI_GENERATE]
--pki-file value file to read PKI data from [$DOCKIT_PKI_FILE, $PKI_FILE]
--pki-key-type value Algorithm to use for PKI for Registry to Dockit authentication (default: "ec") [$DOCKIT_PKI_KEY_TYPE, $PKI_KEY_TYPE]
--pki-ec-key-size value Elliptic Curve Key Size (default: 256) [$DOCKIT_PKI_EC_KEY_SIZE, $PKI_EC_KEY_SIZE]
--pki-rsa-key-size value RSA Key Size (default: 4096) [$DOCKIT_PKI_RSA_KEY_SIZE, $PKI_RSA_KEY_SIZE]
--pki-cert-years value The number of years that internal PKI certs are good for. (default: 2) [$DOCKIT_PKI_CERT_YEARS, $PKI_CERT_YEARS]
--port value Port for the HTTP Server Port (default: 4315) [$DOCKIT_PORT, $PORT]
--metrics-port value Port for the metrics and debug http server to listen on (default: 4316) [$METRICS_PORT, $DOCKIT_METRICS_PORT]
--sql-dialect value The type of sql to use, sqlite or mysql (default: "sqlite") [$DOCKIT_SQL_DIALECT, $SQL_DIALECT]
--sql-dsn value The DSN to use to connect to (default: "file:dockit.sqlite") [$DOCKIT_SQL_DSN, $SQL_DSN]
--root-user value Root Username [$DOCKIT_ROOT_USER, $ROOT_USER]
--root-password value Root Password [$DOCKIT_ROOT_PASSWORD, $ROOT_PASSWORD]
--first-user-admin Indicates if the first user to login should be made an admin (default: true) [$DOCKIT_FIRST_USER_ADMIN, $FIRST_USER_ADMIN]
--log-level value, -l value Log Level (default: "info") [$LOGLEVEL]
--log-caller log the caller (aka line number and file) (default: false)
--log-disable-color disable log coloring (default: false)
--log-full-timestamp force log output to always show full timestamp (default: false)
--help, -h show help (default: false)
```

## API

Besides the token endpoint the registry uses to request tokens for authentication purposes, dockit comes with an admin API that can be used to manage users, groups, permissions and PKI data.
Expand Down
57 changes: 34 additions & 23 deletions pkg/commands/api-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,73 +97,84 @@ func init() {

flags := []cli.Flag{
&cli.IntFlag{
Name: "node-id",
Usage: "Unique ID of the Node (this should be increased for each replica) 0-1023 (1024 will select a random number between 0-1023)",
Value: 1024,
Name: "node-id",
Usage: "Unique ID of the Node (this should be increased for each replica) 0-1023 (1024 will select a random number between 0-1023)",
EnvVars: []string{"DOCKIT_NODE_ID", "NODE_ID"},
Value: 1024,
},
&cli.BoolFlag{
Name: "pki-generate",
Usage: "whether or not to generate PKI if false, you must specify --pki-file",
Value: true,
Name: "pki-generate",
Usage: "whether or not to generate PKI if false, you must specify --pki-file",
Value: true,
EnvVars: []string{"DOCKIT_PKI_GENERATE", "PKI_GENERATE"},
},
&cli.PathFlag{
Name: "pki-file",
Usage: "file to read PKI data from",
Name: "pki-file",
Usage: "file to read PKI data from",
EnvVars: []string{"DOCKIT_PKI_FILE", "PKI_FILE"},
},
&cli.StringFlag{
Name: "pki-key-type",
Value: "ec",
Name: "pki-key-type",
Usage: "Algorithm to use for PKI for Registry to Dockit authentication",
Value: "ec",
EnvVars: []string{"DOCKIT_PKI_KEY_TYPE", "PKI_KEY_TYPE"},
},
&cli.IntFlag{
Name: "pki-ec-key-size",
Value: 256,
Name: "pki-ec-key-size",
Usage: "Elliptic Curve Key Size",
Value: 256,
EnvVars: []string{"DOCKIT_PKI_EC_KEY_SIZE", "PKI_EC_KEY_SIZE"},
},
&cli.IntFlag{
Name: "pki-rsa-key-size",
Value: 4096,
Name: "pki-rsa-key-size",
Usage: "RSA Key Size",
Value: 4096,
EnvVars: []string{"DOCKIT_PKI_RSA_KEY_SIZE", "PKI_RSA_KEY_SIZE"},
},
&cli.IntFlag{
Name: "pki-cert-years",
Value: 2,
Name: "pki-cert-years",
Usage: "The number of years that internal PKI certs are good for.",
Value: 2,
EnvVars: []string{"DOCKIT_PKI_CERT_YEARS", "PKI_CERT_YEARS"},
},
&cli.IntFlag{
Name: "port",
Usage: "Port for the HTTP Server Port",
EnvVars: []string{"PORT"},
EnvVars: []string{"DOCKIT_PORT", "PORT"},
Value: 4315,
},
&cli.IntFlag{
Name: "metrics-port",
Usage: "Port for the metrics and debug http server to listen on",
EnvVars: []string{"METRICS_PORT", "API_SERVER_METRICS_PORT", "ODIN_API_SERVER_METRICS_PORT"},
EnvVars: []string{"METRICS_PORT", "DOCKIT_METRICS_PORT"},
Value: 4316,
},
&cli.StringFlag{
Name: "sql-dialect",
Usage: "The type of sql to use, sqlite or mysql",
EnvVars: []string{"SQL_DIALECT"},
EnvVars: []string{"DOCKIT_SQL_DIALECT", "SQL_DIALECT"},
Value: "sqlite",
},
&cli.StringFlag{
Name: "sql-dsn",
Usage: "The DSN to use to connect to",
EnvVars: []string{"SQL_DSN"},
EnvVars: []string{"DOCKIT_SQL_DSN", "SQL_DSN"},
Value: "file:dockit.sqlite",
},
&cli.StringFlag{
Name: "root-user",
Usage: "Root Username",
EnvVars: []string{"ROOT_USER"},
EnvVars: []string{"DOCKIT_ROOT_USER", "ROOT_USER"},
},
&cli.StringFlag{
Name: "root-password",
Usage: "Root Password",
EnvVars: []string{"ROOT_PASSWORD"},
EnvVars: []string{"DOCKIT_ROOT_PASSWORD", "ROOT_PASSWORD"},
},
&cli.BoolFlag{
Name: "first-user-admin",
Usage: "Indicates if the first user to login should be made an admin",
EnvVars: []string{"FIRST_USER_ADMIN"},
EnvVars: []string{"DOCKIT_FIRST_USER_ADMIN", "FIRST_USER_ADMIN"},
Value: true,
},
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/commands/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ func Flags() []cli.Flag {
Name: "log-full-timestamp",
Usage: "force log output to always show full timestamp",
},
&cli.StringFlag{
Name: "config",
Usage: "configuration file",
},
}

return globalFlags
Expand Down

0 comments on commit 07d9721

Please sign in to comment.