Skip to content
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a7e2329
[#1587] Exclude a common part of CLI parser
fivitti Jan 2, 2025
ac04f65
[#1587] Working general CLI parser
fivitti Jan 3, 2025
ffd2cf4
[#1587] Fix the wrong argument
fivitti Jan 7, 2025
8808118
[#1587] Unify agent and server parsers
fivitti Jan 7, 2025
e301a43
[#1587] Verify the envvars
fivitti Jan 7, 2025
30c4d21
[#1587] Fix linter issues
fivitti Jan 7, 2025
c8ca1c5
[#1587] Verify system environment variables
fivitti Jan 7, 2025
81b857a
[#1587] Add unit tests
fivitti Jan 7, 2025
48add73
[#1587] Extend unit test
fivitti Jan 7, 2025
06ba0b6
[#1587] Fix unit tests
fivitti Jan 7, 2025
cfb6ec4
[#1587] Simplify utility
fivitti Jan 7, 2025
7a29eb8
[#1587] Fix linter issue
fivitti Jan 8, 2025
522be1b
[#1587] Remove redundant flags
fivitti Jan 8, 2025
c6657d4
[#1587] Add unit tests
fivitti Jan 8, 2025
bf98f00
[#1587] Add a Changelog entry
fivitti Jan 8, 2025
19b7c94
[#1587] Unify the CLI handling in the Stork tool
fivitti Jan 8, 2025
66db02f
[#1587] Move package
fivitti Jan 8, 2025
425910d
[#1587] Exclude app to a separate file
fivitti Jan 8, 2025
7b201bd
[#1587] Unexport structs
fivitti Jan 8, 2025
6569020
[#1587] Unify code-gen CLI
fivitti Jan 8, 2025
27c6b7c
[#1587] Remove unnecessary dependencies
fivitti Jan 8, 2025
185123d
[#1587] Rename structs
fivitti Jan 9, 2025
f1d16f2
[#1587] Add unit tests
fivitti Jan 9, 2025
60f2fe4
[#1587] Rephrase a sentence
fivitti Jan 9, 2025
1acfd8d
[#1587] Support hooks only for agent and server
fivitti Jan 9, 2025
9285a3c
[#1587] Add unit test
fivitti Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[#1587] Remove redundant flags
  • Loading branch information
fivitti authored and tomaszmrugalski committed Jun 2, 2025
commit 522be1b0a46291ed9c3c4cbb2d9ec19e04b6d980
17 changes: 6 additions & 11 deletions backend/cmd/stork-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,8 @@ func runRegister(settings *registerSettings) {
}
}

// Read environment file settings. It's parsed before the main settings.
type environmentFileSettings struct {
EnvFile string `long:"env-file" description:"Environment file location; applicable only if the use-env-file is provided" default:"/etc/stork/agent.env"`
UseEnvFile bool `long:"use-env-file" description:"Read the environment variables from the environment file"`
}

// General Stork Agent settings. They are used when no command is specified.
type generalSettings struct {
environmentFileSettings
Version bool `short:"v" long:"version" description:"Show software version"`
Host string `long:"host" description:"The IP or hostname to listen on for incoming Stork Server connections" default:"0.0.0.0" env:"STORK_AGENT_HOST"`
Port int `long:"port" description:"The TCP port to listen on for incoming Stork Server connections" default:"8080" env:"STORK_AGENT_PORT"`
Expand All @@ -337,13 +330,12 @@ type generalSettings struct {
PrometheusBind9ExporterPort int `long:"prometheus-bind9-exporter-port" description:"The port to listen on for incoming Prometheus connections" default:"9119" env:"STORK_AGENT_PROMETHEUS_BIND9_EXPORTER_PORT"`
SkipTLSCertVerification bool `long:"skip-tls-cert-verification" description:"Skip TLS certificate verification when the Stork Agent makes HTTP calls over TLS" env:"STORK_AGENT_SKIP_TLS_CERT_VERIFICATION"`
ServerURL string `long:"server-url" description:"The URL of the Stork Server, used in agent-token-based registration (optional alternative to server-token-based registration)" env:"STORK_AGENT_SERVER_URL"`
HookDirectory string `long:"hook-directory" description:"The path to the hook directory" default:"/usr/lib/stork-agent/hooks" env:"STORK_AGENT_HOOK_DIRECTORY"`
Bind9Path string `long:"bind9-path" description:"Specify the path to BIND 9 config file. Does not need to be specified, unless the location is very uncommon." env:"STORK_AGENT_BIND9_CONFIG"`
HookDirectory string
}

// Register command settings.
type registerSettings struct {
environmentFileSettings
// It is true if the register command was specified. Otherwise, it is false.
commandSpecified bool
NonInteractive bool `short:"n" long:"non-interactive" description:"Do not prompt for missing arguments" env:"STORK_AGENT_NON_INTERACTIVE"`
Expand Down Expand Up @@ -445,19 +437,22 @@ authorization in the server using either the UI or the ReST API (agent-token-bas
storkutil.SetupLogging()
})

_, _, isHelp, err := appParser.Parse()
hookDirectorySettings, _, isHelp, err := appParser.Parse()
if err != nil {
err = errors.Wrap(err, "invalid CLI argument")
return nil, nil, false, err
} else if isHelp {
return nil, nil, true, nil
}
generalSettings.HookDirectory = hookDirectorySettings.HookDirectory

if registerSettings.commandSpecified {
generalSettings = nil
} else {
registerSettings = nil
}

return generalSettings, registerSettings, isHelp, nil
return generalSettings, registerSettings, false, nil
}

// Parses the command line arguments and runs the specific Stork Agent command.
Expand Down