Skip to content
Snippets Groups Projects
Commit 90269aff authored by Semyon Krestyaninov's avatar Semyon Krestyaninov :dog2: Committed by Pavel Antonov
Browse files

chore(api): Исправлены ошибки linter`а связанные с пропущенными именами...

chore(api): Исправлены ошибки linter`а связанные с пропущенными именами переменных при получении результатов

Close #PRXS-2610
parent cf99f709
Branches
Tags
No related merge requests found
Showing
with 99 additions and 98 deletions
...@@ -9,7 +9,6 @@ type config struct { ...@@ -9,7 +9,6 @@ type config struct {
noCache bool noCache bool
noLog bool noLog bool
accessLog bool accessLog bool
debug bool
clientOptions []kitgrpc.ClientOption // todo: можно заменить на grpc-интерсепторы при соединении и избавиться здесь от go-kit clientOptions []kitgrpc.ClientOption // todo: можно заменить на grpc-интерсепторы при соединении и избавиться здесь от go-kit
logger *zap.Logger logger *zap.Logger
} }
......
...@@ -80,7 +80,7 @@ func (a *Anonymous) HasEnvironmentAccess(ctx context.Context, space, env string) ...@@ -80,7 +80,7 @@ func (a *Anonymous) HasEnvironmentAccess(ctx context.Context, space, env string)
} }
func (Anonymous) Format(f fmt.State, verb rune) { func (Anonymous) Format(f fmt.State, verb rune) {
f.Write([]byte("AnonymousPrincipal{}")) _, _ = f.Write([]byte("AnonymousPrincipal{}"))
} }
func (a Anonymous) HasAccess(ctx context.Context, spaceID, orgID string) error { func (a Anonymous) HasAccess(ctx context.Context, spaceID, orgID string) error {
......
...@@ -52,7 +52,7 @@ func (c ClientPrincipal) Format(f fmt.State, verb rune) { ...@@ -52,7 +52,7 @@ func (c ClientPrincipal) Format(f fmt.State, verb rune) {
id = c.client.ID id = c.client.ID
} }
f.Write([]byte(fmt.Sprintf("ClientPrincipal{ID: '%s', Identity: {%s}}", id, identity))) _, _ = f.Write([]byte(fmt.Sprintf("ClientPrincipal{ID: '%s', Identity: {%s}}", id, identity)))
} }
func (c *ClientPrincipal) Space(spaceID string) SpaceAccessor { func (c *ClientPrincipal) Space(spaceID string) SpaceAccessor {
...@@ -63,6 +63,7 @@ func (c *ClientPrincipal) Space(spaceID string) SpaceAccessor { ...@@ -63,6 +63,7 @@ func (c *ClientPrincipal) Space(spaceID string) SpaceAccessor {
return c return c
} }
// nolint:unused
func (c *ClientPrincipal) getSpace(ctx context.Context, spaceID string) *spaces.Space { func (c *ClientPrincipal) getSpace(ctx context.Context, spaceID string) *spaces.Space {
if spaceID == "" { if spaceID == "" {
return nil return nil
...@@ -237,6 +238,7 @@ func (c *ClientPrincipal) HasAccess(ctx context.Context, spaceID, orgID string) ...@@ -237,6 +238,7 @@ func (c *ClientPrincipal) HasAccess(ctx context.Context, spaceID, orgID string)
return service.ErrAccessDenied return service.ErrAccessDenied
} }
// nolint:unused
func (c *ClientPrincipal) hasRole(ctx context.Context, spaceID string) (bool, error) { func (c *ClientPrincipal) hasRole(ctx context.Context, spaceID string) (bool, error) {
if c.spaceID == "" { if c.spaceID == "" {
return false, nil return false, nil
......
...@@ -35,5 +35,5 @@ func (SystemPrincipal) Rules(_ context.Context, _, _ string) permission.Ruleset ...@@ -35,5 +35,5 @@ func (SystemPrincipal) Rules(_ context.Context, _, _ string) permission.Ruleset
} }
func (SystemPrincipal) Format(f fmt.State, verb rune) { func (SystemPrincipal) Format(f fmt.State, verb rune) {
f.Write([]byte("SystemPrincipal{}")) _, _ = f.Write([]byte("SystemPrincipal{}"))
} }
...@@ -36,7 +36,7 @@ type UserPrincipal struct { ...@@ -36,7 +36,7 @@ type UserPrincipal struct {
} }
func (u UserPrincipal) Format(f fmt.State, verb rune) { func (u UserPrincipal) Format(f fmt.State, verb rune) {
f.Write([]byte(fmt.Sprintf("UserPrincipal{ID: '%s', Identity: '%s'}", u.id, u.identity))) _, _ = f.Write([]byte(fmt.Sprintf("UserPrincipal{ID: '%s', Identity: '%s'}", u.id, u.identity)))
} }
func (u *UserPrincipal) Space(spaceID string) SpaceAccessor { func (u *UserPrincipal) Space(spaceID string) SpaceAccessor {
......
...@@ -14,9 +14,7 @@ func WaitForQuit(logger *zap.Logger, finailizer func()) { ...@@ -14,9 +14,7 @@ func WaitForQuit(logger *zap.Logger, finailizer func()) {
signal.Notify(sigc, syscall.SIGTERM, os.Interrupt) signal.Notify(sigc, syscall.SIGTERM, os.Interrupt)
var signalsReceived uint var signalsReceived uint
go func() { go func() {
for { for s := range sigc {
select {
case s := <-sigc:
logger.Info("Signal received. Exiting", zap.String("Signal", s.String())) logger.Info("Signal received. Exiting", zap.String("Signal", s.String()))
signalsReceived++ signalsReceived++
...@@ -32,7 +30,6 @@ func WaitForQuit(logger *zap.Logger, finailizer func()) { ...@@ -32,7 +30,6 @@ func WaitForQuit(logger *zap.Logger, finailizer func()) {
close(donec) close(donec)
} }
} }
}
}() }()
<-donec <-donec
......
...@@ -30,7 +30,7 @@ func (m cachingMiddleware) Create(ctx context.Context, client *service.Client) ( ...@@ -30,7 +30,7 @@ func (m cachingMiddleware) Create(ctx context.Context, client *service.Client) (
cl, err = m.next.Create(ctx, client) cl, err = m.next.Create(ctx, client)
if err == nil { if err == nil {
m.cache.Remove(cl.SpaceID) _ = m.cache.Remove(cl.SpaceID)
} }
return cl, err return cl, err
} }
...@@ -44,9 +44,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, id string) ( ...@@ -44,9 +44,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, id string) (
} }
cl, err = m.next.Get(ctx, spaceId, id) cl, err = m.next.Get(ctx, spaceId, id)
if err == nil { if err == nil {
m.cache.Set(key, cl) _ = m.cache.Set(key, cl)
for _, key := range keysFromIdentities(spaceId, cl) { for _, key := range keysFromIdentities(spaceId, cl) {
m.cache.Set(key, cl) _ = m.cache.Set(key, cl)
} }
} }
return cl, err return cl, err
...@@ -64,9 +64,9 @@ func (m cachingMiddleware) GetBy(ctx context.Context, spaceId string, params *se ...@@ -64,9 +64,9 @@ func (m cachingMiddleware) GetBy(ctx context.Context, spaceId string, params *se
} }
cl, err = m.next.GetBy(ctx, spaceId, params) cl, err = m.next.GetBy(ctx, spaceId, params)
if err == nil { if err == nil {
m.cache.Set(makeKey(spaceId, cl.ID), cl) _ = m.cache.Set(makeKey(spaceId, cl.ID), cl)
for _, key := range keysFromIdentities(spaceId, cl) { for _, key := range keysFromIdentities(spaceId, cl) {
m.cache.Set(key, cl) _ = m.cache.Set(key, cl)
} }
} }
return cl, err return cl, err
...@@ -80,7 +80,7 @@ func (m cachingMiddleware) List(ctx context.Context, spaceId string) (clients [] ...@@ -80,7 +80,7 @@ func (m cachingMiddleware) List(ctx context.Context, spaceId string) (clients []
} }
clients, err = m.next.List(ctx, spaceId) clients, err = m.next.List(ctx, spaceId)
if err == nil { if err == nil {
m.cache.Set(spaceId, clients) _ = m.cache.Set(spaceId, clients)
} }
return clients, err return clients, err
} }
...@@ -90,13 +90,13 @@ func (m cachingMiddleware) Update(ctx context.Context, client *service.Client) ( ...@@ -90,13 +90,13 @@ func (m cachingMiddleware) Update(ctx context.Context, client *service.Client) (
err = m.next.Update(ctx, client) err = m.next.Update(ctx, client)
if err == nil { if err == nil {
m.cache.Remove(client.SpaceID) _ = m.cache.Remove(client.SpaceID)
value, e := m.cache.Get(makeKey(client.SpaceID, client.ID)) value, e := m.cache.Get(makeKey(client.SpaceID, client.ID))
if e == nil { if e == nil {
client := value.(*service.Client) client := value.(*service.Client)
m.cache.Remove(makeKey(client.SpaceID, client.ID)) _ = m.cache.Remove(makeKey(client.SpaceID, client.ID))
for _, key := range keysFromIdentities(client.SpaceID, client) { for _, key := range keysFromIdentities(client.SpaceID, client) {
m.cache.Remove(key) _ = m.cache.Remove(key)
} }
} }
} }
...@@ -110,12 +110,12 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, id string ...@@ -110,12 +110,12 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, id string
value, e := m.cache.Get(makeKey(spaceId, id)) value, e := m.cache.Get(makeKey(spaceId, id))
if e == nil { if e == nil {
client := value.(*service.Client) client := value.(*service.Client)
m.cache.Remove(makeKey(client.SpaceID, client.ID)) _ = m.cache.Remove(makeKey(client.SpaceID, client.ID))
for _, key := range keysFromIdentities(client.SpaceID, client) { for _, key := range keysFromIdentities(client.SpaceID, client) {
m.cache.Remove(key) _ = m.cache.Remove(key)
} }
} }
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
} }
return err return err
} }
...@@ -127,12 +127,12 @@ func (m cachingMiddleware) Enable(ctx context.Context, spaceId string, id string ...@@ -127,12 +127,12 @@ func (m cachingMiddleware) Enable(ctx context.Context, spaceId string, id string
value, e := m.cache.Get(makeKey(spaceId, id)) value, e := m.cache.Get(makeKey(spaceId, id))
if e == nil { if e == nil {
client := value.(*service.Client) client := value.(*service.Client)
m.cache.Remove(makeKey(client.SpaceID, client.ID)) _ = m.cache.Remove(makeKey(client.SpaceID, client.ID))
for _, key := range keysFromIdentities(client.SpaceID, client) { for _, key := range keysFromIdentities(client.SpaceID, client) {
m.cache.Remove(key) _ = m.cache.Remove(key)
} }
} }
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
} }
return err return err
} }
......
...@@ -317,6 +317,7 @@ func TestClientsCache(t *testing.T) { ...@@ -317,6 +317,7 @@ func TestClientsCache(t *testing.T) {
assert.NotSame(t, v2, v4, "Ожидается что после активации объект был удален из кэша и запрошен у сервиса.") assert.NotSame(t, v2, v4, "Ожидается что после активации объект был удален из кэша и запрошен у сервиса.")
v5, err := svc.GetBy(ctx, spaceID, &clients.GetByParams{OAuthClientID: clientID}) v5, err := svc.GetBy(ctx, spaceID, &clients.GetByParams{OAuthClientID: clientID})
require.NoError(t, err)
assert.NotSame(t, v3, v5, "Ожидается что после активации объект был удален из кеша и после запроса Get в кеш попал объект запрошенный заново из сервиса.") assert.NotSame(t, v3, v5, "Ожидается что после активации объект был удален из кеша и после запроса Get в кеш попал объект запрошенный заново из сервиса.")
vl3, err := svc.List(ctx, spaceID) vl3, err := svc.List(ctx, spaceID)
......
...@@ -30,8 +30,8 @@ func (m cachingMiddleware) Set(ctx context.Context, spaceId, subject, role strin ...@@ -30,8 +30,8 @@ func (m cachingMiddleware) Set(ctx context.Context, spaceId, subject, role strin
err = m.next.Set(ctx, spaceId, subject, role) err = m.next.Set(ctx, spaceId, subject, role)
if err == nil { if err == nil {
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
m.cache.Remove(subject) _ = m.cache.Remove(subject)
} }
return err return err
} }
...@@ -45,7 +45,7 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId, subject string) (ro ...@@ -45,7 +45,7 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId, subject string) (ro
} }
role, err = m.next.Get(ctx, spaceId, subject) role, err = m.next.Get(ctx, spaceId, subject)
if err == nil { if err == nil {
m.cache.Set(key, role) _ = m.cache.Set(key, role)
} }
return role, err return role, err
} }
...@@ -54,9 +54,9 @@ func (m cachingMiddleware) Remove(ctx context.Context, spaceId, subject string) ...@@ -54,9 +54,9 @@ func (m cachingMiddleware) Remove(ctx context.Context, spaceId, subject string)
err = m.next.Remove(ctx, spaceId, subject) err = m.next.Remove(ctx, spaceId, subject)
if err == nil { if err == nil {
m.cache.Remove(makeKey(spaceId, subject)) _ = m.cache.Remove(makeKey(spaceId, subject))
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
m.cache.Remove(subject) _ = m.cache.Remove(subject)
} }
return err return err
} }
...@@ -69,7 +69,7 @@ func (m cachingMiddleware) ListCollaborators(ctx context.Context, spaceId string ...@@ -69,7 +69,7 @@ func (m cachingMiddleware) ListCollaborators(ctx context.Context, spaceId string
} }
collaborators, err = m.next.ListCollaborators(ctx, spaceId) collaborators, err = m.next.ListCollaborators(ctx, spaceId)
if err == nil { if err == nil {
m.cache.Set(spaceId, collaborators) _ = m.cache.Set(spaceId, collaborators)
} }
return collaborators, err return collaborators, err
} }
...@@ -82,7 +82,7 @@ func (m cachingMiddleware) ListSpaces(ctx context.Context, subject string) (coll ...@@ -82,7 +82,7 @@ func (m cachingMiddleware) ListSpaces(ctx context.Context, subject string) (coll
} }
collaborators, err = m.next.ListSpaces(ctx, subject) collaborators, err = m.next.ListSpaces(ctx, subject)
if err == nil { if err == nil {
m.cache.Set(subject, collaborators) _ = m.cache.Set(subject, collaborators)
} }
return collaborators, err return collaborators, err
} }
...@@ -113,6 +113,7 @@ func TestCollaboratorsCache(t *testing.T) { ...@@ -113,6 +113,7 @@ func TestCollaboratorsCache(t *testing.T) {
cs.On("ListSpaces", mock.Anything, userID).Return(nil, errNotFound).Once() cs.On("ListSpaces", mock.Anything, userID).Return(nil, errNotFound).Once()
err = svc.Remove(ctx, spaceID, userID) err = svc.Remove(ctx, spaceID, userID)
require.NoError(t, err)
rl, err = svc.Get(ctx, spaceID, userID) rl, err = svc.Get(ctx, spaceID, userID)
require.Error(t, err) require.Error(t, err)
...@@ -167,6 +168,7 @@ func TestCollaboratorsCache(t *testing.T) { ...@@ -167,6 +168,7 @@ func TestCollaboratorsCache(t *testing.T) {
cs.On("ListSpaces", mock.Anything, userID).Return(nil, errNotFound).Once() cs.On("ListSpaces", mock.Anything, userID).Return(nil, errNotFound).Once()
err = svc.Remove(ctx, spaceID, userID) err = svc.Remove(ctx, spaceID, userID)
require.NoError(t, err)
rl, err = svc.Get(ctx, spaceID, userID) rl, err = svc.Get(ctx, spaceID, userID)
require.Error(t, err) require.Error(t, err)
......
...@@ -52,9 +52,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, envId string ...@@ -52,9 +52,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, envId string
if err != nil { if err != nil {
return nil, err return nil, err
} }
m.cache.Set(makeKey(coll.SpaceID, env.ID, coll.ID, opts.DisableSchemaIncludes), coll) _ = m.cache.Set(makeKey(coll.SpaceID, env.ID, coll.ID, opts.DisableSchemaIncludes), coll)
for _, al := range env.Aliases { for _, al := range env.Aliases {
m.cache.Set(makeKey(coll.SpaceID, al, coll.ID, opts.DisableSchemaIncludes), coll) _ = m.cache.Set(makeKey(coll.SpaceID, al, coll.ID, opts.DisableSchemaIncludes), coll)
} }
} }
...@@ -73,11 +73,11 @@ func (m cachingMiddleware) Update(ctx context.Context, coll *service.Collection) ...@@ -73,11 +73,11 @@ func (m cachingMiddleware) Update(ctx context.Context, coll *service.Collection)
if err != nil { if err != nil {
return err return err
} }
m.cache.Remove(makeKey(env.SpaceID, env.ID, coll.ID, true)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, coll.ID, true))
m.cache.Remove(makeKey(env.SpaceID, env.ID, coll.ID, false)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, coll.ID, false))
for _, al := range env.Aliases { for _, al := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, al, coll.ID, true)) _ = m.cache.Remove(makeKey(env.SpaceID, al, coll.ID, true))
m.cache.Remove(makeKey(env.SpaceID, al, coll.ID, false)) _ = m.cache.Remove(makeKey(env.SpaceID, al, coll.ID, false))
} }
} }
return err return err
...@@ -90,11 +90,11 @@ func (m cachingMiddleware) SetSchema(ctx context.Context, spaceId, envId, collec ...@@ -90,11 +90,11 @@ func (m cachingMiddleware) SetSchema(ctx context.Context, spaceId, envId, collec
if err != nil { if err != nil {
return err return err
} }
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false))
for _, al := range env.Aliases { for _, al := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false))
} }
} }
return err return err
...@@ -107,11 +107,11 @@ func (m cachingMiddleware) SetState(ctx context.Context, spaceId, envId, collect ...@@ -107,11 +107,11 @@ func (m cachingMiddleware) SetState(ctx context.Context, spaceId, envId, collect
if err != nil { if err != nil {
return err return err
} }
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false))
for _, al := range env.Aliases { for _, al := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false))
} }
} }
return err return err
...@@ -125,11 +125,11 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, envId str ...@@ -125,11 +125,11 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, envId str
if err != nil { if err != nil {
return err return err
} }
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID, collectionId, false))
for _, al := range env.Aliases { for _, al := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, true))
m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false)) _ = m.cache.Remove(makeKey(env.SpaceID, al, collectionId, false))
} }
} }
return err return err
......
...@@ -120,7 +120,7 @@ func DeleteMany(paths []string, value any, delim ...string) { ...@@ -120,7 +120,7 @@ func DeleteMany(paths []string, value any, delim ...string) {
return return
} }
for _, path := range paths { for _, path := range paths {
Delete(path, value, delim...) _ = Delete(path, value, delim...)
} }
} }
...@@ -245,7 +245,6 @@ func get(path []string, data any) (any, bool) { ...@@ -245,7 +245,6 @@ func get(path []string, data any) (any, bool) {
// The path is the sting with delim, for eg:, parent.child.key // The path is the sting with delim, for eg:, parent.child.key
func Keep(paths []string, data any, delim ...string) { func Keep(paths []string, data any, delim ...string) {
if len(paths) == 0 { if len(paths) == 0 {
data = nil
return return
} }
switch val := data.(type) { switch val := data.(type) {
......
...@@ -78,7 +78,8 @@ func TestDelete(t *testing.T) { ...@@ -78,7 +78,8 @@ func TestDelete(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
Delete(tt.field, tt.in) err := Delete(tt.field, tt.in)
assert.NoError(t, err)
assert.Equal(t, tt.out, tt.in) assert.Equal(t, tt.out, tt.in)
}) })
} }
......
...@@ -45,7 +45,7 @@ func TableEncode(s string, tlm map[rune]string) string { ...@@ -45,7 +45,7 @@ func TableEncode(s string, tlm map[rune]string) string {
} }
if unicode.IsUpper(r) { if unicode.IsUpper(r) {
tr = strings.Title(tr) tr = strings.Title(tr) //nolint:staticcheck // Для обработки основных языков достаточно правил работы функции strings.Title
} }
out.WriteString(tr) out.WriteString(tr)
......
...@@ -30,7 +30,7 @@ func (m cachingMiddleware) Create(ctx context.Context, env *service.Environment) ...@@ -30,7 +30,7 @@ func (m cachingMiddleware) Create(ctx context.Context, env *service.Environment)
environment, err = m.next.Create(ctx, env) environment, err = m.next.Create(ctx, env)
if err == nil { if err == nil {
m.cache.Remove(environment.SpaceID) _ = m.cache.Remove(environment.SpaceID)
} }
return environment, err return environment, err
} }
...@@ -43,9 +43,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, envId string ...@@ -43,9 +43,9 @@ func (m cachingMiddleware) Get(ctx context.Context, spaceId string, envId string
} }
environment, err = m.next.Get(ctx, spaceId, envId) environment, err = m.next.Get(ctx, spaceId, envId)
if err == nil { if err == nil {
m.cache.Set(makeKey(spaceId, environment.ID), environment) _ = m.cache.Set(makeKey(spaceId, environment.ID), environment)
for _, a := range environment.Aliases { for _, a := range environment.Aliases {
m.cache.Set(makeKey(spaceId, a), environment) _ = m.cache.Set(makeKey(spaceId, a), environment)
} }
} }
return environment, err return environment, err
...@@ -59,7 +59,7 @@ func (m cachingMiddleware) List(ctx context.Context, spaceId string) (environmen ...@@ -59,7 +59,7 @@ func (m cachingMiddleware) List(ctx context.Context, spaceId string) (environmen
} }
environments, err = m.next.List(ctx, spaceId) environments, err = m.next.List(ctx, spaceId)
if err == nil { if err == nil {
m.cache.Set(spaceId, environments) _ = m.cache.Set(spaceId, environments)
} }
return environments, err return environments, err
} }
...@@ -71,12 +71,12 @@ func (m cachingMiddleware) Update(ctx context.Context, env *service.Environment) ...@@ -71,12 +71,12 @@ func (m cachingMiddleware) Update(ctx context.Context, env *service.Environment)
value, e := m.cache.Get(makeKey(env.SpaceID, env.ID)) value, e := m.cache.Get(makeKey(env.SpaceID, env.ID))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
m.cache.Remove(env.SpaceID) _ = m.cache.Remove(env.SpaceID)
} }
return err return err
} }
...@@ -88,12 +88,12 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, envId str ...@@ -88,12 +88,12 @@ func (m cachingMiddleware) Delete(ctx context.Context, spaceId string, envId str
value, e := m.cache.Get(makeKey(spaceId, envId)) value, e := m.cache.Get(makeKey(spaceId, envId))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
} }
return err return err
} }
...@@ -105,21 +105,21 @@ func (m cachingMiddleware) SetAlias(ctx context.Context, spaceId string, envId s ...@@ -105,21 +105,21 @@ func (m cachingMiddleware) SetAlias(ctx context.Context, spaceId string, envId s
value, e := m.cache.Get(makeKey(spaceId, alias)) value, e := m.cache.Get(makeKey(spaceId, alias))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
value, e = m.cache.Get(makeKey(spaceId, envId)) value, e = m.cache.Get(makeKey(spaceId, envId))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
} }
return err return err
} }
...@@ -128,22 +128,22 @@ func (m cachingMiddleware) RemoveAlias(ctx context.Context, spaceId string, envI ...@@ -128,22 +128,22 @@ func (m cachingMiddleware) RemoveAlias(ctx context.Context, spaceId string, envI
err = m.next.RemoveAlias(ctx, spaceId, envId, alias) err = m.next.RemoveAlias(ctx, spaceId, envId, alias)
if err == nil { if err == nil {
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
value, e := m.cache.Get(makeKey(spaceId, alias)) value, e := m.cache.Get(makeKey(spaceId, alias))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
value, e = m.cache.Get(makeKey(spaceId, envId)) value, e = m.cache.Get(makeKey(spaceId, envId))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
} }
...@@ -157,11 +157,11 @@ func (m cachingMiddleware) Migrate(ctx context.Context, spaceId, envId string, o ...@@ -157,11 +157,11 @@ func (m cachingMiddleware) Migrate(ctx context.Context, spaceId, envId string, o
value, e := m.cache.Get(makeKey(spaceId, envId)) value, e := m.cache.Get(makeKey(spaceId, envId))
if e == nil { if e == nil {
env := value.(*service.Environment) env := value.(*service.Environment)
m.cache.Remove(makeKey(env.SpaceID, env.ID)) _ = m.cache.Remove(makeKey(env.SpaceID, env.ID))
for _, a := range env.Aliases { for _, a := range env.Aliases {
m.cache.Remove(makeKey(env.SpaceID, a)) _ = m.cache.Remove(makeKey(env.SpaceID, a))
} }
} }
m.cache.Remove(spaceId) _ = m.cache.Remove(spaceId)
return err return err
} }
...@@ -30,7 +30,7 @@ func (e *codeError) Format(s fmt.State, verb rune) { ...@@ -30,7 +30,7 @@ func (e *codeError) Format(s fmt.State, verb rune) {
} }
fallthrough fallthrough
case 's': case 's':
io.WriteString(s, e.Error()) _, _ = io.WriteString(s, e.Error())
case 'q': case 'q':
fmt.Fprintf(s, "%q", e.Error()) fmt.Fprintf(s, "%q", e.Error())
} }
......
...@@ -27,7 +27,7 @@ func (w *withDetail) Format(s fmt.State, verb rune) { ...@@ -27,7 +27,7 @@ func (w *withDetail) Format(s fmt.State, verb rune) {
} }
fallthrough fallthrough
case 's': case 's':
io.WriteString(s, w.Error()) _, _ = io.WriteString(s, w.Error())
case 'q': case 'q':
fmt.Fprintf(s, "%q", w.Error()) fmt.Fprintf(s, "%q", w.Error())
} }
......
...@@ -31,7 +31,7 @@ func (w *withDomain) Format(s fmt.State, verb rune) { ...@@ -31,7 +31,7 @@ func (w *withDomain) Format(s fmt.State, verb rune) {
} }
fallthrough fallthrough
case 's': case 's':
io.WriteString(s, w.Error()) _, _ = io.WriteString(s, w.Error())
case 'q': case 'q':
fmt.Fprintf(s, "%q", w.Error()) fmt.Fprintf(s, "%q", w.Error())
} }
......
...@@ -31,7 +31,7 @@ func (w *withField) Format(s fmt.State, verb rune) { ...@@ -31,7 +31,7 @@ func (w *withField) Format(s fmt.State, verb rune) {
} }
fallthrough fallthrough
case 's': case 's':
io.WriteString(s, w.Error()) _, _ = io.WriteString(s, w.Error())
case 'q': case 'q':
fmt.Fprintf(s, "%q", w.Error()) fmt.Fprintf(s, "%q", w.Error())
} }
......
...@@ -27,7 +27,7 @@ func (w *withHint) Format(s fmt.State, verb rune) { ...@@ -27,7 +27,7 @@ func (w *withHint) Format(s fmt.State, verb rune) {
} }
fallthrough fallthrough
case 's': case 's':
io.WriteString(s, w.Error()) _, _ = io.WriteString(s, w.Error())
case 'q': case 'q':
fmt.Fprintf(s, "%q", w.Error()) fmt.Fprintf(s, "%q", w.Error())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment