MCPcopy Index your code
hub / github.com/coder/coder / ExpiresAt

Method ExpiresAt

codersdk/licenses.go:39–57  ·  view source on GitHub ↗

ExpiresAt returns the expiration time of the license. If the claim is missing or has an unexpected type, an error is returned.

()

Source from the content-addressed store, hash-verified

37// ExpiresAt returns the expiration time of the license.
38// If the claim is missing or has an unexpected type, an error is returned.
39func (l *License) ExpiresAt() (time.Time, error) {
40 expClaim, ok := l.Claims[LicenseExpiryClaim]
41 if !ok {
42 return time.Time{}, xerrors.New("license_expires claim is missing")
43 }
44
45 // This claim should be a unix timestamp.
46 // Everything is already an interface{}, so we need to do some type
47 // assertions to figure out what we're dealing with.
48 if unix, ok := expClaim.(json.Number); ok {
49 i64, err := unix.Int64()
50 if err != nil {
51 return time.Time{}, xerrors.Errorf("license_expires claim is not a valid unix timestamp: %w", err)
52 }
53 return time.Unix(i64, 0), nil
54 }
55
56 return time.Time{}, xerrors.Errorf("license_expires claim has unexpected type %T", expClaim)
57}
58
59func (l *License) Trial() bool {
60 if trail, ok := l.Claims["trail"].(bool); ok {

Callers 1

NewLicenseFormatterFunction · 0.45

Calls 3

Int64Method · 0.80
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected