forked from TrueCloudLab/frostfs-node
[#587] cmd/neofs-cli: Make session token parser reusable
containerSessionToken() actually parses any session token. We can reuse this function to resign session token when it takes filepath as an argument, instead of public variable. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
752efc6f8c
commit
bce92168c1
1 changed files with 7 additions and 6 deletions
|
@ -161,7 +161,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tok, err := containerSessionToken()
|
tok, err := getSessionToken(sessionTokenPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tok, err := containerSessionToken()
|
tok, err := getSessionToken(sessionTokenPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tok, err := containerSessionToken()
|
tok, err := getSessionToken(sessionTokenPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -595,12 +595,13 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func containerSessionToken() (*session.Token, error) {
|
// getSessionToken reads `<path>` as JSON file with session token and parses it.
|
||||||
|
func getSessionToken(path string) (*session.Token, error) {
|
||||||
// try to read session token from file
|
// try to read session token from file
|
||||||
var tok *session.Token
|
var tok *session.Token
|
||||||
|
|
||||||
if sessionTokenPath != "" {
|
if path != "" {
|
||||||
data, err := ioutil.ReadFile(sessionTokenPath)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue