mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
Fix linting (#1934)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
This commit is contained in:
@@ -54,7 +54,6 @@ require (
|
||||
go.opentelemetry.io/otel/sdk v1.19.0
|
||||
go.opentelemetry.io/otel/trace v1.19.0
|
||||
golang.org/x/crypto v0.14.0
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
||||
golang.org/x/net v0.17.0
|
||||
golang.org/x/sync v0.4.0
|
||||
gonum.org/v1/gonum v0.14.0
|
||||
@@ -216,6 +215,7 @@ require (
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.5.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
|
||||
golang.org/x/mod v0.13.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
|
||||
@@ -260,7 +260,6 @@ func (sdk mfSDK) ConnectThing(thingID, channelID, token string) errors.SDKError
|
||||
_, _, sdkerr := sdk.processRequest(http.MethodPost, url, token, nil, nil, http.StatusNoContent)
|
||||
|
||||
return sdkerr
|
||||
|
||||
}
|
||||
|
||||
func (sdk mfSDK) DisconnectThing(thingID, channelID, token string) errors.SDKError {
|
||||
|
||||
@@ -86,8 +86,3 @@ type SubscriptionPage struct {
|
||||
type identifyThingResp struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type canAccessRes struct {
|
||||
ThingID string `json:"thing_id"`
|
||||
Authorized bool `json:"authorized"`
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ func clientsHandler(svc things.Service, r *chi.Mux, logger mflog.Logger) http.Ha
|
||||
api.EncodeResponse,
|
||||
opts...,
|
||||
), "thing_delete_share").ServeHTTP)
|
||||
|
||||
})
|
||||
|
||||
// Ideal location: things service, channels endpoint
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/mainflux/mainflux/internal/apiutil"
|
||||
mfclients "github.com/mainflux/mainflux/pkg/clients"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type createClientReq struct {
|
||||
@@ -208,66 +207,6 @@ func (req changeClientStatusReq) validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type assignUsersGroupsRequest struct {
|
||||
token string
|
||||
groupID string
|
||||
Relation string `json:"relation,omitempty"`
|
||||
MemberKind string `json:"member_kind,omitempty"`
|
||||
Members []string `json:"members"`
|
||||
}
|
||||
|
||||
func (req assignUsersGroupsRequest) validate() error {
|
||||
if req.token == "" {
|
||||
return apiutil.ErrBearerToken
|
||||
}
|
||||
if req.MemberKind == "" {
|
||||
return apiutil.ErrMissingMemberKind
|
||||
}
|
||||
if !slices.Contains([]string{"users", "groups"}, req.MemberKind) {
|
||||
return apiutil.ErrInvalidMemberKind
|
||||
}
|
||||
if req.groupID == "" {
|
||||
return apiutil.ErrMissingID
|
||||
}
|
||||
if len(req.Members) == 0 {
|
||||
return apiutil.ErrEmptyList
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type unassignUsersGroupsRequest struct {
|
||||
token string
|
||||
groupID string
|
||||
Relation string `json:"relation,omitempty"`
|
||||
MemberKind string `json:"member_kind,omitempty"`
|
||||
Members []string `json:"members"`
|
||||
}
|
||||
|
||||
func (req unassignUsersGroupsRequest) validate() error {
|
||||
if req.token == "" {
|
||||
return apiutil.ErrBearerToken
|
||||
}
|
||||
|
||||
if req.MemberKind == "" {
|
||||
return apiutil.ErrMissingMemberKind
|
||||
}
|
||||
|
||||
if !slices.Contains([]string{"users", "groups"}, req.MemberKind) {
|
||||
return apiutil.ErrInvalidMemberKind
|
||||
}
|
||||
|
||||
if req.groupID == "" {
|
||||
return apiutil.ErrMissingID
|
||||
}
|
||||
|
||||
if len(req.Members) == 0 {
|
||||
return apiutil.ErrEmptyList
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type assignUsersRequest struct {
|
||||
token string
|
||||
groupID string
|
||||
|
||||
+1
-2
@@ -205,6 +205,7 @@ func (svc service) filterAllowedThingIDs(ctx context.Context, userID, permission
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func (svc service) UpdateClient(ctx context.Context, token string, cli mfclients.Client) (mfclients.Client, error) {
|
||||
userID, err := svc.authorize(ctx, userType, tokenKind, token, editPermission, thingType, cli.ID)
|
||||
if err != nil {
|
||||
@@ -309,7 +310,6 @@ func (svc service) Share(ctx context.Context, token, id, relation string, userid
|
||||
}
|
||||
|
||||
for _, userid := range userids {
|
||||
|
||||
addPolicyReq := &mainflux.AddPolicyReq{
|
||||
SubjectType: userType,
|
||||
Subject: userid,
|
||||
@@ -336,7 +336,6 @@ func (svc service) Unshare(ctx context.Context, token, id, relation string, user
|
||||
}
|
||||
|
||||
for _, userid := range userids {
|
||||
|
||||
delPolicyReq := &mainflux.DeletePolicyReq{
|
||||
SubjectType: userType,
|
||||
Subject: userid,
|
||||
|
||||
+2
-3
@@ -463,9 +463,8 @@ func messaging(s sdk.SDK, conf Config, token string, things []sdk.Thing, channel
|
||||
for _, thing := range things {
|
||||
for _, channel := range channels {
|
||||
conn := sdk.Connection{
|
||||
ThingID: thing.ID,
|
||||
ChannelID: channel.ID,
|
||||
Permission: "publish",
|
||||
ThingID: thing.ID,
|
||||
ChannelID: channel.ID,
|
||||
}
|
||||
if err := s.Connect(conn, token); err != nil {
|
||||
return fmt.Errorf("failed to connect thing %s to channel %s", thing.ID, channel.ID)
|
||||
|
||||
@@ -236,7 +236,6 @@ func Provision(conf Config) error {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user