feat: add schema for key rotation (#14662)

This commit is contained in:
Jon Ayers
2024-09-17 18:08:18 +01:00
committed by GitHub
parent 45420b95f3
commit 45160c7679
29 changed files with 977 additions and 2 deletions
+70
View File
@@ -339,6 +339,67 @@ func AllBuildReasonValues() []BuildReason {
}
}
type CryptoKeyFeature string
const (
CryptoKeyFeatureWorkspaceApps CryptoKeyFeature = "workspace_apps"
CryptoKeyFeatureOidcConvert CryptoKeyFeature = "oidc_convert"
CryptoKeyFeatureTailnetResume CryptoKeyFeature = "tailnet_resume"
)
func (e *CryptoKeyFeature) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = CryptoKeyFeature(s)
case string:
*e = CryptoKeyFeature(s)
default:
return fmt.Errorf("unsupported scan type for CryptoKeyFeature: %T", src)
}
return nil
}
type NullCryptoKeyFeature struct {
CryptoKeyFeature CryptoKeyFeature `json:"crypto_key_feature"`
Valid bool `json:"valid"` // Valid is true if CryptoKeyFeature is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullCryptoKeyFeature) Scan(value interface{}) error {
if value == nil {
ns.CryptoKeyFeature, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.CryptoKeyFeature.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullCryptoKeyFeature) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.CryptoKeyFeature), nil
}
func (e CryptoKeyFeature) Valid() bool {
switch e {
case CryptoKeyFeatureWorkspaceApps,
CryptoKeyFeatureOidcConvert,
CryptoKeyFeatureTailnetResume:
return true
}
return false
}
func AllCryptoKeyFeatureValues() []CryptoKeyFeature {
return []CryptoKeyFeature{
CryptoKeyFeatureWorkspaceApps,
CryptoKeyFeatureOidcConvert,
CryptoKeyFeatureTailnetResume,
}
}
type DisplayApp string
const (
@@ -2043,6 +2104,15 @@ type AuditLog struct {
ResourceIcon string `db:"resource_icon" json:"resource_icon"`
}
type CryptoKey struct {
Feature CryptoKeyFeature `db:"feature" json:"feature"`
Sequence int32 `db:"sequence" json:"sequence"`
Secret sql.NullString `db:"secret" json:"secret"`
SecretKeyID sql.NullString `db:"secret_key_id" json:"secret_key_id"`
StartsAt time.Time `db:"starts_at" json:"starts_at"`
DeletesAt sql.NullTime `db:"deletes_at" json:"deletes_at"`
}
// Custom roles allow dynamic roles expanded at runtime
type CustomRole struct {
Name string `db:"name" json:"name"`