Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply gofmt -s -w #1919

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ imports: off
`go env GOPATH`/bin/goimports -w tools pkg internal cmd

build: imports test-go-version
gofmt -s -w .
go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad
go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva

Expand Down
3 changes: 3 additions & 0 deletions changelog/unreleased/go-fmt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Run gofmt before building

https://github.com/cs3org/reva/pull/1919
12 changes: 6 additions & 6 deletions cmd/reva/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ func (c *Completer) completeOptionArguments(d prompt.Document) ([]prompt.Suggest
var match bool
switch option {
case "-cs":
suggests = []prompt.Suggest{prompt.Suggest{Text: "basic"}, prompt.Suggest{Text: "oidc"}}
suggests = []prompt.Suggest{{Text: "basic"}, {Text: "oidc"}}
match = true
case "-dd":
suggests = []prompt.Suggest{prompt.Suggest{Text: "local"}, prompt.Suggest{Text: "owncloud"}}
suggests = []prompt.Suggest{{Text: "local"}, {Text: "owncloud"}}
match = true
case "-type":
suggests = []prompt.Suggest{prompt.Suggest{Text: "user"}, prompt.Suggest{Text: "group"}}
suggests = []prompt.Suggest{{Text: "user"}, {Text: "group"}}
match = true
case "-rol":
suggests = []prompt.Suggest{prompt.Suggest{Text: "viewer"}, prompt.Suggest{Text: "editor"}}
suggests = []prompt.Suggest{{Text: "viewer"}, {Text: "editor"}}
match = true
case "-state":
suggests = []prompt.Suggest{prompt.Suggest{Text: "pending"}, prompt.Suggest{Text: "accepted"}, prompt.Suggest{Text: "rejected"}}
suggests = []prompt.Suggest{{Text: "pending"}, {Text: "accepted"}, {Text: "rejected"}}
match = true
case "-viewmode":
suggests = []prompt.Suggest{prompt.Suggest{Text: "view"}, prompt.Suggest{Text: "read"}, prompt.Suggest{Text: "write"}}
suggests = []prompt.Suggest{{Text: "view"}, {Text: "read"}, {Text: "write"}}
match = true
case "-c", "-grantee", "-idp", "-by-resource-id", "-xs", "-token":
match = true
Expand Down
6 changes: 3 additions & 3 deletions cmd/reva/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,23 +400,23 @@ func WriteUsers(p string, users []*userpb.User) {

if users == nil {
uservars = []*UserVars{
&UserVars{
{
Sub: "c6e5995d6c7fa1986b830b78b478e6c2",
Iss: "localhost:9998",
Username: "einstein",
Secret: "relativity",
Mail: "einstein@example.org",
Displayname: "Albert Einstein",
},
&UserVars{
{
Sub: "9fb5f8d212cbf3fc55f1bf67d97ed05d",
Iss: "localhost:9998",
Username: "marie",
Secret: "radioactivity",
Mail: "marie@example.org",
Displayname: "Marie Curie",
},
&UserVars{
{
Sub: "a84075b398fe6a0aee1155f8ead13331",
Iss: "localhost:9998",
Username: "richard",
Expand Down
4 changes: 2 additions & 2 deletions cmd/reva/ocm-share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func ocmShareCreateCommand() *command {

opaqueObj := &types.Opaque{
Map: map[string]*types.OpaqueEntry{
"permissions": &types.OpaqueEntry{
"permissions": {
Decoder: "plain",
Value: []byte(strconv.Itoa(pint)),
},
"name": &types.OpaqueEntry{
"name": {
Decoder: "plain",
Value: []byte(res.Info.Path),
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/ocm-share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func ocmShareListCommand() *command {
OpaqueId: tokens[1],
}
shareRequest.Filters = []*ocm.ListOCMSharesRequest_Filter{
&ocm.ListOCMSharesRequest_Filter{
{
Type: ocm.ListOCMSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &ocm.ListOCMSharesRequest_Filter_ResourceId{
ResourceId: id,
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/public-share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func publicShareListCommand() *command {
OpaqueId: tokens[1],
}
shareRequest.Filters = []*link.ListPublicSharesRequest_Filter{
&link.ListPublicSharesRequest_Filter{
{
Type: link.ListPublicSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &link.ListPublicSharesRequest_Filter_ResourceId{
ResourceId: id,
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func shareListCommand() *command {
OpaqueId: tokens[1],
}
shareRequest.Filters = []*collaboration.ListSharesRequest_Filter{
&collaboration.ListSharesRequest_Filter{
{
Type: collaboration.ListSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &collaboration.ListSharesRequest_Filter_ResourceId{
ResourceId: id,
Expand Down
6 changes: 3 additions & 3 deletions cmd/reva/transfer-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ func transferCreateCommand() *command {
createShareReq := &ocm.CreateOCMShareRequest{
Opaque: &types.Opaque{
Map: map[string]*types.OpaqueEntry{
"permissions": &types.OpaqueEntry{
"permissions": {
Decoder: "plain",
Value: []byte(strconv.Itoa(pint)),
},
"name": &types.OpaqueEntry{
"name": {
Decoder: "plain",
Value: []byte(statRes.Info.Path),
},
"protocol": &types.OpaqueEntry{
"protocol": {
Decoder: "plain",
Value: []byte("datatx"),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia
log.Info().Str("data-server", u.String()).Str("fn", req.Ref.GetPath()).Msg("file download")
res := &provider.InitiateFileDownloadResponse{
Protocols: []*provider.FileDownloadProtocol{
&provider.FileDownloadProtocol{
{
Protocol: "simple",
DownloadEndpoint: u.String(),
Expose: s.conf.ExposeDataServer,
Expand Down
12 changes: 6 additions & 6 deletions internal/http/interceptors/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,47 @@ func TestGetCredsForUserAgent(t *testing.T) {

tests := []*test{
// no user agent we return all available credentials
&test{
{
userAgent: "",
userAgentMap: map[string]string{},
availableCredentials: []string{"basic"},
expected: []string{"basic"},
},

// map set but user agent not in map
&test{
{
userAgent: "curl",
userAgentMap: map[string]string{"mirall": "basic"},
availableCredentials: []string{"basic", "bearer"},
expected: []string{"basic", "bearer"},
},

// no user map we return all available credentials
&test{
{
userAgent: "mirall",
userAgentMap: map[string]string{},
availableCredentials: []string{"basic"},
expected: []string{"basic"},
},

// user agent set but no mapping set we return all credentials
&test{
{
userAgent: "mirall",
userAgentMap: map[string]string{},
availableCredentials: []string{"basic"},
expected: []string{"basic"},
},

// user mapping set to non available credential, we return all available
&test{
{
userAgent: "mirall",
userAgentMap: map[string]string{"mirall": "notfound"},
availableCredentials: []string{"basic", "bearer"},
expected: []string{"basic", "bearer"},
},

// user mapping set and we return only desired credential
&test{
{
userAgent: "mirall",
userAgentMap: map[string]string{"mirall": "bearer"},
availableCredentials: []string{"basic", "bearer"},
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/ocmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (h *configHandler) init(c *Config) {
}
h.c.Enabled = true
h.c.Endpoint = fmt.Sprintf("https://%s/%s", h.c.Host, c.Prefix)
h.c.ResourceTypes = []resourceTypes{resourceTypes{
h.c.ResourceTypes = []resourceTypes{{
Name: "file",
ShareTypes: []string{"user"},
Protocols: resourceTypesProtocols{
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (h *invitesHandler) acceptInvite(w http.ResponseWriter, r *http.Request) {
providerInfo := ocmprovider.ProviderInfo{
Domain: recipientProvider,
Services: []*ocmprovider.Service{
&ocmprovider.Service{
{
Host: clientIP,
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/manager/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (m *manager) Authenticate(ctx context.Context, clientID, clientSecret strin

func getCredentials() map[string]Credentials {
return map[string]Credentials{
"einstein": Credentials{
"einstein": {
Secret: "relativity",
User: &user.User{
Id: &user.UserId{
Expand All @@ -88,7 +88,7 @@ func getCredentials() map[string]Credentials {
DisplayName: "Albert Einstein",
},
},
"marie": Credentials{
"marie": {
Secret: "radioactivity",
User: &user.User{
Id: &user.UserId{
Expand All @@ -102,7 +102,7 @@ func getCredentials() map[string]Credentials {
DisplayName: "Marie Curie",
},
},
"richard": Credentials{
"richard": {
Secret: "superfluidity",
User: &user.User{
Id: &user.UserId{
Expand Down
2 changes: 1 addition & 1 deletion pkg/ocm/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr
userID = owner
g.Grantee.Opaque = &typespb.Opaque{
Map: map[string]*typespb.OpaqueEntry{
"token": &typespb.OpaqueEntry{
"token": {
Decoder: "plain",
Value: []byte(token),
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestParseConfig(t *testing.T) {
}{
{name: "parse config", args: args{map[string]interface{}{
"services": map[string]map[string]interface{}{
"authprovider": map[string]interface{}{
"authprovider": {
"basic": map[string]interface{}{
"name": "auth-basic",
"nodes": []map[string]interface{}{
Expand All @@ -78,15 +78,15 @@ func TestParseConfig(t *testing.T) {
},
}}, want: &Config{
Services: map[string]map[string]*service{
"authprovider": map[string]*service{
"basic": &service{
"authprovider": {
"basic": {
Name: "auth-basic",
Nodes: []node{{
Address: "0.0.0.0:1234",
Metadata: map[string]string{"version": "v0.1.0"},
}},
},
"bearer": &service{
"bearer": {
Name: "auth-bearer",
Nodes: []node{{
Address: "0.0.0.0:5678",
Expand Down
4 changes: 2 additions & 2 deletions pkg/share/cache/cbox/cbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ func (m *manager) GetResourceInfos() ([]*provider.ResourceInfo, error) {
},
Opaque: &types.Opaque{
Map: map[string]*types.OpaqueEntry{
"uid": &types.OpaqueEntry{
"uid": {
Decoder: "plain",
Value: []byte("0"),
},
"gid": &types.OpaqueEntry{
"gid": {
Decoder: "plain",
Value: []byte("0"),
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/registry/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (c *config) init() {

if len(c.Rules) == 0 {
c.Rules = map[string]rule{
"/": rule{
"/": {
Address: sharedconf.GetGatewaySVC(""),
},
"00000000-0000-0000-0000-000000000000": rule{
"00000000-0000-0000-0000-000000000000": {
Address: sharedconf.GetGatewaySVC(""),
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,22 +1076,22 @@ func (fs *eosfs) createUserDir(ctx context.Context, u *userpb.User, path string,
}

attrs := []*eosclient.Attribute{
&eosclient.Attribute{
{
Type: SystemAttr,
Key: "mask",
Val: "700",
},
&eosclient.Attribute{
{
Type: SystemAttr,
Key: "allow.oc.sync",
Val: "1",
},
&eosclient.Attribute{
{
Type: SystemAttr,
Key: "mtime.propagation",
Val: "1",
},
&eosclient.Attribute{
{
Type: SystemAttr,
Key: "forced.atomic",
Val: "1",
Expand Down
16 changes: 8 additions & 8 deletions pkg/storage/utils/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ type testUnit struct {
}

var tests = []*testUnit{
&testUnit{
{
expected: "alabasta",
user: &userpb.User{
Username: "alabasta",
},
template: "{{.Username}}",
},
&testUnit{
{
expected: "a/alabasta",
user: &userpb.User{
Username: "alabasta",
},
template: "{{substr 0 1 .Username}}/{{.Username}}",
},
&testUnit{
{
expected: "idp@opaque",
user: &userpb.User{
Id: &userpb.UserId{
Expand All @@ -55,35 +55,35 @@ var tests = []*testUnit{
},
template: "{{.Id.Idp}}@{{.Id.OpaqueId}}",
},
&testUnit{ // test path clean
{ // test path clean
expected: "/alabasta",
user: &userpb.User{
Username: "alabasta",
},
template: "///{{.Username}}",
},
&testUnit{
{
expected: "michael",
user: &userpb.User{
Username: "MICHAEL",
},
template: "{{lower .Username}}",
},
&testUnit{
{
expected: "somewhere.com/michael@somewhere.com",
user: &userpb.User{
Username: "michael@somewhere.com",
},
template: "{{.Email.Domain}}/{{.Username}}",
},
&testUnit{
{
expected: "somewhere.com/michael",
user: &userpb.User{
Username: "michael@somewhere.com",
},
template: "{{.Email.Domain}}/{{.Email.Local}}",
},
&testUnit{
{
expected: "_unknown/michael",
user: &userpb.User{
Username: "michael",
Expand Down
Loading