Repository: codenotary/immudb
File: cmd/immudb/command/init.go (Go)

Code before:
	cmd.Flags().BoolP(c.DetachedFlag, c.DetachedShortFlag, options.Detached, "run immudb in background")
	cmd.Flags().String("certificate", "", "server certificate file path")
	cmd.Flags().String("pkey", "", "server private key path")
	cmd.Flags().String("clientcas", "", "clients certificates list. Aka certificate authority")
	cmd.Flags().Bool("devmode", options.DevMode, "enable dev mode: accept remote connections without auth")
	cmd.Flags().String("admin-password", options.AdminPassword, "admin password (default is 'immudb') as plain-text or base64 encoded (must be prefixed with 'enc:' if it is encoded)")
	cmd.Flags().Bool("force-admin-password", false, "if true, reset the admin password to the one passed through admin-password option upon startup")
	cmd.Flags().Bool("maintenance", options.GetMaintenance(), "override the authentication flag")
	cmd.Flags().String("signingKey", options.SigningKey, "signature private key path. If a valid one is provided, it enables the cryptographic signature of the root. e.g. \"./../test/signer/ec3.key\"")
	cmd.Flags().Bool("synced", true, "synced mode prevents data lost under unexpected crashes but affects performance")
	cmd.Flags().Int("token-expiry-time", options.TokenExpiryTimeMin, "client authentication token expiration time. Minutes")
	cmd.Flags().Bool("metrics-server", options.MetricsServer, "enable or disable Prometheus endpoint")
	cmd.Flags().Int("metrics-server-port", options.MetricsServerPort, "Prometheus endpoint port")
	cmd.Flags().Bool("web-server", options.WebServer, "enable or disable web/console server")
	cmd.Flags().Int("web-server-port", options.WebServerPort, "web/console server port")
	cmd.Flags().Bool("pgsql-server", true, "enable or disable pgsql server")
	cmd.Flags().Int("pgsql-server-port", 5432, "pgsql server port")
	cmd.Flags().Bool("pprof", false, "add pprof profiling endpoint on the metrics server")
	cmd.Flags().Bool("s3-storage", false, "enable or disable s3 storage")
	cmd.Flags().String("s3-endpoint", "", "s3 endpoint")
	cmd.Flags().String("s3-access-key-id", "", "s3 access key id")
	cmd.Flags().String("s3-secret-key", "", "s3 secret access key")
	cmd.Flags().String("s3-bucket-name", "", "s3 bucket name")
	cmd.Flags().String("s3-location", "", "s3 location (region)")
	cmd.Flags().String("s3-path-prefix", "", "s3 path prefix (multiple immudb instances can share the same bucket if they have different prefixes)")
	cmd.Flags().Bool("s3-external-identifier", false, "use external identifier over the local")
	cmd.Flags().Int("max-sessions", 100, "maximum number of simultaneously opened sessions")
	cmd.Flags().Duration("max-session-inactivity-time", 3*time.Minute, "max session inactivity time is a duration after which an active session is declared inactive by the server. A session is kept active if server is still receiving requests from client (keep-alive or other methods)")
	cmd.Flags().Duration("max-session-age-time", 0, "the current default value is infinity. max session age time is a duration after which session will be forcibly closed")
	cmd.Flags().Duration("session-timeout", 2*time.Minute, "session timeout is a duration after which an inactive session is forcibly closed by the server")
	cmd.Flags().Duration("sessions-guard-check-interval", 1*time.Minute, "sessions guard check interval")
	cmd.Flags().MarkHidden("sessions-guard-check-interval")
	cmd.Flags().Bool("grpc-reflection", options.GRPCReflectionServerEnabled, "GRPC reflection server enabled")

	flagNameMapping := map[string]string{
		"replication-enabled":           "replication-is-replica",
		"replication-follower-username": "replication-primary-username",
		"replication-follower-password": "replication-primary-password",
		"replication-master-database":   "replication-primary-database",
		"replication-master-address":    "replication-primary-host",
		"replication-master-port":       "replication-primary-port",
	}

	cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
		if newName, ok := flagNameMapping[name]; ok {
			name = newName
		}
		return pflag.NormalizedName(name)
	})
}


