From 1302c7ae787a7c049f4673ae3babb2ca44fe0002 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Wed, 19 May 2021 19:27:02 +0300 Subject: [PATCH] [#46] *: Add comments, fix typos Signed-off-by: Angira Kekteeva --- Makefile | 4 ++-- authmate/authmate.go | 9 ++++++++- cmd/authmate/main.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7fa7d64..1c8b863 100644 --- a/Makefile +++ b/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//')" BINDIR = bin -# s3 gate variables +# s3 gw variables BIN_NAME=neofs-s3-gw BIN = "$(BINDIR)/$(BIN_NAME)" @@ -13,7 +13,7 @@ BIN = "$(BINDIR)/$(BIN_NAME)" HUB_IMAGE ?= "nspccdev/$(BIN_NAME)" HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" -#authmate variables +# Authmate variables AUTHMATE_BIN_NAME=neofs-authmate AUTHMATE_BIN = "$(BINDIR)/$(AUTHMATE_BIN_NAME)" diff --git a/authmate/authmate.go b/authmate/authmate.go index b3c37f8..b27dd45 100644 --- a/authmate/authmate.go +++ b/authmate/authmate.go @@ -27,16 +27,19 @@ import ( const defaultAuthContainerBasicACL uint32 = 0b00111100100011001000110011001100 +// Agent contains client communicating with NeoFS and logger. type Agent struct { cli sdk.Client 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 { return &Agent{log: log, cli: client} } type ( + // IssueSecretOptions contains options for passing to Agent.IssueSecret method. IssueSecretOptions struct { ContainerID *container.ID ContainerFriendlyName string @@ -46,6 +49,7 @@ type ( EACLRules []byte } + // ObtainSecretOptions contains options for passing to Agent.ObtainSecret method. ObtainSecretOptions struct { SecretAddress string GatePrivateKey hcs.PrivateKey @@ -88,6 +92,7 @@ func (a *Agent) checkContainer(ctx context.Context, cid *container.ID, friendlyN 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 { var ( err error @@ -138,6 +143,8 @@ func (a *Agent) IssueSecret(ctx context.Context, w io.Writer, options *IssueSecr 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 { bearerCreds := bearer.New(a.cli.Object(), options.GatePrivateKey) address := object.NewAddress() @@ -183,7 +190,7 @@ func buildPlacementPolicy(placementRules string) (*netmap.PlacementPolicy, error return pp, nil } -// selects nodes in container without any additional attributes +// selects nodes in container without any additional attributes. func newSimpleSelector(name string, count uint32) (s *netmap.Selector) { s = new(netmap.Selector) s.SetCount(count) diff --git a/cmd/authmate/main.go b/cmd/authmate/main.go index ec38e06..8ec1ddb 100644 --- a/cmd/authmate/main.go +++ b/cmd/authmate/main.go @@ -32,7 +32,7 @@ const ( ) var ( - // Build = "now" + // Version of the program. Version = "dev" )