File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
cmd/state-svc/internal/rtusage Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11package rtusage
22
33import (
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
1416const 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
4345func (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 }
You can’t perform that action at this time.
0 commit comments