Review comment (suggestion):
```suggestion
	cmd.Flags().Bool("s3-external-identifier", false, "use the remote identifier if there is no local identifier")
```

Code after:
	cmd.Flags().BoolP(c.DetachedFlag, c.DetachedShortFlag, options.Detached, "run immudb in background")
	cmd.Flags().String("certificate", "", "server certificate file path")
	cmd.Flags().String("pkey", "", "server private key path")
	cmd.Flags().String("clientcas", "", "clients certificates list. Aka certificate authority")
	cmd.Flags().Bool("devmode", options.DevMode, "enable dev mode: accept remote connections without auth")
	cmd.Flags().String("admin-password", options.AdminPassword, "admin password (default is 'immudb') as plain-text or base64 encoded (must be prefixed with 'enc:' if it is encoded)")
	cmd.Flags().Bool("force-admin-password", false, "if true, reset the admin password to the one passed through admin-password option upon startup")
	cmd.Flags().Bool("maintenance", options.GetMaintenance(), "override the authentication flag")
	cmd.Flags().String("signingKey", options.SigningKey, "signature private key path. If a valid one is provided, it enables the cryptographic signature of the root. e.g. \"./../test/signer/ec3.key\"")
	cmd.Flags().Bool("synced", true, "synced mode prevents data lost under unexpected crashes but affects performance")
	cmd.Flags().Int("token-expiry-time", options.TokenExpiryTimeMin, "client authentication token expiration time. Minutes")
	cmd.Flags().Bool("metrics-server", options.MetricsServer, "enable or disable Prometheus endpoint")
	cmd.Flags().Int("metrics-server-port", options.MetricsServerPort, "Prometheus endpoint port")
	cmd.Flags().Bool("web-server", options.WebServer, "enable or disable web/console server")
	cmd.Flags().Int("web-server-port", options.WebServerPort, "web/console server port")
	cmd.Flags().Bool("pgsql-server", true, "enable or disable pgsql server")
	cmd.Flags().Int("pgsql-server-port", 5432, "pgsql server port")
	cmd.Flags().Bool("pprof", false, "add pprof profiling endpoint on the metrics server")
	cmd.Flags().Bool("s3-storage", false, "enable or disable s3 storage")
	cmd.Flags().String("s3-endpoint", "", "s3 endpoint")
	cmd.Flags().String("s3-access-key-id", "", "s3 access key id")
	cmd.Flags().String("s3-secret-key", "", "s3 secret access key")
	cmd.Flags().String("s3-bucket-name", "", "s3 bucket name")
	cmd.Flags().String("s3-location", "", "s3 location (region)")
	cmd.Flags().String("s3-path-prefix", "", "s3 path prefix (multiple immudb instances can share the same bucket if they have different prefixes)")
	cmd.Flags().Bool("s3-external-identifier", false, "use the remote identifier if there is no local identifier")
	cmd.Flags().Int("max-sessions", 100, "maximum number of simultaneously opened sessions")
	cmd.Flags().Duration("max-session-inactivity-time", 3*time.Minute, "max session inactivity time is a duration after which an active session is declared inactive by the server. A session is kept active if server is still receiving requests from client (keep-alive or other methods)")
	cmd.Flags().Duration("max-session-age-time", 0, "the current default value is infinity. max session age time is a duration after which session will be forcibly closed")
	cmd.Flags().Duration("session-timeout", 2*time.Minute, "session timeout is a duration after which an inactive session is forcibly closed by the server")
	cmd.Flags().Duration("sessions-guard-check-interval", 1*time.Minute, "sessions guard check interval")
	cmd.Flags().MarkHidden("sessions-guard-check-interval")
	cmd.Flags().Bool("grpc-reflection", options.GRPCReflectionServerEnabled, "GRPC reflection server enabled")

	flagNameMapping := map[string]string{
		"replication-enabled":           "replication-is-replica",
		"replication-follower-username": "replication-primary-username",
		"replication-follower-password": "replication-primary-password",
		"replication-master-database":   "replication-primary-database",
		"replication-master-address":    "replication-primary-host",
		"replication-master-port":       "replication-primary-port",
	}

	cmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
		if newName, ok := flagNameMapping[name]; ok {
			name = newName
		}
		return pflag.NormalizedName(name)
	})
}