forked from TrueCloudLab/frostfs-node
[#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes: * avoid package-colliding variable naming * avoid using pointers to IDs where unnecessary * avoid using `idSDK` import alias pattern * use `EncodeToString` for protocol string calculation and `String` for printing Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cc6209e8a0
commit
1c30414a6c
218 changed files with 2095 additions and 2521 deletions
|
@ -2,6 +2,7 @@ package common
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||
|
@ -33,13 +34,24 @@ func ReadBearerToken(cmd *cobra.Command, flagname string) *bearer.Token {
|
|||
return &tok
|
||||
}
|
||||
|
||||
// ReadSessionToken reads session token as JSON file with session token
|
||||
// from path provided in a specified flag.
|
||||
// ReadSessionToken calls ReadSessionTokenErr and exists on error.
|
||||
func ReadSessionToken(cmd *cobra.Command, dst json.Unmarshaler, fPath string) {
|
||||
ExitOnErr(cmd, "", ReadSessionTokenErr(dst, fPath))
|
||||
}
|
||||
|
||||
// ReadSessionTokenErr reads session token as JSON file with session token
|
||||
// from path provided in a specified flag.
|
||||
func ReadSessionTokenErr(dst json.Unmarshaler, fPath string) error {
|
||||
// try to read session token from file
|
||||
data, err := os.ReadFile(fPath)
|
||||
ExitOnErr(cmd, "could not open file with session token: %w", err)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not open file with session token <%s>: %w", fPath, err)
|
||||
}
|
||||
|
||||
err = dst.UnmarshalJSON(data)
|
||||
ExitOnErr(cmd, "could not unmarshal session token from file: %w", err)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not unmarshal session token from file: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue