forked from TrueCloudLab/frostfs-s3-gw
[#46] *: Add comments, fix typos
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
d46578ce0b
commit
1302c7ae78
3 changed files with 11 additions and 4 deletions
4
Makefile
4
Makefile
|
@ -5,7 +5,7 @@ REPO ?= $(shell go list -m)
|
||||||
VERSION ?= "$(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD | sed 's/^v//')"
|
VERSION ?= "$(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD | sed 's/^v//')"
|
||||||
BINDIR = bin
|
BINDIR = bin
|
||||||
|
|
||||||
# s3 gate variables
|
# s3 gw variables
|
||||||
BIN_NAME=neofs-s3-gw
|
BIN_NAME=neofs-s3-gw
|
||||||
BIN = "$(BINDIR)/$(BIN_NAME)"
|
BIN = "$(BINDIR)/$(BIN_NAME)"
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ BIN = "$(BINDIR)/$(BIN_NAME)"
|
||||||
HUB_IMAGE ?= "nspccdev/$(BIN_NAME)"
|
HUB_IMAGE ?= "nspccdev/$(BIN_NAME)"
|
||||||
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
|
||||||
|
|
||||||
#authmate variables
|
# Authmate variables
|
||||||
AUTHMATE_BIN_NAME=neofs-authmate
|
AUTHMATE_BIN_NAME=neofs-authmate
|
||||||
AUTHMATE_BIN = "$(BINDIR)/$(AUTHMATE_BIN_NAME)"
|
AUTHMATE_BIN = "$(BINDIR)/$(AUTHMATE_BIN_NAME)"
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,19 @@ import (
|
||||||
|
|
||||||
const defaultAuthContainerBasicACL uint32 = 0b00111100100011001000110011001100
|
const defaultAuthContainerBasicACL uint32 = 0b00111100100011001000110011001100
|
||||||
|
|
||||||
|
// Agent contains client communicating with NeoFS and logger.
|
||||||
type Agent struct {
|
type Agent struct {
|
||||||
cli sdk.Client
|
cli sdk.Client
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates an object of type Agent that consists of Client and logger.
|
||||||
func New(log *zap.Logger, client sdk.Client) *Agent {
|
func New(log *zap.Logger, client sdk.Client) *Agent {
|
||||||
return &Agent{log: log, cli: client}
|
return &Agent{log: log, cli: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// IssueSecretOptions contains options for passing to Agent.IssueSecret method.
|
||||||
IssueSecretOptions struct {
|
IssueSecretOptions struct {
|
||||||
ContainerID *container.ID
|
ContainerID *container.ID
|
||||||
ContainerFriendlyName string
|
ContainerFriendlyName string
|
||||||
|
@ -46,6 +49,7 @@ type (
|
||||||
EACLRules []byte
|
EACLRules []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ObtainSecretOptions contains options for passing to Agent.ObtainSecret method.
|
||||||
ObtainSecretOptions struct {
|
ObtainSecretOptions struct {
|
||||||
SecretAddress string
|
SecretAddress string
|
||||||
GatePrivateKey hcs.PrivateKey
|
GatePrivateKey hcs.PrivateKey
|
||||||
|
@ -88,6 +92,7 @@ func (a *Agent) checkContainer(ctx context.Context, cid *container.ID, friendlyN
|
||||||
sdk.ContainerPutWithTimeout(120*time.Second))
|
sdk.ContainerPutWithTimeout(120*time.Second))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IssueSecret creates an auth token, puts it in the NeoFS network and writes to io.Writer a new secret access key.
|
||||||
func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecretOptions) error {
|
func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecretOptions) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
@ -138,6 +143,8 @@ func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecr
|
||||||
return enc.Encode(ir)
|
return enc.Encode(ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ObtainSecret receives an existing secret access key from NeoFS and
|
||||||
|
// writes to io.Writer the secret access key.
|
||||||
func (a *Agent) ObtainSecret(ctx context.Context, w io.Writer, options *ObtainSecretOptions) error {
|
func (a *Agent) ObtainSecret(ctx context.Context, w io.Writer, options *ObtainSecretOptions) error {
|
||||||
bearerCreds := bearer.New(a.cli.Object(), options.GatePrivateKey)
|
bearerCreds := bearer.New(a.cli.Object(), options.GatePrivateKey)
|
||||||
address := object.NewAddress()
|
address := object.NewAddress()
|
||||||
|
@ -183,7 +190,7 @@ func buildPlacementPolicy(placementRules string) (*netmap.PlacementPolicy, error
|
||||||
return pp, nil
|
return pp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// selects <count> nodes in container without any additional attributes
|
// selects <count> nodes in container without any additional attributes.
|
||||||
func newSimpleSelector(name string, count uint32) (s *netmap.Selector) {
|
func newSimpleSelector(name string, count uint32) (s *netmap.Selector) {
|
||||||
s = new(netmap.Selector)
|
s = new(netmap.Selector)
|
||||||
s.SetCount(count)
|
s.SetCount(count)
|
||||||
|
|
|
@ -32,7 +32,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Build = "now"
|
// Version of the program.
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue