forked from TrueCloudLab/frostfs-s3-gw
[#290] Add timeout to authmate
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
62301d8ce8
commit
a23a97efd6
1 changed files with 18 additions and 3 deletions
|
@ -49,6 +49,7 @@ var (
|
||||||
lifetimeFlag time.Duration
|
lifetimeFlag time.Duration
|
||||||
containerPolicies string
|
containerPolicies string
|
||||||
awcCliCredFile string
|
awcCliCredFile string
|
||||||
|
timeoutFlag time.Duration
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -124,6 +125,13 @@ func appFlags() []cli.Flag {
|
||||||
Usage: "Enable debug logger level",
|
Usage: "Enable debug logger level",
|
||||||
Destination: &logDebugEnabledFlag,
|
Destination: &logDebugEnabledFlag,
|
||||||
},
|
},
|
||||||
|
&cli.DurationFlag{
|
||||||
|
Name: "timeout",
|
||||||
|
Usage: "timeout of processing of the command, for example 2m " +
|
||||||
|
"(note: max time unit is an hour so to set a day you should use 24h)",
|
||||||
|
Destination: &timeoutFlag,
|
||||||
|
Value: 1 * time.Minute,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,10 +284,13 @@ It will be ceil rounded to the nearest amount of epoch.`,
|
||||||
AwsCliCredentialsFile: awcCliCredFile,
|
AwsCliCredentialsFile: awcCliCredFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = agent.IssueSecret(ctx, os.Stdout, issueSecretOptions); err != nil {
|
var tcancel context.CancelFunc
|
||||||
return cli.Exit(fmt.Sprintf("failed to issue secret: %s", err), 6)
|
ctx, tcancel = context.WithTimeout(ctx, timeoutFlag)
|
||||||
}
|
defer tcancel()
|
||||||
|
|
||||||
|
if err = agent.IssueSecret(ctx, os.Stdout, issueSecretOptions); err != nil {
|
||||||
|
return cli.Exit(fmt.Sprintf("failed to issue secret: %s", err), 7)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -391,6 +402,10 @@ func obtainSecret() *cli.Command {
|
||||||
GatePrivateKey: gateCreds,
|
GatePrivateKey: gateCreds,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tcancel context.CancelFunc
|
||||||
|
ctx, tcancel = context.WithTimeout(ctx, timeoutFlag)
|
||||||
|
defer tcancel()
|
||||||
|
|
||||||
if err = agent.ObtainSecret(ctx, os.Stdout, obtainSecretOptions); err != nil {
|
if err = agent.ObtainSecret(ctx, os.Stdout, obtainSecretOptions); err != nil {
|
||||||
return cli.Exit(fmt.Sprintf("failed to obtain secret: %s", err), 5)
|
return cli.Exit(fmt.Sprintf("failed to obtain secret: %s", err), 5)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue