Skip to content

Commit d18942f

Browse files
authored
Merge pull request #2335 from ActiveState/DX-1538
Don't check for usage when not authenticated
2 parents e3972de + 5950dc4 commit d18942f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/state-svc/internal/rtusage/rtusage.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package rtusage
22

33
import (
4+
"time"
5+
6+
"github.com/patrickmn/go-cache"
7+
48
"github.com/ActiveState/cli/internal/errs"
59
"github.com/ActiveState/cli/internal/logging"
610
"github.com/ActiveState/cli/pkg/platform/api/graphql"
711
"github.com/ActiveState/cli/pkg/platform/api/graphql/model"
812
"github.com/ActiveState/cli/pkg/platform/api/graphql/request"
913
"github.com/ActiveState/cli/pkg/platform/authentication"
10-
"github.com/patrickmn/go-cache"
11-
"time"
1214
)
1315

1416
const cacheKey = "runtime-usage-"
@@ -41,6 +43,12 @@ func NewChecker(configuration configurable, auth *authentication.Auth) *Checker
4143

4244
// Check will check the runtime usage for the given organization, it may return a cached result
4345
func (c *Checker) Check(organizationName string) (*model.RuntimeUsage, error) {
46+
if !c.auth.Authenticated() {
47+
// Usage information can only be given to authenticated users, and the API doesn't support authentication errors
48+
// so we just don't even attempt it if not authenticated.
49+
return nil, nil
50+
}
51+
4452
if cached, ok := c.cache.Get(cacheKey + organizationName); ok {
4553
return cached.(*model.RuntimeUsage), nil
4654
}

0 commit comments

Comments
 (0)