Skip to content

Commit 5c31d43

Browse files
committed
Add comments to exported functions
1 parent 5d0b3fd commit 5c31d43

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

pkg/cbox/publicshare/sql/sql.go

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func (m *manager) startJanitorRun() {
103103
}
104104
}
105105

106+
// New returns a new public share manager.
106107
func New(m map[string]interface{}) (publicshare.Manager, error) {
107108
c := &config{}
108109
if err := mapstructure.Decode(m, c); err != nil {

pkg/cbox/share/sql/sql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type mgr struct {
6060
db *sql.DB
6161
}
6262

63-
// New returns a new mgr.
63+
// New returns a new share manager.
6464
func New(m map[string]interface{}) (share.Manager, error) {
6565
c, err := parseConfig(m)
6666
if err != nil {

pkg/cbox/utils/conversions.go

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
3232
)
3333

34+
// DBShare stores information about user and public shares.
3435
type DBShare struct {
3536
ID string
3637
UIDOwner string
@@ -48,6 +49,7 @@ type DBShare struct {
4849
State int
4950
}
5051

52+
// FormatGrantee formats a CS3API grantee to a string
5153
func FormatGrantee(g *provider.Grantee) (int, string) {
5254
var granteeType int
5355
var formattedID string
@@ -64,6 +66,7 @@ func FormatGrantee(g *provider.Grantee) (int, string) {
6466
return granteeType, formattedID
6567
}
6668

69+
// ExtractGrantee retrieves the CS3API grantee from a formatted string
6770
func ExtractGrantee(t int, g string) *provider.Grantee {
6871
var grantee *provider.Grantee
6972
switch t {
@@ -79,6 +82,7 @@ func ExtractGrantee(t int, g string) *provider.Grantee {
7982
return grantee
8083
}
8184

85+
// ResourceTypeToItem maps a resource type to an integer
8286
func ResourceTypeToItem(r provider.ResourceType) string {
8387
switch r {
8488
case provider.ResourceType_RESOURCE_TYPE_FILE:
@@ -94,6 +98,7 @@ func ResourceTypeToItem(r provider.ResourceType) string {
9498
}
9599
}
96100

101+
// SharePermToInt maps read/write permissions to an integer
97102
func SharePermToInt(p *provider.ResourcePermissions) int {
98103
var perm int
99104
if p.CreateContainer {
@@ -104,6 +109,7 @@ func SharePermToInt(p *provider.ResourcePermissions) int {
104109
return perm
105110
}
106111

112+
// IntTosharePerm retrieves read/write permissions from an integer
107113
func IntTosharePerm(p int) *provider.ResourcePermissions {
108114
switch p {
109115
case 1:
@@ -141,6 +147,7 @@ func IntTosharePerm(p int) *provider.ResourcePermissions {
141147
}
142148
}
143149

150+
// IntToShareState retrieves the received share state from an integer
144151
func IntToShareState(g int) collaboration.ShareState {
145152
switch g {
146153
case 0:
@@ -152,13 +159,15 @@ func IntToShareState(g int) collaboration.ShareState {
152159
}
153160
}
154161

162+
// FormatUserID formats a CS3API user ID to a string
155163
func FormatUserID(u *userpb.UserId) string {
156164
if u.Idp != "" {
157165
return fmt.Sprintf("%s:%s", u.OpaqueId, u.Idp)
158166
}
159167
return u.OpaqueId
160168
}
161169

170+
// ExtractUserID retrieves a CS3API user ID from a string
162171
func ExtractUserID(u string) *userpb.UserId {
163172
parts := strings.Split(u, ":")
164173
if len(parts) > 1 {
@@ -167,13 +176,15 @@ func ExtractUserID(u string) *userpb.UserId {
167176
return &userpb.UserId{OpaqueId: parts[0]}
168177
}
169178

179+
// FormatGroupID formats a CS3API group ID to a string
170180
func FormatGroupID(u *grouppb.GroupId) string {
171181
if u.Idp != "" {
172182
return fmt.Sprintf("%s:%s", u.OpaqueId, u.Idp)
173183
}
174184
return u.OpaqueId
175185
}
176186

187+
// ExtractGroupID retrieves a CS3API group ID from a string
177188
func ExtractGroupID(u string) *grouppb.GroupId {
178189
parts := strings.Split(u, ":")
179190
if len(parts) > 1 {
@@ -182,6 +193,7 @@ func ExtractGroupID(u string) *grouppb.GroupId {
182193
return &grouppb.GroupId{OpaqueId: parts[0]}
183194
}
184195

196+
// ConvertToCS3Share converts a DBShare to a CS3API collaboration share
185197
func ConvertToCS3Share(s DBShare) *collaboration.Share {
186198
ts := &typespb.Timestamp{
187199
Seconds: uint64(s.STime),
@@ -200,6 +212,7 @@ func ConvertToCS3Share(s DBShare) *collaboration.Share {
200212
}
201213
}
202214

215+
// ConvertToCS3ReceivedShare converts a DBShare to a CS3API collaboration received share
203216
func ConvertToCS3ReceivedShare(s DBShare) *collaboration.ReceivedShare {
204217
share := ConvertToCS3Share(s)
205218
return &collaboration.ReceivedShare{
@@ -208,6 +221,7 @@ func ConvertToCS3ReceivedShare(s DBShare) *collaboration.ReceivedShare {
208221
}
209222
}
210223

224+
// ConvertToCS3PublicShare converts a DBShare to a CS3API public share
211225
func ConvertToCS3PublicShare(s DBShare) *link.PublicShare {
212226
ts := &typespb.Timestamp{
213227
Seconds: uint64(s.STime),

0 commit comments

Comments
 (0)