Skip to content

Commit ff3bb81

Browse files
committed
restructure a bit
1 parent 88f4c19 commit ff3bb81

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

pkg/eosclient/eosgrpc/eosgrpc.go

+36-36
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,12 @@ const (
5959
UserAttr
6060
)
6161

62-
func serializeAttribute(a *eosclient.Attribute) string {
63-
return fmt.Sprintf("%s.%s=%s", attrTypeToString(a.Type), a.Key, a.Val)
64-
}
65-
66-
func attrTypeToString(at eosclient.AttrType) string {
67-
switch at {
68-
case eosclient.SystemAttr:
69-
return "sys"
70-
case eosclient.UserAttr:
71-
return "user"
72-
default:
73-
return "invalid"
74-
}
75-
}
76-
77-
func isValidAttribute(a *eosclient.Attribute) bool {
78-
// validate that an attribute is correct.
79-
if (a.Type != eosclient.SystemAttr && a.Type != eosclient.UserAttr) || a.Key == "" {
80-
return false
81-
}
82-
return true
62+
// Client performs actions against a EOS management node (MGM)
63+
// using the EOS GRPC interface.
64+
type Client struct {
65+
opt *Options
66+
httpcl *EOSHTTPClient
67+
cl erpc.EosClient
8368
}
8469

8570
// Options to configure the Client.
@@ -132,15 +117,6 @@ type Options struct {
132117
TokenExpiry int
133118
}
134119

135-
func getUser(ctx context.Context) (*userpb.User, error) {
136-
u, ok := appctx.ContextGetUser(ctx)
137-
if !ok {
138-
err := errors.Wrap(errtypes.UserRequired(""), "eosfs: error getting user from ctx")
139-
return nil, err
140-
}
141-
return u, nil
142-
}
143-
144120
func (opt *Options) init() {
145121
if opt.XrdcopyBinary == "" {
146122
opt.XrdcopyBinary = "/opt/eos/xrootd/bin/xrdcopy"
@@ -155,12 +131,36 @@ func (opt *Options) init() {
155131
}
156132
}
157133

158-
// Client performs actions against a EOS management node (MGM)
159-
// using the EOS GRPC interface.
160-
type Client struct {
161-
opt *Options
162-
httpcl *EOSHTTPClient
163-
cl erpc.EosClient
134+
func getUser(ctx context.Context) (*userpb.User, error) {
135+
u, ok := appctx.ContextGetUser(ctx)
136+
if !ok {
137+
err := errors.Wrap(errtypes.UserRequired(""), "eosfs: error getting user from ctx")
138+
return nil, err
139+
}
140+
return u, nil
141+
}
142+
143+
func serializeAttribute(a *eosclient.Attribute) string {
144+
return fmt.Sprintf("%s.%s=%s", attrTypeToString(a.Type), a.Key, a.Val)
145+
}
146+
147+
func attrTypeToString(at eosclient.AttrType) string {
148+
switch at {
149+
case eosclient.SystemAttr:
150+
return "sys"
151+
case eosclient.UserAttr:
152+
return "user"
153+
default:
154+
return "invalid"
155+
}
156+
}
157+
158+
func isValidAttribute(a *eosclient.Attribute) bool {
159+
// validate that an attribute is correct.
160+
if (a.Type != eosclient.SystemAttr && a.Type != eosclient.UserAttr) || a.Key == "" {
161+
return false
162+
}
163+
return true
164164
}
165165

166166
// Create and connect a grpc eos Client.

0 commit comments

Comments
 (0)