From ff3bb819e5f46fec24208c088c0dde221efb655c Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Mon, 9 Dec 2024 09:59:21 +0100 Subject: [PATCH] restructure a bit --- pkg/eosclient/eosgrpc/eosgrpc.go | 72 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 29a4d74bcd..296289f75b 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -59,27 +59,12 @@ const ( UserAttr ) -func serializeAttribute(a *eosclient.Attribute) string { - return fmt.Sprintf("%s.%s=%s", attrTypeToString(a.Type), a.Key, a.Val) -} - -func attrTypeToString(at eosclient.AttrType) string { - switch at { - case eosclient.SystemAttr: - return "sys" - case eosclient.UserAttr: - return "user" - default: - return "invalid" - } -} - -func isValidAttribute(a *eosclient.Attribute) bool { - // validate that an attribute is correct. - if (a.Type != eosclient.SystemAttr && a.Type != eosclient.UserAttr) || a.Key == "" { - return false - } - return true +// Client performs actions against a EOS management node (MGM) +// using the EOS GRPC interface. +type Client struct { + opt *Options + httpcl *EOSHTTPClient + cl erpc.EosClient } // Options to configure the Client. @@ -132,15 +117,6 @@ type Options struct { TokenExpiry int } -func getUser(ctx context.Context) (*userpb.User, error) { - u, ok := appctx.ContextGetUser(ctx) - if !ok { - err := errors.Wrap(errtypes.UserRequired(""), "eosfs: error getting user from ctx") - return nil, err - } - return u, nil -} - func (opt *Options) init() { if opt.XrdcopyBinary == "" { opt.XrdcopyBinary = "/opt/eos/xrootd/bin/xrdcopy" @@ -155,12 +131,36 @@ func (opt *Options) init() { } } -// Client performs actions against a EOS management node (MGM) -// using the EOS GRPC interface. -type Client struct { - opt *Options - httpcl *EOSHTTPClient - cl erpc.EosClient +func getUser(ctx context.Context) (*userpb.User, error) { + u, ok := appctx.ContextGetUser(ctx) + if !ok { + err := errors.Wrap(errtypes.UserRequired(""), "eosfs: error getting user from ctx") + return nil, err + } + return u, nil +} + +func serializeAttribute(a *eosclient.Attribute) string { + return fmt.Sprintf("%s.%s=%s", attrTypeToString(a.Type), a.Key, a.Val) +} + +func attrTypeToString(at eosclient.AttrType) string { + switch at { + case eosclient.SystemAttr: + return "sys" + case eosclient.UserAttr: + return "user" + default: + return "invalid" + } +} + +func isValidAttribute(a *eosclient.Attribute) bool { + // validate that an attribute is correct. + if (a.Type != eosclient.SystemAttr && a.Type != eosclient.UserAttr) || a.Key == "" { + return false + } + return true } // Create and connect a grpc eos Client.