|
@@ -4,19 +4,6 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-const (
|
|
|
|
- Undefined KeyType = iota
|
|
|
|
- TimeExpiration
|
|
|
|
- Uses
|
|
|
|
- Unlimited
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-type KeyType int
|
|
|
|
-
|
|
|
|
-func (k KeyType) String() string {
|
|
|
|
- return [...]string{"Undefined", "TimeExpiration", "Uses", "Unlimited"}[k]
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// EnrollmentToken - the tokenized version of an enrollmentkey;
|
|
// EnrollmentToken - the tokenized version of an enrollmentkey;
|
|
// to be used for host registration
|
|
// to be used for host registration
|
|
type EnrollmentToken struct {
|
|
type EnrollmentToken struct {
|
|
@@ -36,7 +23,6 @@ type EnrollmentKey struct {
|
|
Unlimited bool `json:"unlimited"`
|
|
Unlimited bool `json:"unlimited"`
|
|
Tags []string `json:"tags"`
|
|
Tags []string `json:"tags"`
|
|
Token string `json:"token,omitempty"` // B64 value of EnrollmentToken
|
|
Token string `json:"token,omitempty"` // B64 value of EnrollmentToken
|
|
- Type KeyType `json:"type"`
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// APIEnrollmentKey - used to create enrollment keys via API
|
|
// APIEnrollmentKey - used to create enrollment keys via API
|
|
@@ -65,9 +51,6 @@ func (k *EnrollmentKey) IsValid() bool {
|
|
if !k.Expiration.IsZero() && time.Now().Before(k.Expiration) {
|
|
if !k.Expiration.IsZero() && time.Now().Before(k.Expiration) {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
- if k.Type == Undefined {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
|
|
|
|
return k.Unlimited
|
|
return k.Unlimited
|
|
}
|
|
}
|