Skip to content

Commit

Permalink
Updated flags from camelCase to kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinmwinuka committed Feb 25, 2024
1 parent 76c4226 commit 5e1e362
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 39 deletions.
39 changes: 20 additions & 19 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@ COPY ./openssl/client /etc/ssl/certs/echovault/client
WORKDIR /opt/echovault/bin

CMD "./server" \
"--bindAddr" "${BIND_ADDR}" \
"--bind-addr" "${BIND_ADDR}" \
"--port" "${PORT}" \
"--mlPort" "${ML_PORT}" \
"--raftPort" "${RAFT_PORT}" \
"--serverId" "${SERVER_ID}" \
"--joinAddr" "${JOIN_ADDR}" \
"--pluginDir" "${PLUGIN_DIR}" \
"--dataDir" "${DATA_DIR}" \
"--snapshotThreshold" "${SNAPSHOT_THRESHOLD}" \
"--snapshotInterval" "${SNAPSHOT_INTERVAL}" \
"--memberlist-port" "${ML_PORT}" \
"--raft-port" "${RAFT_PORT}" \
"--server-id" "${SERVER_ID}" \
"--join-addr" "${JOIN_ADDR}" \
"--plugin-dir" "${PLUGIN_DIR}" \
"--data-dir" "${DATA_DIR}" \
"--snapshot-threshold" "${SNAPSHOT_THRESHOLD}" \
"--snapshot-interval" "${SNAPSHOT_INTERVAL}" \
"--tls=${TLS}" \
"--mtls=${MTLS}" \
"--inMemory=${IN_MEMORY}" \
"--bootstrapCluster=${BOOTSTRAP_CLUSTER}" \
"--aclConfig=${ACL_CONFIG}" \
"--requirePass=${REQUIRE_PASS}" \
"--in-memory=${IN_MEMORY}" \
"--bootstrap-cluster=${BOOTSTRAP_CLUSTER}" \
"--acl-config=${ACL_CONFIG}" \
"--require-pass=${REQUIRE_PASS}" \
"--password=${PASSWORD}" \
"--forwardCommand=${FORWARD_COMMAND}" \
"--restoreSnapshot=${RESTORE_SNAPSHOT}" \
"--restoreAOF=${RESTORE_AOF}" \
"--forward-commands=${FORWARD_COMMAND}" \
"--restore-snapshot=${RESTORE_SNAPSHOT}" \
"--restore-aof=${RESTORE_AOF}" \
"--aof-sync-strategy=${AOF_SYNC_STRATEGY}" \
# List of server cert/key pairs
"--certKeyPair=${CERT_KEY_PAIR_1}" \
"--certKeyPair=${CERT_KEY_PAIR_2}" \
"--cert-key-pair=${CERT_KEY_PAIR_1}" \
"--cert-key-pair=${CERT_KEY_PAIR_2}" \
# List of client certs
"--clientCA=${CLIENT_CA_1}" \
"--client-ca=${CLIENT_CA_1}" \
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=true
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down Expand Up @@ -69,6 +70,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=false
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down Expand Up @@ -110,6 +112,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=false
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down Expand Up @@ -151,6 +154,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=false
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down Expand Up @@ -192,6 +196,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=false
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down Expand Up @@ -233,6 +238,7 @@ services:
- SNAPSHOT_INTERVAL=5m30s
- RESTORE_SNAPSHOT=false
- RESTORE_AOF=false
- AOF_SYNC_STRATEGY=everysec
# List of server cert/key pairs
- CERT_KEY_PAIR_1=/etc/ssl/certs/echovault/server/server1.crt,/etc/ssl/certs/echovault/server/server1.key
- CERT_KEY_PAIR_2=/etc/ssl/certs/echovault/server/server2.crt,/etc/ssl/certs/echovault/server/server2.key
Expand Down
40 changes: 20 additions & 20 deletions src/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetConfig() (Config, error) {
var certKeyPairs [][]string
var clientCAs []string

flag.Func("certKeyPair",
flag.Func("cert-key-pair",
"A pair of file paths representing the signed certificate and it's corresponding key separated by a comma.",
func(s string) error {
pair := strings.Split(strings.TrimSpace(s), ",")
Expand All @@ -58,13 +58,13 @@ func GetConfig() (Config, error) {
return nil
})

flag.Func("clientCA", "Path to certificate authority used to verify client certificates.", func(s string) error {
flag.Func("client-ca", "Path to certificate authority used to verify client certificates.", func(s string) error {
clientCAs = append(clientCAs, s)
return nil
})

var aofSyncStrategy string = "everysec"
flag.Func("aofSyncStrategy", `How often to flush the file contents written to append only file.
aofSyncStrategy := "everysec"
flag.Func("aof-sync-strategy", `How often to flush the file contents written to append only file.
The options are 'always' for syncing on each command, 'everysec' to sync every second, and 'no' to leave it up to the os.`,
func(option string) error {
if !slices.ContainsFunc([]string{"always", "everysec", "no"}, func(s string) bool {
Expand All @@ -79,26 +79,26 @@ The options are 'always' for syncing on each command, 'everysec' to sync every s
tls := flag.Bool("tls", false, "Start the server in TLS mode. Default is false")
mtls := flag.Bool("mtls", false, "Use mTLS to verify the client.")
port := flag.Int("port", 7480, "Port to use. Default is 7480")
pluginDir := flag.String("pluginDir", "", "Directory where plugins are located.")
serverId := flag.String("serverId", "1", "Server ID in raft cluster. Leave empty for client.")
joinAddr := flag.String("joinAddr", "", "Address of cluster member in a cluster to you want to join.")
bindAddr := flag.String("bindAddr", "", "Address to bind the server to.")
raftBindPort := flag.Uint("raftPort", 7481, "Port to use for intra-cluster communication. Leave on the client.")
mlBindPort := flag.Uint("mlPort", 7946, "Port to use for memberlist communication.")
inMemory := flag.Bool("inMemory", false, "Whether to use memory or persistent storage for raft logs and snapshots.")
dataDir := flag.String("dataDir", "/var/lib/memstore", "Directory to store raft snapshots and logs.")
bootstrapCluster := flag.Bool("bootstrapCluster", false, "Whether this instance should bootstrap a new cluster.")
aclConfig := flag.String("aclConfig", "", "ACL config file path.")
snapshotThreshold := flag.Uint64("snapshotThreshold", 1000, "The number of entries that trigger a snapshot. Default is 1000.")
snapshotInterval := flag.Duration("snapshotInterval", 5*time.Minute, "The time interval between snapshots (in seconds). Default is 5 minutes.")
restoreSnapshot := flag.Bool("restoreSnapshot", false, "This flag prompts the server to restore state from snapshot when set to true. Only works in standalone mode. Higher priority than restoreAOF.")
restoreAOF := flag.Bool("restoreAOF", false, "This flag prompts the server to restore state from append-only logs. Only works in standalone mode. Lower priority than restoreSnapshot.")
pluginDir := flag.String("plugin-dir", "", "Directory where plugins are located.")
serverId := flag.String("server-id", "1", "Server ID in raft cluster. Leave empty for client.")
joinAddr := flag.String("join-addr", "", "Address of cluster member in a cluster to you want to join.")
bindAddr := flag.String("bind-addr", "", "Address to bind the server to.")
raftBindPort := flag.Uint("raft-port", 7481, "Port to use for intra-cluster communication. Leave on the client.")
mlBindPort := flag.Uint("memberlist-port", 7946, "Port to use for memberlist communication.")
inMemory := flag.Bool("in-memory", false, "Whether to use memory or persistent storage for raft logs and snapshots.")
dataDir := flag.String("data-dir", "/var/lib/memstore", "Directory to store raft snapshots and logs.")
bootstrapCluster := flag.Bool("bootstrap-cluster", false, "Whether this instance should bootstrap a new cluster.")
aclConfig := flag.String("acl-config", "", "ACL config file path.")
snapshotThreshold := flag.Uint64("snapshot-threshold", 1000, "The number of entries that trigger a snapshot. Default is 1000.")
snapshotInterval := flag.Duration("snapshot-interval", 5*time.Minute, "The time interval between snapshots (in seconds). Default is 5 minutes.")
restoreSnapshot := flag.Bool("restore-snapshot", false, "This flag prompts the server to restore state from snapshot when set to true. Only works in standalone mode. Higher priority than restoreAOF.")
restoreAOF := flag.Bool("restore-aof", false, "This flag prompts the server to restore state from append-only logs. Only works in standalone mode. Lower priority than restoreSnapshot.")
forwardCommand := flag.Bool(
"forwardCommand",
"forward-commands",
false,
"If the node is a follower, this flag forwards mutation command to the leader when set to true")
requirePass := flag.Bool(
"requirePass",
"require-pass",
false,
"Whether the server should require a password before allowing commands. Default is false.",
)
Expand Down

0 comments on commit 5e1e362

Please sign in to comment.