diff --git a/commons/commands.go b/commons/commands.go index 2bc4a6d..9c46d9f 100644 --- a/commons/commands.go +++ b/commons/commands.go @@ -29,6 +29,7 @@ var ( sessionID int resourceServer string + ticket string ) func GetEnvironmentManager() *irodsclient_icommands.ICommandsEnvironmentManager { @@ -101,6 +102,7 @@ func SetCommonFlags(command *cobra.Command) { command.Flags().BoolP("debug", "d", false, "Enable debug mode") command.Flags().Int32P("session", "s", -1, "Set session ID") command.Flags().StringP("resource", "R", "", "Set resource server") + command.Flags().StringP("ticket", "T", "", "Set ticket") } func ProcessCommonFlags(command *cobra.Command) (bool, error) { @@ -233,6 +235,14 @@ func ProcessCommonFlags(command *cobra.Command) (bool, error) { resourceServer = resourceFlag.Value.String() } + ticketFlag := command.Flags().Lookup("ticket") + if ticketFlag != nil { + // load to global variable + ticket = ticketFlag.Value.String() + + logger.Debugf("use ticket - %s", ticket) + } + return true, nil // contiue } @@ -320,6 +330,10 @@ func InputMissingFields() (bool, error) { newAccount.DefaultResource = resourceServer } + if len(ticket) > 0 { + newAccount.Ticket = ticket + } + account = newAccount return updated, nil } @@ -472,6 +486,7 @@ func loadConfigFile(configPath string) error { } loadedAccount.ClientUser = config.ClientUsername + loadedAccount.Ticket = config.Ticket environmentMgr = iCommandsEnvMgr account = loadedAccount @@ -548,6 +563,7 @@ func loadConfigEnv() error { } loadedAccount.ClientUser = config.ClientUsername + loadedAccount.Ticket = config.Ticket environmentMgr = iCommandsEnvMgr account = loadedAccount diff --git a/commons/config.go b/commons/config.go index 3644b2f..3cbab88 100644 --- a/commons/config.go +++ b/commons/config.go @@ -30,6 +30,7 @@ type Config struct { DefaultResource string `yaml:"irods_default_resource,omitempty" envconfig:"IRODS_DEFAULT_RESOURCE"` LogLevel int `yaml:"irods_log_level,omitempty" envconfig:"IRODS_LOG_LEVEL"` Password string `yaml:"irods_user_password,omitempty" envconfig:"IRODS_USER_PASSWORD"` + Ticket string `yaml:"irods_ticket,omitempty" envconfig:"IRODS_TICKET"` AuthenticationScheme string `yaml:"irods_authentication_scheme,omitempty" envconfig:"IRODS_AUTHENTICATION_SCHEME"` ClientServerNegotiation string `yaml:"irods_client_server_negotiation,omitempty" envconfig:"IRODS_CLIENT_SERVER_NEGOTIATION"` ClientServerPolicy string `yaml:"irods_client_server_policy,omitempty" envconfig:"IRODS_CLIENT_SERVER_POLICY"`