mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
Schema: Remove ServiceAccount kind (#69194)
remove service account kind
This commit is contained in:
parent
778963849e
commit
51107e9cab
@ -1,41 +0,0 @@
|
||||
package kind
|
||||
|
||||
name: "ServiceAccount"
|
||||
maturity: "merged"
|
||||
description: "system account"
|
||||
|
||||
lineage: schemas: [{
|
||||
version: [0, 0]
|
||||
schema: {
|
||||
spec: {
|
||||
// ID is the unique identifier of the service account in the database.
|
||||
id: int64 @grafanamaturity(ToMetadata="sys")
|
||||
// OrgId is the ID of an organisation the service account belongs to.
|
||||
orgId: int64 @grafanamaturity(ToMetadata="sys")
|
||||
// Name of the service account.
|
||||
name: string
|
||||
// Login of the service account.
|
||||
login: string
|
||||
// IsDisabled indicates if the service account is disabled.
|
||||
isDisabled: bool
|
||||
// Role is the Grafana organization role of the service account which can be 'Viewer', 'Editor', 'Admin'.
|
||||
role: #OrgRole @grafanamaturity(ToMetadata="kind")
|
||||
// Tokens is the number of active tokens for the service account.
|
||||
// Tokens are used to authenticate the service account against Grafana.
|
||||
tokens: int64 @grafanamaturity(ToMetadata="kind")
|
||||
// AvatarUrl is the service account's avatar URL. It allows the frontend to display a picture in front
|
||||
// of the service account.
|
||||
avatarUrl: string @grafanamaturity(ToMetadata="kind")
|
||||
// AccessControl metadata associated with a given resource.
|
||||
accessControl?: {
|
||||
[string]: bool @grafanamaturity(ToMetadata="sys")
|
||||
}
|
||||
|
||||
// Teams is a list of teams the service account belongs to.
|
||||
teams?: [...string] @grafanamaturity(ToMetadata="sys")
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
// OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'.
|
||||
#OrgRole: "Admin" | "Editor" | "Viewer" @cuetsy(kind="type")
|
||||
}
|
||||
}]
|
@ -151,14 +151,5 @@ export type {
|
||||
RoleBindingSubject
|
||||
} from './raw/rolebinding/x/rolebinding_types.gen';
|
||||
|
||||
// Raw generated types from ServiceAccount kind.
|
||||
export type {
|
||||
ServiceAccount,
|
||||
OrgRole
|
||||
} from './raw/serviceaccount/x/serviceaccount_types.gen';
|
||||
|
||||
// Raw generated enums and default consts from serviceaccount kind.
|
||||
export { defaultServiceAccount } from './raw/serviceaccount/x/serviceaccount_types.gen';
|
||||
|
||||
// Raw generated types from Team kind.
|
||||
export type { Team } from './raw/team/x/team_types.gen';
|
||||
|
@ -1,63 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// TSResourceJenny
|
||||
// LatestMajorsOrXJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
/**
|
||||
* OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'.
|
||||
*/
|
||||
export type OrgRole = ('Admin' | 'Editor' | 'Viewer');
|
||||
|
||||
export interface ServiceAccount {
|
||||
/**
|
||||
* AccessControl metadata associated with a given resource.
|
||||
*/
|
||||
accessControl?: Record<string, boolean>;
|
||||
/**
|
||||
* AvatarUrl is the service account's avatar URL. It allows the frontend to display a picture in front
|
||||
* of the service account.
|
||||
*/
|
||||
avatarUrl: string;
|
||||
/**
|
||||
* ID is the unique identifier of the service account in the database.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* IsDisabled indicates if the service account is disabled.
|
||||
*/
|
||||
isDisabled: boolean;
|
||||
/**
|
||||
* Login of the service account.
|
||||
*/
|
||||
login: string;
|
||||
/**
|
||||
* Name of the service account.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* OrgId is the ID of an organisation the service account belongs to.
|
||||
*/
|
||||
orgId: number;
|
||||
/**
|
||||
* Role is the Grafana organization role of the service account which can be 'Viewer', 'Editor', 'Admin'.
|
||||
*/
|
||||
role: OrgRole;
|
||||
/**
|
||||
* Teams is a list of teams the service account belongs to.
|
||||
*/
|
||||
teams?: Array<string>;
|
||||
/**
|
||||
* Tokens is the number of active tokens for the service account.
|
||||
* Tokens are used to authenticate the service account against Grafana.
|
||||
*/
|
||||
tokens: number;
|
||||
}
|
||||
|
||||
export const defaultServiceAccount: Partial<ServiceAccount> = {
|
||||
teams: [],
|
||||
};
|
@ -1,40 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/kinds"
|
||||
)
|
||||
|
||||
// Resource is the kubernetes style representation of ServiceAccount. (TODO be better)
|
||||
type K8sResource = kinds.GrafanaResource[Spec, Status]
|
||||
|
||||
// NewResource creates a new instance of the resource with a given name (UID)
|
||||
func NewK8sResource(name string, s *Spec) K8sResource {
|
||||
return K8sResource{
|
||||
Kind: "ServiceAccount",
|
||||
APIVersion: "v0.0-alpha",
|
||||
Metadata: kinds.GrafanaResourceMetadata{
|
||||
Name: name,
|
||||
Annotations: make(map[string]string),
|
||||
Labels: make(map[string]string),
|
||||
},
|
||||
Spec: s,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Resource is the wire representation of ServiceAccount.
|
||||
// It currently will soon be merged into the k8s flavor (TODO be better)
|
||||
type Resource struct {
|
||||
Metadata Metadata `json:"metadata"`
|
||||
Spec Spec `json:"spec"`
|
||||
Status Status `json:"status"`
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// CoreKindJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount
|
||||
|
||||
import (
|
||||
"github.com/grafana/kindsys"
|
||||
"github.com/grafana/thema"
|
||||
"github.com/grafana/thema/vmux"
|
||||
|
||||
"github.com/grafana/grafana/pkg/cuectx"
|
||||
)
|
||||
|
||||
// rootrel is the relative path from the grafana repository root to the
|
||||
// directory containing the .cue files in which this kind is defined. Necessary
|
||||
// for runtime errors related to the definition and/or lineage to provide
|
||||
// a real path to the correct .cue file.
|
||||
const rootrel string = "kinds/serviceaccount"
|
||||
|
||||
// TODO standard generated docs
|
||||
type Kind struct {
|
||||
kindsys.Core
|
||||
lin thema.ConvergentLineage[*Resource]
|
||||
jcodec vmux.Codec
|
||||
valmux vmux.ValueMux[*Resource]
|
||||
}
|
||||
|
||||
// type guard - ensure generated Kind type satisfies the kindsys.Core interface
|
||||
var _ kindsys.Core = &Kind{}
|
||||
|
||||
// TODO standard generated docs
|
||||
func NewKind(rt *thema.Runtime, opts ...thema.BindOption) (*Kind, error) {
|
||||
def, err := cuectx.LoadCoreKindDef(rootrel, rt.Context(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k := &Kind{}
|
||||
k.Core, err = kindsys.BindCore(rt, def, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Get the thema.Schema that the meta says is in the current version (which
|
||||
// codegen ensures is always the latest)
|
||||
cursch := thema.SchemaP(k.Core.Lineage(), def.Properties.CurrentVersion)
|
||||
tsch, err := thema.BindType(cursch, &Resource{})
|
||||
if err != nil {
|
||||
// Should be unreachable, modulo bugs in the Thema->Go code generator
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k.jcodec = vmux.NewJSONCodec("serviceaccount.json")
|
||||
k.lin = tsch.ConvergentLineage()
|
||||
k.valmux = vmux.NewValueMux(k.lin.TypedSchema(), k.jcodec)
|
||||
return k, nil
|
||||
}
|
||||
|
||||
// ConvergentLineage returns the same [thema.Lineage] as Lineage, but bound (see [thema.BindType])
|
||||
// to the the ServiceAccount [Resource] type generated from the current schema, v0.0.
|
||||
func (k *Kind) ConvergentLineage() thema.ConvergentLineage[*Resource] {
|
||||
return k.lin
|
||||
}
|
||||
|
||||
// JSONValueMux is a version multiplexer that maps a []byte containing JSON data
|
||||
// at any schematized dashboard version to an instance of ServiceAccount [Resource].
|
||||
//
|
||||
// Validation and translation errors emitted from this func will identify the
|
||||
// input bytes as "dashboard.json".
|
||||
//
|
||||
// This is a thin wrapper around Thema's [vmux.ValueMux].
|
||||
func (k *Kind) JSONValueMux(b []byte) (*Resource, thema.TranslationLacunas, error) {
|
||||
return k.valmux(b)
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Metadata defines model for Metadata.
|
||||
type Metadata struct {
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreationTimestamp time.Time `json:"creationTimestamp"`
|
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
|
||||
|
||||
// extraFields is reserved for any fields that are pulled from the API server metadata but do not have concrete fields in the CUE metadata
|
||||
ExtraFields map[string]interface{} `json:"extraFields"`
|
||||
Finalizers []string `json:"finalizers"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
ResourceVersion string `json:"resourceVersion"`
|
||||
Uid string `json:"uid"`
|
||||
UpdateTimestamp time.Time `json:"updateTimestamp"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
}
|
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type KubeObjectMetadata struct {
|
||||
CreationTimestamp time.Time `json:"creationTimestamp"`
|
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
|
||||
Finalizers []string `json:"finalizers"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
ResourceVersion string `json:"resourceVersion"`
|
||||
Uid string `json:"uid"`
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount
|
||||
|
||||
// Defines values for OrgRole.
|
||||
const (
|
||||
OrgRoleAdmin OrgRole = "Admin"
|
||||
OrgRoleEditor OrgRole = "Editor"
|
||||
OrgRoleViewer OrgRole = "Viewer"
|
||||
)
|
||||
|
||||
// OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'.
|
||||
type OrgRole string
|
||||
|
||||
// Spec defines model for Spec.
|
||||
type Spec struct {
|
||||
// AccessControl metadata associated with a given resource.
|
||||
AccessControl map[string]bool `json:"accessControl,omitempty"`
|
||||
|
||||
// AvatarUrl is the service account's avatar URL. It allows the frontend to display a picture in front
|
||||
// of the service account.
|
||||
AvatarUrl string `json:"avatarUrl"`
|
||||
|
||||
// ID is the unique identifier of the service account in the database.
|
||||
Id int64 `json:"id"`
|
||||
|
||||
// IsDisabled indicates if the service account is disabled.
|
||||
IsDisabled bool `json:"isDisabled"`
|
||||
|
||||
// Login of the service account.
|
||||
Login string `json:"login"`
|
||||
|
||||
// Name of the service account.
|
||||
Name string `json:"name"`
|
||||
|
||||
// OrgId is the ID of an organisation the service account belongs to.
|
||||
OrgId int64 `json:"orgId"`
|
||||
|
||||
// OrgRole is a Grafana Organization Role which can be 'Viewer', 'Editor', 'Admin'.
|
||||
Role OrgRole `json:"role"`
|
||||
|
||||
// Teams is a list of teams the service account belongs to.
|
||||
Teams []string `json:"teams,omitempty"`
|
||||
|
||||
// Tokens is the number of active tokens for the service account.
|
||||
// Tokens are used to authenticate the service account against Grafana.
|
||||
Tokens int64 `json:"tokens"`
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// kinds/gen.go
|
||||
// Using jennies:
|
||||
// GoResourceTypes
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
package serviceaccount
|
||||
|
||||
// Defines values for OperatorStateState.
|
||||
const (
|
||||
OperatorStateStateFailed OperatorStateState = "failed"
|
||||
OperatorStateStateInProgress OperatorStateState = "in_progress"
|
||||
OperatorStateStateSuccess OperatorStateState = "success"
|
||||
)
|
||||
|
||||
// Defines values for StatusOperatorStateState.
|
||||
const (
|
||||
StatusOperatorStateStateFailed StatusOperatorStateState = "failed"
|
||||
StatusOperatorStateStateInProgress StatusOperatorStateState = "in_progress"
|
||||
StatusOperatorStateStateSuccess StatusOperatorStateState = "success"
|
||||
)
|
||||
|
||||
// OperatorState defines model for OperatorState.
|
||||
type OperatorState struct {
|
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"`
|
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"`
|
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State OperatorStateState `json:"state"`
|
||||
}
|
||||
|
||||
// OperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type OperatorStateState string
|
||||
|
||||
// Status defines model for Status.
|
||||
type Status struct {
|
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
|
||||
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]StatusOperatorState `json:"operatorStates,omitempty"`
|
||||
}
|
||||
|
||||
// StatusOperatorState defines model for status.#OperatorState.
|
||||
type StatusOperatorState struct {
|
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"`
|
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"`
|
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"`
|
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State StatusOperatorStateState `json:"state"`
|
||||
}
|
||||
|
||||
// StatusOperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
type StatusOperatorStateState string
|
@ -21,7 +21,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/kinds/publicdashboard"
|
||||
"github.com/grafana/grafana/pkg/kinds/role"
|
||||
"github.com/grafana/grafana/pkg/kinds/rolebinding"
|
||||
"github.com/grafana/grafana/pkg/kinds/serviceaccount"
|
||||
"github.com/grafana/grafana/pkg/kinds/team"
|
||||
"github.com/grafana/kindsys"
|
||||
"github.com/grafana/thema"
|
||||
@ -53,7 +52,6 @@ type Base struct {
|
||||
publicdashboard *publicdashboard.Kind
|
||||
role *role.Kind
|
||||
rolebinding *rolebinding.Kind
|
||||
serviceaccount *serviceaccount.Kind
|
||||
team *team.Kind
|
||||
}
|
||||
|
||||
@ -68,7 +66,6 @@ var (
|
||||
_ kindsys.Core = &publicdashboard.Kind{}
|
||||
_ kindsys.Core = &role.Kind{}
|
||||
_ kindsys.Core = &rolebinding.Kind{}
|
||||
_ kindsys.Core = &serviceaccount.Kind{}
|
||||
_ kindsys.Core = &team.Kind{}
|
||||
)
|
||||
|
||||
@ -117,11 +114,6 @@ func (b *Base) RoleBinding() *rolebinding.Kind {
|
||||
return b.rolebinding
|
||||
}
|
||||
|
||||
// ServiceAccount returns the [kindsys.Interface] implementation for the serviceaccount kind.
|
||||
func (b *Base) ServiceAccount() *serviceaccount.Kind {
|
||||
return b.serviceaccount
|
||||
}
|
||||
|
||||
// Team returns the [kindsys.Interface] implementation for the team kind.
|
||||
func (b *Base) Team() *team.Kind {
|
||||
return b.team
|
||||
@ -185,12 +177,6 @@ func doNewBase(rt *thema.Runtime) *Base {
|
||||
}
|
||||
reg.all = append(reg.all, reg.rolebinding)
|
||||
|
||||
reg.serviceaccount, err = serviceaccount.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the serviceaccount Kind: %s", err))
|
||||
}
|
||||
reg.all = append(reg.all, reg.serviceaccount)
|
||||
|
||||
reg.team, err = team.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the team Kind: %s", err))
|
||||
|
Loading…
Reference in New Issue
Block a user