Skip to content

Commit

Permalink
Add ticket support
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Jan 19, 2023
1 parent b87dbd6 commit 0e073a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions commons/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (

sessionID int
resourceServer string
ticket string
)

func GetEnvironmentManager() *irodsclient_icommands.ICommandsEnvironmentManager {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -320,6 +330,10 @@ func InputMissingFields() (bool, error) {
newAccount.DefaultResource = resourceServer
}

if len(ticket) > 0 {
newAccount.Ticket = ticket
}

account = newAccount
return updated, nil
}
Expand Down Expand Up @@ -472,6 +486,7 @@ func loadConfigFile(configPath string) error {
}

loadedAccount.ClientUser = config.ClientUsername
loadedAccount.Ticket = config.Ticket

environmentMgr = iCommandsEnvMgr
account = loadedAccount
Expand Down Expand Up @@ -548,6 +563,7 @@ func loadConfigEnv() error {
}

loadedAccount.ClientUser = config.ClientUsername
loadedAccount.Ticket = config.Ticket

environmentMgr = iCommandsEnvMgr
account = loadedAccount
Expand Down
1 change: 1 addition & 0 deletions commons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 0e073a1

Please sign in to comment.