45 lines
2.6 KiB
Go
45 lines
2.6 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import "go.maximumdirect.net/commandkit"
|
||
|
|
|
||
|
|
// configurationSelection distinguishes source selection from identity assertions
|
||
|
|
// and retains explicit empty selections until the operation checks its inputs.
|
||
|
|
type configurationSelection struct {
|
||
|
|
Config commandkit.Supplied[string]
|
||
|
|
Overlay commandkit.Supplied[string]
|
||
|
|
Campaign commandkit.Supplied[string]
|
||
|
|
CampaignFile commandkit.Supplied[string]
|
||
|
|
Session commandkit.Supplied[string]
|
||
|
|
SessionFile commandkit.Supplied[string]
|
||
|
|
PartyFile commandkit.Supplied[string]
|
||
|
|
SecretsDir commandkit.Supplied[string]
|
||
|
|
}
|
||
|
|
|
||
|
|
type configurationFlags[I any] struct {
|
||
|
|
Config, Overlay, Campaign, CampaignFile commandkit.Flag[I]
|
||
|
|
Session, SessionFile, PartyFile, SecretsDir commandkit.Flag[I]
|
||
|
|
}
|
||
|
|
|
||
|
|
func newConfigurationFlags[I any](selection func(*I) *configurationSelection) configurationFlags[I] {
|
||
|
|
return configurationFlags[I]{
|
||
|
|
Config: commandkit.ValueFlag(commandkit.FlagMeta{Name: "config", Usage: "Pipeline configuration file."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).Config = v }),
|
||
|
|
Overlay: commandkit.ValueFlag(commandkit.FlagMeta{Name: "overlay", Usage: "Pipeline overlay."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).Overlay = v }),
|
||
|
|
Campaign: commandkit.ValueFlag(commandkit.FlagMeta{Name: "campaign", Usage: "Assert the campaign identity."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).Campaign = v }),
|
||
|
|
CampaignFile: commandkit.ValueFlag(commandkit.FlagMeta{Name: "campaign-file", Usage: "Campaign configuration file."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).CampaignFile = v }),
|
||
|
|
Session: commandkit.ValueFlag(commandkit.FlagMeta{Name: "session", Usage: "Assert the session identity for configuration inspection."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).Session = v }),
|
||
|
|
SessionFile: commandkit.ValueFlag(commandkit.FlagMeta{Name: "session-file", Usage: "Session configuration file."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).SessionFile = v }),
|
||
|
|
PartyFile: commandkit.ValueFlag(commandkit.FlagMeta{Name: "party-file", Usage: "Party file replacing the campaign default."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).PartyFile = v }),
|
||
|
|
SecretsDir: commandkit.ValueFlag(commandkit.FlagMeta{Name: "secrets-dir", Usage: "Credential-bootstrap directory."}, nil, stringValue,
|
||
|
|
func(in *I, v commandkit.Supplied[string]) { selection(in).SecretsDir = v }),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func stringValue(value string) (string, error) { return value, nil }
|