mirror of https://github.com/grafana/grafana
commit
d8e58535ae
@ -0,0 +1,93 @@ |
||||
name: Deploy Storybook preview |
||||
|
||||
on: |
||||
pull_request: |
||||
paths: |
||||
- 'packages/grafana-ui/**' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
permissions: {} |
||||
|
||||
jobs: |
||||
deploy-storybook-preview: |
||||
name: Deploy Storybook preview |
||||
runs-on: ubuntu-latest |
||||
# Don't run from forks for the moment. If we find this useful we can do the workflow_run dance |
||||
# to make it work for forks. |
||||
if: github.event.pull_request.head.repo.fork == false |
||||
permissions: |
||||
contents: read |
||||
id-token: write |
||||
|
||||
env: |
||||
BUCKET_NAME: grafana-storybook-previews |
||||
|
||||
steps: |
||||
- name: Checkout code |
||||
uses: actions/checkout@v4 |
||||
with: |
||||
persist-credentials: false |
||||
|
||||
- name: Setup Node.js |
||||
uses: actions/setup-node@v4 |
||||
with: |
||||
node-version-file: '.nvmrc' |
||||
cache: 'yarn' |
||||
|
||||
- name: Cache node_modules |
||||
uses: actions/cache@v4 |
||||
with: |
||||
path: | |
||||
node_modules |
||||
key: node_modules-${{ hashFiles('yarn.lock') }} |
||||
restore-keys: | |
||||
node_modules- |
||||
|
||||
- name: Install dependencies |
||||
env: |
||||
# If the PR isn't from a fork then don't use the slower yarn checks |
||||
YARN_ENABLE_HARDENED_MODE: ${{ github.event.pull_request.head.repo.fork == false && '1' || '0' }} |
||||
run: yarn install --immutable |
||||
|
||||
- name: Build storybook |
||||
run: yarn storybook:build |
||||
|
||||
# Create the GCS folder name for the preview. Creates a consistent name for all deploys for the PR. |
||||
# Matches format of `pr_<PR_NUMBER>_<SANITIZED_BRANCH>`. |
||||
# Where `SANITIZED_BRANCH` is the branch name with only alphanumeric and hyphens, limited to 30 characters. |
||||
- name: Create deploy name |
||||
id: create-deploy-name |
||||
env: |
||||
BRANCH_NAME: ${{ github.event.pull_request.head.ref }} |
||||
PR_NUMBER: ${{ github.event.pull_request.number }} |
||||
run: | |
||||
# Convert branch name to only contain alphanumeric and hyphens |
||||
SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | tr -cs "[:alnum:]-" "-" | sed "s/^-//;s/-$//") |
||||
|
||||
# Check if SANITIZED_BRANCH is empty and fail if it is |
||||
if [ -z "$SANITIZED_BRANCH" ]; then |
||||
echo "Error: Branch name resulted in empty string after sanitization" |
||||
exit 1 |
||||
fi |
||||
|
||||
echo "deploy-name=pr_${PR_NUMBER}_${SANITIZED_BRANCH:0:30}" >> "$GITHUB_OUTPUT" |
||||
|
||||
- name: Upload Storybook |
||||
uses: grafana/shared-workflows/actions/push-to-gcs@main |
||||
with: |
||||
environment: prod |
||||
bucket: ${{ env.BUCKET_NAME }} |
||||
bucket_path: ${{ steps.create-deploy-name.outputs.deploy-name }} |
||||
path: packages/grafana-ui/dist/storybook |
||||
service_account: github-gf-storybook-preview@grafanalabs-workload-identity.iam.gserviceaccount.com |
||||
parent: false |
||||
|
||||
- name: Write summary |
||||
env: |
||||
DEPLOY_NAME: ${{ steps.create-deploy-name.outputs.deploy-name }} |
||||
run: | |
||||
echo "## Storybook preview deployed! 🚀" >> $GITHUB_STEP_SUMMARY |
||||
echo "Check it out at https://storage.googleapis.com/${BUCKET_NAME}/${DEPLOY_NAME}/index.html" >> $GITHUB_STEP_SUMMARY |
@ -0,0 +1,24 @@ |
||||
package kinds |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/apps/iam/kinds/v0alpha1" |
||||
) |
||||
|
||||
serviceaccount: { |
||||
kind: "ServiceAccount" |
||||
pluralName: "ServiceAccounts" |
||||
current: "v0alpha1" |
||||
|
||||
codegen: { |
||||
ts: { enabled: false } |
||||
go: { enabled: true } |
||||
} |
||||
|
||||
versions: { |
||||
"v0alpha1": { |
||||
schema: { |
||||
spec: v0alpha1.ServiceAccountSpec |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
package kinds |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/apps/iam/kinds/v0alpha1" |
||||
) |
||||
|
||||
team: { |
||||
kind: "Team" |
||||
pluralName: "Teams" |
||||
current: "v0alpha1" |
||||
|
||||
codegen: { |
||||
ts: { enabled: false } |
||||
go: { enabled: true } |
||||
} |
||||
|
||||
versions: { |
||||
"v0alpha1": { |
||||
schema: { |
||||
spec: v0alpha1.TeamSpec |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
package kinds |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/apps/iam/kinds/v0alpha1" |
||||
) |
||||
|
||||
teambinding: { |
||||
kind: "TeamBinding" |
||||
pluralName: "TeamBindings" |
||||
current: "v0alpha1" |
||||
|
||||
codegen: { |
||||
ts: { enabled: false } |
||||
go: { enabled: true } |
||||
} |
||||
|
||||
versions: { |
||||
"v0alpha1": { |
||||
schema: { |
||||
spec: v0alpha1.TeamBindingSpec |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
package kinds |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/apps/iam/kinds/v0alpha1" |
||||
) |
||||
|
||||
user: { |
||||
kind: "User" |
||||
pluralName: "Users" |
||||
current: "v0alpha1" |
||||
|
||||
codegen: { |
||||
ts: { enabled: false } |
||||
go: { enabled: true } |
||||
} |
||||
|
||||
versions: { |
||||
"v0alpha1": { |
||||
schema: { |
||||
spec: v0alpha1.UserSpec |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
package v0alpha1 |
||||
|
||||
ServiceAccountSpec: { |
||||
title: string |
||||
disabled: bool |
||||
} |
@ -0,0 +1,20 @@ |
||||
package v0alpha1 |
||||
|
||||
TeamBindingSpec: { |
||||
#Subject: { |
||||
// uid of the identity |
||||
name: string |
||||
// permission of the identity in the team |
||||
permission: TeamPermission |
||||
} |
||||
|
||||
subjects: [...#Subject] |
||||
teamRef: TeamRef |
||||
} |
||||
|
||||
TeamRef:{ |
||||
// Name is the unique identifier for a team. |
||||
name: string |
||||
} |
||||
|
||||
TeamPermission: "admin" | "member" |
@ -0,0 +1,6 @@ |
||||
package v0alpha1 |
||||
|
||||
TeamSpec: { |
||||
title: string |
||||
email: string |
||||
} |
@ -0,0 +1,13 @@ |
||||
package v0alpha1 |
||||
|
||||
UserSpec: { |
||||
disabled: bool |
||||
email: string |
||||
emailVerified: bool |
||||
grafanaAdmin: bool |
||||
login: string |
||||
name: string |
||||
provisioned: bool |
||||
|
||||
// What to do with salt, rands and password? |
||||
} |
@ -0,0 +1,43 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils" |
||||
) |
||||
|
||||
func (u User) AuthID() string { |
||||
meta, err := utils.MetaAccessor(&u) |
||||
if err != nil { |
||||
return "" |
||||
} |
||||
// TODO: Workaround until we move all definitions
|
||||
// After having all resource definitions here in the app, we can remove this
|
||||
// and we need to change the List authorization to use the MetaAccessor and the GetDeprecatedInternalID method
|
||||
//nolint:staticcheck
|
||||
return fmt.Sprintf("%d", meta.GetDeprecatedInternalID()) |
||||
} |
||||
|
||||
func (s ServiceAccount) AuthID() string { |
||||
meta, err := utils.MetaAccessor(&s) |
||||
if err != nil { |
||||
return "" |
||||
} |
||||
// TODO: Workaround until we move all definitions
|
||||
// After having all resource definitions here in the app, we can remove this
|
||||
// and we need to change the List authorization to use the MetaAccessor and the GetDeprecatedInternalID method
|
||||
//nolint:staticcheck
|
||||
return fmt.Sprintf("%d", meta.GetDeprecatedInternalID()) |
||||
} |
||||
|
||||
func (t Team) AuthID() string { |
||||
meta, err := utils.MetaAccessor(&t) |
||||
if err != nil { |
||||
return "" |
||||
} |
||||
// TODO: Workaround until we move all definitions
|
||||
// After having all resource definitions here in the app, we can remove this
|
||||
// and we need to change the List authorization to use the MetaAccessor and the GetDeprecatedInternalID method
|
||||
//nolint:staticcheck
|
||||
return fmt.Sprintf("%d", meta.GetDeprecatedInternalID()) |
||||
} |
@ -0,0 +1,28 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// ServiceAccountJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type ServiceAccountJSONCodec struct{} |
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*ServiceAccountJSONCodec) Read(reader io.Reader, into resource.Object) error { |
||||
return json.NewDecoder(reader).Decode(into) |
||||
} |
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*ServiceAccountJSONCodec) Write(writer io.Writer, from resource.Object) error { |
||||
return json.NewEncoder(writer).Encode(from) |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &ServiceAccountJSONCodec{} |
@ -0,0 +1,31 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
time "time" |
||||
) |
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type ServiceAccountMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// NewServiceAccountMetadata creates a new ServiceAccountMetadata object.
|
||||
func NewServiceAccountMetadata() *ServiceAccountMetadata { |
||||
return &ServiceAccountMetadata{ |
||||
Finalizers: []string{}, |
||||
Labels: map[string]string{}, |
||||
} |
||||
} |
@ -0,0 +1,319 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/apimachinery/pkg/types" |
||||
"time" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccount struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"` |
||||
|
||||
// Spec is the spec of the ServiceAccount
|
||||
Spec ServiceAccountSpec `json:"spec" yaml:"spec"` |
||||
|
||||
Status ServiceAccountStatus `json:"status" yaml:"status"` |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetSpec() any { |
||||
return o.Spec |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetSpec(spec any) error { |
||||
cast, ok := spec.(ServiceAccountSpec) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) |
||||
} |
||||
o.Spec = cast |
||||
return nil |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetSubresources() map[string]any { |
||||
return map[string]any{ |
||||
"status": o.Status, |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetSubresource(name string) (any, bool) { |
||||
switch name { |
||||
case "status": |
||||
return o.Status, true |
||||
default: |
||||
return nil, false |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetSubresource(name string, value any) error { |
||||
switch name { |
||||
case "status": |
||||
cast, ok := value.(ServiceAccountStatus) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set status type %#v, not of type ServiceAccountStatus", value) |
||||
} |
||||
o.Status = cast |
||||
return nil |
||||
default: |
||||
return fmt.Errorf("subresource '%s' does not exist", name) |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetStaticMetadata() resource.StaticMetadata { |
||||
gvk := o.GroupVersionKind() |
||||
return resource.StaticMetadata{ |
||||
Name: o.ObjectMeta.Name, |
||||
Namespace: o.ObjectMeta.Namespace, |
||||
Group: gvk.Group, |
||||
Version: gvk.Version, |
||||
Kind: gvk.Kind, |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetStaticMetadata(metadata resource.StaticMetadata) { |
||||
o.Name = metadata.Name |
||||
o.Namespace = metadata.Namespace |
||||
o.SetGroupVersionKind(schema.GroupVersionKind{ |
||||
Group: metadata.Group, |
||||
Version: metadata.Version, |
||||
Kind: metadata.Kind, |
||||
}) |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetCommonMetadata() resource.CommonMetadata { |
||||
dt := o.DeletionTimestamp |
||||
var deletionTimestamp *time.Time |
||||
if dt != nil { |
||||
deletionTimestamp = &dt.Time |
||||
} |
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any) |
||||
if o.Annotations != nil { |
||||
extraFields["annotations"] = o.Annotations |
||||
} |
||||
if o.ManagedFields != nil { |
||||
extraFields["managedFields"] = o.ManagedFields |
||||
} |
||||
if o.OwnerReferences != nil { |
||||
extraFields["ownerReferences"] = o.OwnerReferences |
||||
} |
||||
return resource.CommonMetadata{ |
||||
UID: string(o.UID), |
||||
ResourceVersion: o.ResourceVersion, |
||||
Generation: o.Generation, |
||||
Labels: o.Labels, |
||||
CreationTimestamp: o.CreationTimestamp.Time, |
||||
DeletionTimestamp: deletionTimestamp, |
||||
Finalizers: o.Finalizers, |
||||
UpdateTimestamp: o.GetUpdateTimestamp(), |
||||
CreatedBy: o.GetCreatedBy(), |
||||
UpdatedBy: o.GetUpdatedBy(), |
||||
ExtraFields: extraFields, |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetCommonMetadata(metadata resource.CommonMetadata) { |
||||
o.UID = types.UID(metadata.UID) |
||||
o.ResourceVersion = metadata.ResourceVersion |
||||
o.Generation = metadata.Generation |
||||
o.Labels = metadata.Labels |
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) |
||||
if metadata.DeletionTimestamp != nil { |
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp) |
||||
o.DeletionTimestamp = &dt |
||||
} else { |
||||
o.DeletionTimestamp = nil |
||||
} |
||||
o.Finalizers = metadata.Finalizers |
||||
if o.Annotations == nil { |
||||
o.Annotations = make(map[string]string) |
||||
} |
||||
if !metadata.UpdateTimestamp.IsZero() { |
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp) |
||||
} |
||||
if metadata.CreatedBy != "" { |
||||
o.SetCreatedBy(metadata.CreatedBy) |
||||
} |
||||
if metadata.UpdatedBy != "" { |
||||
o.SetUpdatedBy(metadata.UpdatedBy) |
||||
} |
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil { |
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok { |
||||
if cast, ok := annotations.(map[string]string); ok { |
||||
o.Annotations = cast |
||||
} |
||||
} |
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { |
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { |
||||
o.ManagedFields = cast |
||||
} |
||||
} |
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { |
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { |
||||
o.OwnerReferences = cast |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetCreatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"] |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetCreatedBy(createdBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetUpdateTimestamp() time.Time { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) |
||||
return parsed |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetUpdateTimestamp(updateTimestamp time.Time) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) |
||||
} |
||||
|
||||
func (o *ServiceAccount) GetUpdatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"] |
||||
} |
||||
|
||||
func (o *ServiceAccount) SetUpdatedBy(updatedBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy |
||||
} |
||||
|
||||
func (o *ServiceAccount) Copy() resource.Object { |
||||
return resource.CopyObject(o) |
||||
} |
||||
|
||||
func (o *ServiceAccount) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *ServiceAccount) DeepCopy() *ServiceAccount { |
||||
cpy := &ServiceAccount{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *ServiceAccount) DeepCopyInto(dst *ServiceAccount) { |
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion |
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind |
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta) |
||||
o.Spec.DeepCopyInto(&dst.Spec) |
||||
o.Status.DeepCopyInto(&dst.Status) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &ServiceAccount{} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccountList struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"` |
||||
Items []ServiceAccount `json:"items" yaml:"items"` |
||||
} |
||||
|
||||
func (o *ServiceAccountList) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *ServiceAccountList) Copy() resource.ListObject { |
||||
cpy := &ServiceAccountList{ |
||||
TypeMeta: o.TypeMeta, |
||||
Items: make([]ServiceAccount, len(o.Items)), |
||||
} |
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
if item, ok := o.Items[i].Copy().(*ServiceAccount); ok { |
||||
cpy.Items[i] = *item |
||||
} |
||||
} |
||||
return cpy |
||||
} |
||||
|
||||
func (o *ServiceAccountList) GetItems() []resource.Object { |
||||
items := make([]resource.Object, len(o.Items)) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
items[i] = &o.Items[i] |
||||
} |
||||
return items |
||||
} |
||||
|
||||
func (o *ServiceAccountList) SetItems(items []resource.Object) { |
||||
o.Items = make([]ServiceAccount, len(items)) |
||||
for i := 0; i < len(items); i++ { |
||||
o.Items[i] = *items[i].(*ServiceAccount) |
||||
} |
||||
} |
||||
|
||||
func (o *ServiceAccountList) DeepCopy() *ServiceAccountList { |
||||
cpy := &ServiceAccountList{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *ServiceAccountList) DeepCopyInto(dst *ServiceAccountList) { |
||||
resource.CopyObjectInto(dst, o) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &ServiceAccountList{} |
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *ServiceAccountSpec) DeepCopy() *ServiceAccountSpec { |
||||
cpy := &ServiceAccountSpec{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *ServiceAccountSpec) DeepCopyInto(dst *ServiceAccountSpec) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
||||
|
||||
// DeepCopy creates a full deep copy of ServiceAccountStatus
|
||||
func (s *ServiceAccountStatus) DeepCopy() *ServiceAccountStatus { |
||||
cpy := &ServiceAccountStatus{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies ServiceAccountStatus into another ServiceAccountStatus object
|
||||
func (s *ServiceAccountStatus) DeepCopyInto(dst *ServiceAccountStatus) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
@ -0,0 +1,34 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var ( |
||||
schemaServiceAccount = resource.NewSimpleSchema("iam.grafana.app", "v0alpha1", &ServiceAccount{}, &ServiceAccountList{}, resource.WithKind("ServiceAccount"), |
||||
resource.WithPlural("serviceaccounts"), resource.WithScope(resource.NamespacedScope)) |
||||
kindServiceAccount = resource.Kind{ |
||||
Schema: schemaServiceAccount, |
||||
Codecs: map[resource.KindEncoding]resource.Codec{ |
||||
resource.KindEncodingJSON: &ServiceAccountJSONCodec{}, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func ServiceAccountKind() resource.Kind { |
||||
return kindServiceAccount |
||||
} |
||||
|
||||
// Schema returns a resource.SimpleSchema representation of ServiceAccount
|
||||
func ServiceAccountSchema() *resource.SimpleSchema { |
||||
return schemaServiceAccount |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindServiceAccount |
@ -0,0 +1,14 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccountSpec struct { |
||||
Title string `json:"title"` |
||||
Disabled bool `json:"disabled"` |
||||
} |
||||
|
||||
// NewServiceAccountSpec creates a new ServiceAccountSpec object.
|
||||
func NewServiceAccountSpec() *ServiceAccountSpec { |
||||
return &ServiceAccountSpec{} |
||||
} |
@ -0,0 +1,44 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccountstatusOperatorState struct { |
||||
// 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 ServiceAccountStatusOperatorStateState `json:"state"` |
||||
// 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"` |
||||
} |
||||
|
||||
// NewServiceAccountstatusOperatorState creates a new ServiceAccountstatusOperatorState object.
|
||||
func NewServiceAccountstatusOperatorState() *ServiceAccountstatusOperatorState { |
||||
return &ServiceAccountstatusOperatorState{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccountStatus struct { |
||||
// 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]ServiceAccountstatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// NewServiceAccountStatus creates a new ServiceAccountStatus object.
|
||||
func NewServiceAccountStatus() *ServiceAccountStatus { |
||||
return &ServiceAccountStatus{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type ServiceAccountStatusOperatorStateState string |
||||
|
||||
const ( |
||||
ServiceAccountStatusOperatorStateStateSuccess ServiceAccountStatusOperatorStateState = "success" |
||||
ServiceAccountStatusOperatorStateStateInProgress ServiceAccountStatusOperatorStateState = "in_progress" |
||||
ServiceAccountStatusOperatorStateStateFailed ServiceAccountStatusOperatorStateState = "failed" |
||||
) |
@ -0,0 +1,28 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// TeamJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type TeamJSONCodec struct{} |
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*TeamJSONCodec) Read(reader io.Reader, into resource.Object) error { |
||||
return json.NewDecoder(reader).Decode(into) |
||||
} |
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*TeamJSONCodec) Write(writer io.Writer, from resource.Object) error { |
||||
return json.NewEncoder(writer).Encode(from) |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &TeamJSONCodec{} |
@ -0,0 +1,31 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
time "time" |
||||
) |
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type TeamMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// NewTeamMetadata creates a new TeamMetadata object.
|
||||
func NewTeamMetadata() *TeamMetadata { |
||||
return &TeamMetadata{ |
||||
Finalizers: []string{}, |
||||
Labels: map[string]string{}, |
||||
} |
||||
} |
@ -0,0 +1,319 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/apimachinery/pkg/types" |
||||
"time" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Team struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"` |
||||
|
||||
// Spec is the spec of the Team
|
||||
Spec TeamSpec `json:"spec" yaml:"spec"` |
||||
|
||||
Status TeamStatus `json:"status" yaml:"status"` |
||||
} |
||||
|
||||
func (o *Team) GetSpec() any { |
||||
return o.Spec |
||||
} |
||||
|
||||
func (o *Team) SetSpec(spec any) error { |
||||
cast, ok := spec.(TeamSpec) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) |
||||
} |
||||
o.Spec = cast |
||||
return nil |
||||
} |
||||
|
||||
func (o *Team) GetSubresources() map[string]any { |
||||
return map[string]any{ |
||||
"status": o.Status, |
||||
} |
||||
} |
||||
|
||||
func (o *Team) GetSubresource(name string) (any, bool) { |
||||
switch name { |
||||
case "status": |
||||
return o.Status, true |
||||
default: |
||||
return nil, false |
||||
} |
||||
} |
||||
|
||||
func (o *Team) SetSubresource(name string, value any) error { |
||||
switch name { |
||||
case "status": |
||||
cast, ok := value.(TeamStatus) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set status type %#v, not of type TeamStatus", value) |
||||
} |
||||
o.Status = cast |
||||
return nil |
||||
default: |
||||
return fmt.Errorf("subresource '%s' does not exist", name) |
||||
} |
||||
} |
||||
|
||||
func (o *Team) GetStaticMetadata() resource.StaticMetadata { |
||||
gvk := o.GroupVersionKind() |
||||
return resource.StaticMetadata{ |
||||
Name: o.ObjectMeta.Name, |
||||
Namespace: o.ObjectMeta.Namespace, |
||||
Group: gvk.Group, |
||||
Version: gvk.Version, |
||||
Kind: gvk.Kind, |
||||
} |
||||
} |
||||
|
||||
func (o *Team) SetStaticMetadata(metadata resource.StaticMetadata) { |
||||
o.Name = metadata.Name |
||||
o.Namespace = metadata.Namespace |
||||
o.SetGroupVersionKind(schema.GroupVersionKind{ |
||||
Group: metadata.Group, |
||||
Version: metadata.Version, |
||||
Kind: metadata.Kind, |
||||
}) |
||||
} |
||||
|
||||
func (o *Team) GetCommonMetadata() resource.CommonMetadata { |
||||
dt := o.DeletionTimestamp |
||||
var deletionTimestamp *time.Time |
||||
if dt != nil { |
||||
deletionTimestamp = &dt.Time |
||||
} |
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any) |
||||
if o.Annotations != nil { |
||||
extraFields["annotations"] = o.Annotations |
||||
} |
||||
if o.ManagedFields != nil { |
||||
extraFields["managedFields"] = o.ManagedFields |
||||
} |
||||
if o.OwnerReferences != nil { |
||||
extraFields["ownerReferences"] = o.OwnerReferences |
||||
} |
||||
return resource.CommonMetadata{ |
||||
UID: string(o.UID), |
||||
ResourceVersion: o.ResourceVersion, |
||||
Generation: o.Generation, |
||||
Labels: o.Labels, |
||||
CreationTimestamp: o.CreationTimestamp.Time, |
||||
DeletionTimestamp: deletionTimestamp, |
||||
Finalizers: o.Finalizers, |
||||
UpdateTimestamp: o.GetUpdateTimestamp(), |
||||
CreatedBy: o.GetCreatedBy(), |
||||
UpdatedBy: o.GetUpdatedBy(), |
||||
ExtraFields: extraFields, |
||||
} |
||||
} |
||||
|
||||
func (o *Team) SetCommonMetadata(metadata resource.CommonMetadata) { |
||||
o.UID = types.UID(metadata.UID) |
||||
o.ResourceVersion = metadata.ResourceVersion |
||||
o.Generation = metadata.Generation |
||||
o.Labels = metadata.Labels |
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) |
||||
if metadata.DeletionTimestamp != nil { |
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp) |
||||
o.DeletionTimestamp = &dt |
||||
} else { |
||||
o.DeletionTimestamp = nil |
||||
} |
||||
o.Finalizers = metadata.Finalizers |
||||
if o.Annotations == nil { |
||||
o.Annotations = make(map[string]string) |
||||
} |
||||
if !metadata.UpdateTimestamp.IsZero() { |
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp) |
||||
} |
||||
if metadata.CreatedBy != "" { |
||||
o.SetCreatedBy(metadata.CreatedBy) |
||||
} |
||||
if metadata.UpdatedBy != "" { |
||||
o.SetUpdatedBy(metadata.UpdatedBy) |
||||
} |
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil { |
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok { |
||||
if cast, ok := annotations.(map[string]string); ok { |
||||
o.Annotations = cast |
||||
} |
||||
} |
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { |
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { |
||||
o.ManagedFields = cast |
||||
} |
||||
} |
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { |
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { |
||||
o.OwnerReferences = cast |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
func (o *Team) GetCreatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"] |
||||
} |
||||
|
||||
func (o *Team) SetCreatedBy(createdBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy |
||||
} |
||||
|
||||
func (o *Team) GetUpdateTimestamp() time.Time { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) |
||||
return parsed |
||||
} |
||||
|
||||
func (o *Team) SetUpdateTimestamp(updateTimestamp time.Time) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) |
||||
} |
||||
|
||||
func (o *Team) GetUpdatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"] |
||||
} |
||||
|
||||
func (o *Team) SetUpdatedBy(updatedBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy |
||||
} |
||||
|
||||
func (o *Team) Copy() resource.Object { |
||||
return resource.CopyObject(o) |
||||
} |
||||
|
||||
func (o *Team) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *Team) DeepCopy() *Team { |
||||
cpy := &Team{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *Team) DeepCopyInto(dst *Team) { |
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion |
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind |
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta) |
||||
o.Spec.DeepCopyInto(&dst.Spec) |
||||
o.Status.DeepCopyInto(&dst.Status) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &Team{} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamList struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"` |
||||
Items []Team `json:"items" yaml:"items"` |
||||
} |
||||
|
||||
func (o *TeamList) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *TeamList) Copy() resource.ListObject { |
||||
cpy := &TeamList{ |
||||
TypeMeta: o.TypeMeta, |
||||
Items: make([]Team, len(o.Items)), |
||||
} |
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
if item, ok := o.Items[i].Copy().(*Team); ok { |
||||
cpy.Items[i] = *item |
||||
} |
||||
} |
||||
return cpy |
||||
} |
||||
|
||||
func (o *TeamList) GetItems() []resource.Object { |
||||
items := make([]resource.Object, len(o.Items)) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
items[i] = &o.Items[i] |
||||
} |
||||
return items |
||||
} |
||||
|
||||
func (o *TeamList) SetItems(items []resource.Object) { |
||||
o.Items = make([]Team, len(items)) |
||||
for i := 0; i < len(items); i++ { |
||||
o.Items[i] = *items[i].(*Team) |
||||
} |
||||
} |
||||
|
||||
func (o *TeamList) DeepCopy() *TeamList { |
||||
cpy := &TeamList{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *TeamList) DeepCopyInto(dst *TeamList) { |
||||
resource.CopyObjectInto(dst, o) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &TeamList{} |
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *TeamSpec) DeepCopy() *TeamSpec { |
||||
cpy := &TeamSpec{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *TeamSpec) DeepCopyInto(dst *TeamSpec) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
||||
|
||||
// DeepCopy creates a full deep copy of TeamStatus
|
||||
func (s *TeamStatus) DeepCopy() *TeamStatus { |
||||
cpy := &TeamStatus{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies TeamStatus into another TeamStatus object
|
||||
func (s *TeamStatus) DeepCopyInto(dst *TeamStatus) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
@ -0,0 +1,34 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var ( |
||||
schemaTeam = resource.NewSimpleSchema("iam.grafana.app", "v0alpha1", &Team{}, &TeamList{}, resource.WithKind("Team"), |
||||
resource.WithPlural("teams"), resource.WithScope(resource.NamespacedScope)) |
||||
kindTeam = resource.Kind{ |
||||
Schema: schemaTeam, |
||||
Codecs: map[resource.KindEncoding]resource.Codec{ |
||||
resource.KindEncodingJSON: &TeamJSONCodec{}, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func TeamKind() resource.Kind { |
||||
return kindTeam |
||||
} |
||||
|
||||
// Schema returns a resource.SimpleSchema representation of Team
|
||||
func TeamSchema() *resource.SimpleSchema { |
||||
return schemaTeam |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindTeam |
@ -0,0 +1,14 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamSpec struct { |
||||
Title string `json:"title"` |
||||
Email string `json:"email"` |
||||
} |
||||
|
||||
// NewTeamSpec creates a new TeamSpec object.
|
||||
func NewTeamSpec() *TeamSpec { |
||||
return &TeamSpec{} |
||||
} |
@ -0,0 +1,44 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamstatusOperatorState struct { |
||||
// 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 TeamStatusOperatorStateState `json:"state"` |
||||
// 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"` |
||||
} |
||||
|
||||
// NewTeamstatusOperatorState creates a new TeamstatusOperatorState object.
|
||||
func NewTeamstatusOperatorState() *TeamstatusOperatorState { |
||||
return &TeamstatusOperatorState{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamStatus struct { |
||||
// 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]TeamstatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// NewTeamStatus creates a new TeamStatus object.
|
||||
func NewTeamStatus() *TeamStatus { |
||||
return &TeamStatus{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamStatusOperatorStateState string |
||||
|
||||
const ( |
||||
TeamStatusOperatorStateStateSuccess TeamStatusOperatorStateState = "success" |
||||
TeamStatusOperatorStateStateInProgress TeamStatusOperatorStateState = "in_progress" |
||||
TeamStatusOperatorStateStateFailed TeamStatusOperatorStateState = "failed" |
||||
) |
@ -0,0 +1,28 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// TeamBindingJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type TeamBindingJSONCodec struct{} |
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*TeamBindingJSONCodec) Read(reader io.Reader, into resource.Object) error { |
||||
return json.NewDecoder(reader).Decode(into) |
||||
} |
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*TeamBindingJSONCodec) Write(writer io.Writer, from resource.Object) error { |
||||
return json.NewEncoder(writer).Encode(from) |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &TeamBindingJSONCodec{} |
@ -0,0 +1,31 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
time "time" |
||||
) |
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type TeamBindingMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// NewTeamBindingMetadata creates a new TeamBindingMetadata object.
|
||||
func NewTeamBindingMetadata() *TeamBindingMetadata { |
||||
return &TeamBindingMetadata{ |
||||
Finalizers: []string{}, |
||||
Labels: map[string]string{}, |
||||
} |
||||
} |
@ -0,0 +1,319 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/apimachinery/pkg/types" |
||||
"time" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBinding struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"` |
||||
|
||||
// Spec is the spec of the TeamBinding
|
||||
Spec TeamBindingSpec `json:"spec" yaml:"spec"` |
||||
|
||||
Status TeamBindingStatus `json:"status" yaml:"status"` |
||||
} |
||||
|
||||
func (o *TeamBinding) GetSpec() any { |
||||
return o.Spec |
||||
} |
||||
|
||||
func (o *TeamBinding) SetSpec(spec any) error { |
||||
cast, ok := spec.(TeamBindingSpec) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) |
||||
} |
||||
o.Spec = cast |
||||
return nil |
||||
} |
||||
|
||||
func (o *TeamBinding) GetSubresources() map[string]any { |
||||
return map[string]any{ |
||||
"status": o.Status, |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) GetSubresource(name string) (any, bool) { |
||||
switch name { |
||||
case "status": |
||||
return o.Status, true |
||||
default: |
||||
return nil, false |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) SetSubresource(name string, value any) error { |
||||
switch name { |
||||
case "status": |
||||
cast, ok := value.(TeamBindingStatus) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set status type %#v, not of type TeamBindingStatus", value) |
||||
} |
||||
o.Status = cast |
||||
return nil |
||||
default: |
||||
return fmt.Errorf("subresource '%s' does not exist", name) |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) GetStaticMetadata() resource.StaticMetadata { |
||||
gvk := o.GroupVersionKind() |
||||
return resource.StaticMetadata{ |
||||
Name: o.ObjectMeta.Name, |
||||
Namespace: o.ObjectMeta.Namespace, |
||||
Group: gvk.Group, |
||||
Version: gvk.Version, |
||||
Kind: gvk.Kind, |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) SetStaticMetadata(metadata resource.StaticMetadata) { |
||||
o.Name = metadata.Name |
||||
o.Namespace = metadata.Namespace |
||||
o.SetGroupVersionKind(schema.GroupVersionKind{ |
||||
Group: metadata.Group, |
||||
Version: metadata.Version, |
||||
Kind: metadata.Kind, |
||||
}) |
||||
} |
||||
|
||||
func (o *TeamBinding) GetCommonMetadata() resource.CommonMetadata { |
||||
dt := o.DeletionTimestamp |
||||
var deletionTimestamp *time.Time |
||||
if dt != nil { |
||||
deletionTimestamp = &dt.Time |
||||
} |
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any) |
||||
if o.Annotations != nil { |
||||
extraFields["annotations"] = o.Annotations |
||||
} |
||||
if o.ManagedFields != nil { |
||||
extraFields["managedFields"] = o.ManagedFields |
||||
} |
||||
if o.OwnerReferences != nil { |
||||
extraFields["ownerReferences"] = o.OwnerReferences |
||||
} |
||||
return resource.CommonMetadata{ |
||||
UID: string(o.UID), |
||||
ResourceVersion: o.ResourceVersion, |
||||
Generation: o.Generation, |
||||
Labels: o.Labels, |
||||
CreationTimestamp: o.CreationTimestamp.Time, |
||||
DeletionTimestamp: deletionTimestamp, |
||||
Finalizers: o.Finalizers, |
||||
UpdateTimestamp: o.GetUpdateTimestamp(), |
||||
CreatedBy: o.GetCreatedBy(), |
||||
UpdatedBy: o.GetUpdatedBy(), |
||||
ExtraFields: extraFields, |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) SetCommonMetadata(metadata resource.CommonMetadata) { |
||||
o.UID = types.UID(metadata.UID) |
||||
o.ResourceVersion = metadata.ResourceVersion |
||||
o.Generation = metadata.Generation |
||||
o.Labels = metadata.Labels |
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) |
||||
if metadata.DeletionTimestamp != nil { |
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp) |
||||
o.DeletionTimestamp = &dt |
||||
} else { |
||||
o.DeletionTimestamp = nil |
||||
} |
||||
o.Finalizers = metadata.Finalizers |
||||
if o.Annotations == nil { |
||||
o.Annotations = make(map[string]string) |
||||
} |
||||
if !metadata.UpdateTimestamp.IsZero() { |
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp) |
||||
} |
||||
if metadata.CreatedBy != "" { |
||||
o.SetCreatedBy(metadata.CreatedBy) |
||||
} |
||||
if metadata.UpdatedBy != "" { |
||||
o.SetUpdatedBy(metadata.UpdatedBy) |
||||
} |
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil { |
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok { |
||||
if cast, ok := annotations.(map[string]string); ok { |
||||
o.Annotations = cast |
||||
} |
||||
} |
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { |
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { |
||||
o.ManagedFields = cast |
||||
} |
||||
} |
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { |
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { |
||||
o.OwnerReferences = cast |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBinding) GetCreatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"] |
||||
} |
||||
|
||||
func (o *TeamBinding) SetCreatedBy(createdBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy |
||||
} |
||||
|
||||
func (o *TeamBinding) GetUpdateTimestamp() time.Time { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) |
||||
return parsed |
||||
} |
||||
|
||||
func (o *TeamBinding) SetUpdateTimestamp(updateTimestamp time.Time) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) |
||||
} |
||||
|
||||
func (o *TeamBinding) GetUpdatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"] |
||||
} |
||||
|
||||
func (o *TeamBinding) SetUpdatedBy(updatedBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy |
||||
} |
||||
|
||||
func (o *TeamBinding) Copy() resource.Object { |
||||
return resource.CopyObject(o) |
||||
} |
||||
|
||||
func (o *TeamBinding) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *TeamBinding) DeepCopy() *TeamBinding { |
||||
cpy := &TeamBinding{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *TeamBinding) DeepCopyInto(dst *TeamBinding) { |
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion |
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind |
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta) |
||||
o.Spec.DeepCopyInto(&dst.Spec) |
||||
o.Status.DeepCopyInto(&dst.Status) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &TeamBinding{} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingList struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"` |
||||
Items []TeamBinding `json:"items" yaml:"items"` |
||||
} |
||||
|
||||
func (o *TeamBindingList) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *TeamBindingList) Copy() resource.ListObject { |
||||
cpy := &TeamBindingList{ |
||||
TypeMeta: o.TypeMeta, |
||||
Items: make([]TeamBinding, len(o.Items)), |
||||
} |
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
if item, ok := o.Items[i].Copy().(*TeamBinding); ok { |
||||
cpy.Items[i] = *item |
||||
} |
||||
} |
||||
return cpy |
||||
} |
||||
|
||||
func (o *TeamBindingList) GetItems() []resource.Object { |
||||
items := make([]resource.Object, len(o.Items)) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
items[i] = &o.Items[i] |
||||
} |
||||
return items |
||||
} |
||||
|
||||
func (o *TeamBindingList) SetItems(items []resource.Object) { |
||||
o.Items = make([]TeamBinding, len(items)) |
||||
for i := 0; i < len(items); i++ { |
||||
o.Items[i] = *items[i].(*TeamBinding) |
||||
} |
||||
} |
||||
|
||||
func (o *TeamBindingList) DeepCopy() *TeamBindingList { |
||||
cpy := &TeamBindingList{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *TeamBindingList) DeepCopyInto(dst *TeamBindingList) { |
||||
resource.CopyObjectInto(dst, o) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &TeamBindingList{} |
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *TeamBindingSpec) DeepCopy() *TeamBindingSpec { |
||||
cpy := &TeamBindingSpec{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *TeamBindingSpec) DeepCopyInto(dst *TeamBindingSpec) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
||||
|
||||
// DeepCopy creates a full deep copy of TeamBindingStatus
|
||||
func (s *TeamBindingStatus) DeepCopy() *TeamBindingStatus { |
||||
cpy := &TeamBindingStatus{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies TeamBindingStatus into another TeamBindingStatus object
|
||||
func (s *TeamBindingStatus) DeepCopyInto(dst *TeamBindingStatus) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
@ -0,0 +1,34 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var ( |
||||
schemaTeamBinding = resource.NewSimpleSchema("iam.grafana.app", "v0alpha1", &TeamBinding{}, &TeamBindingList{}, resource.WithKind("TeamBinding"), |
||||
resource.WithPlural("teambindings"), resource.WithScope(resource.NamespacedScope)) |
||||
kindTeamBinding = resource.Kind{ |
||||
Schema: schemaTeamBinding, |
||||
Codecs: map[resource.KindEncoding]resource.Codec{ |
||||
resource.KindEncodingJSON: &TeamBindingJSONCodec{}, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func TeamBindingKind() resource.Kind { |
||||
return kindTeamBinding |
||||
} |
||||
|
||||
// Schema returns a resource.SimpleSchema representation of TeamBinding
|
||||
func TeamBindingSchema() *resource.SimpleSchema { |
||||
return schemaTeamBinding |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindTeamBinding |
@ -0,0 +1,49 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingspecSubject struct { |
||||
// uid of the identity
|
||||
Name string `json:"name"` |
||||
// permission of the identity in the team
|
||||
Permission TeamBindingTeamPermission `json:"permission"` |
||||
} |
||||
|
||||
// NewTeamBindingspecSubject creates a new TeamBindingspecSubject object.
|
||||
func NewTeamBindingspecSubject() *TeamBindingspecSubject { |
||||
return &TeamBindingspecSubject{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingTeamPermission string |
||||
|
||||
const ( |
||||
TeamBindingTeamPermissionAdmin TeamBindingTeamPermission = "admin" |
||||
TeamBindingTeamPermissionMember TeamBindingTeamPermission = "member" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingTeamRef struct { |
||||
// Name is the unique identifier for a team.
|
||||
Name string `json:"name"` |
||||
} |
||||
|
||||
// NewTeamBindingTeamRef creates a new TeamBindingTeamRef object.
|
||||
func NewTeamBindingTeamRef() *TeamBindingTeamRef { |
||||
return &TeamBindingTeamRef{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingSpec struct { |
||||
Subjects []TeamBindingspecSubject `json:"subjects"` |
||||
TeamRef TeamBindingTeamRef `json:"teamRef"` |
||||
} |
||||
|
||||
// NewTeamBindingSpec creates a new TeamBindingSpec object.
|
||||
func NewTeamBindingSpec() *TeamBindingSpec { |
||||
return &TeamBindingSpec{ |
||||
Subjects: []TeamBindingspecSubject{}, |
||||
TeamRef: *NewTeamBindingTeamRef(), |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingstatusOperatorState struct { |
||||
// 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 TeamBindingStatusOperatorStateState `json:"state"` |
||||
// 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"` |
||||
} |
||||
|
||||
// NewTeamBindingstatusOperatorState creates a new TeamBindingstatusOperatorState object.
|
||||
func NewTeamBindingstatusOperatorState() *TeamBindingstatusOperatorState { |
||||
return &TeamBindingstatusOperatorState{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingStatus struct { |
||||
// 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]TeamBindingstatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// NewTeamBindingStatus creates a new TeamBindingStatus object.
|
||||
func NewTeamBindingStatus() *TeamBindingStatus { |
||||
return &TeamBindingStatus{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type TeamBindingStatusOperatorStateState string |
||||
|
||||
const ( |
||||
TeamBindingStatusOperatorStateStateSuccess TeamBindingStatusOperatorStateState = "success" |
||||
TeamBindingStatusOperatorStateStateInProgress TeamBindingStatusOperatorStateState = "in_progress" |
||||
TeamBindingStatusOperatorStateStateFailed TeamBindingStatusOperatorStateState = "failed" |
||||
) |
@ -0,0 +1,28 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// UserJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type UserJSONCodec struct{} |
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*UserJSONCodec) Read(reader io.Reader, into resource.Object) error { |
||||
return json.NewDecoder(reader).Decode(into) |
||||
} |
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*UserJSONCodec) Write(writer io.Writer, from resource.Object) error { |
||||
return json.NewEncoder(writer).Encode(from) |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &UserJSONCodec{} |
@ -0,0 +1,31 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
time "time" |
||||
) |
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type UserMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// NewUserMetadata creates a new UserMetadata object.
|
||||
func NewUserMetadata() *UserMetadata { |
||||
return &UserMetadata{ |
||||
Finalizers: []string{}, |
||||
Labels: map[string]string{}, |
||||
} |
||||
} |
@ -0,0 +1,319 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/apimachinery/pkg/types" |
||||
"time" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type User struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"` |
||||
|
||||
// Spec is the spec of the User
|
||||
Spec UserSpec `json:"spec" yaml:"spec"` |
||||
|
||||
Status UserStatus `json:"status" yaml:"status"` |
||||
} |
||||
|
||||
func (o *User) GetSpec() any { |
||||
return o.Spec |
||||
} |
||||
|
||||
func (o *User) SetSpec(spec any) error { |
||||
cast, ok := spec.(UserSpec) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) |
||||
} |
||||
o.Spec = cast |
||||
return nil |
||||
} |
||||
|
||||
func (o *User) GetSubresources() map[string]any { |
||||
return map[string]any{ |
||||
"status": o.Status, |
||||
} |
||||
} |
||||
|
||||
func (o *User) GetSubresource(name string) (any, bool) { |
||||
switch name { |
||||
case "status": |
||||
return o.Status, true |
||||
default: |
||||
return nil, false |
||||
} |
||||
} |
||||
|
||||
func (o *User) SetSubresource(name string, value any) error { |
||||
switch name { |
||||
case "status": |
||||
cast, ok := value.(UserStatus) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set status type %#v, not of type UserStatus", value) |
||||
} |
||||
o.Status = cast |
||||
return nil |
||||
default: |
||||
return fmt.Errorf("subresource '%s' does not exist", name) |
||||
} |
||||
} |
||||
|
||||
func (o *User) GetStaticMetadata() resource.StaticMetadata { |
||||
gvk := o.GroupVersionKind() |
||||
return resource.StaticMetadata{ |
||||
Name: o.ObjectMeta.Name, |
||||
Namespace: o.ObjectMeta.Namespace, |
||||
Group: gvk.Group, |
||||
Version: gvk.Version, |
||||
Kind: gvk.Kind, |
||||
} |
||||
} |
||||
|
||||
func (o *User) SetStaticMetadata(metadata resource.StaticMetadata) { |
||||
o.Name = metadata.Name |
||||
o.Namespace = metadata.Namespace |
||||
o.SetGroupVersionKind(schema.GroupVersionKind{ |
||||
Group: metadata.Group, |
||||
Version: metadata.Version, |
||||
Kind: metadata.Kind, |
||||
}) |
||||
} |
||||
|
||||
func (o *User) GetCommonMetadata() resource.CommonMetadata { |
||||
dt := o.DeletionTimestamp |
||||
var deletionTimestamp *time.Time |
||||
if dt != nil { |
||||
deletionTimestamp = &dt.Time |
||||
} |
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any) |
||||
if o.Annotations != nil { |
||||
extraFields["annotations"] = o.Annotations |
||||
} |
||||
if o.ManagedFields != nil { |
||||
extraFields["managedFields"] = o.ManagedFields |
||||
} |
||||
if o.OwnerReferences != nil { |
||||
extraFields["ownerReferences"] = o.OwnerReferences |
||||
} |
||||
return resource.CommonMetadata{ |
||||
UID: string(o.UID), |
||||
ResourceVersion: o.ResourceVersion, |
||||
Generation: o.Generation, |
||||
Labels: o.Labels, |
||||
CreationTimestamp: o.CreationTimestamp.Time, |
||||
DeletionTimestamp: deletionTimestamp, |
||||
Finalizers: o.Finalizers, |
||||
UpdateTimestamp: o.GetUpdateTimestamp(), |
||||
CreatedBy: o.GetCreatedBy(), |
||||
UpdatedBy: o.GetUpdatedBy(), |
||||
ExtraFields: extraFields, |
||||
} |
||||
} |
||||
|
||||
func (o *User) SetCommonMetadata(metadata resource.CommonMetadata) { |
||||
o.UID = types.UID(metadata.UID) |
||||
o.ResourceVersion = metadata.ResourceVersion |
||||
o.Generation = metadata.Generation |
||||
o.Labels = metadata.Labels |
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) |
||||
if metadata.DeletionTimestamp != nil { |
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp) |
||||
o.DeletionTimestamp = &dt |
||||
} else { |
||||
o.DeletionTimestamp = nil |
||||
} |
||||
o.Finalizers = metadata.Finalizers |
||||
if o.Annotations == nil { |
||||
o.Annotations = make(map[string]string) |
||||
} |
||||
if !metadata.UpdateTimestamp.IsZero() { |
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp) |
||||
} |
||||
if metadata.CreatedBy != "" { |
||||
o.SetCreatedBy(metadata.CreatedBy) |
||||
} |
||||
if metadata.UpdatedBy != "" { |
||||
o.SetUpdatedBy(metadata.UpdatedBy) |
||||
} |
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil { |
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok { |
||||
if cast, ok := annotations.(map[string]string); ok { |
||||
o.Annotations = cast |
||||
} |
||||
} |
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { |
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { |
||||
o.ManagedFields = cast |
||||
} |
||||
} |
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { |
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { |
||||
o.OwnerReferences = cast |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
func (o *User) GetCreatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"] |
||||
} |
||||
|
||||
func (o *User) SetCreatedBy(createdBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy |
||||
} |
||||
|
||||
func (o *User) GetUpdateTimestamp() time.Time { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) |
||||
return parsed |
||||
} |
||||
|
||||
func (o *User) SetUpdateTimestamp(updateTimestamp time.Time) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) |
||||
} |
||||
|
||||
func (o *User) GetUpdatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"] |
||||
} |
||||
|
||||
func (o *User) SetUpdatedBy(updatedBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy |
||||
} |
||||
|
||||
func (o *User) Copy() resource.Object { |
||||
return resource.CopyObject(o) |
||||
} |
||||
|
||||
func (o *User) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *User) DeepCopy() *User { |
||||
cpy := &User{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *User) DeepCopyInto(dst *User) { |
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion |
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind |
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta) |
||||
o.Spec.DeepCopyInto(&dst.Spec) |
||||
o.Status.DeepCopyInto(&dst.Status) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &User{} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type UserList struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"` |
||||
Items []User `json:"items" yaml:"items"` |
||||
} |
||||
|
||||
func (o *UserList) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *UserList) Copy() resource.ListObject { |
||||
cpy := &UserList{ |
||||
TypeMeta: o.TypeMeta, |
||||
Items: make([]User, len(o.Items)), |
||||
} |
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
if item, ok := o.Items[i].Copy().(*User); ok { |
||||
cpy.Items[i] = *item |
||||
} |
||||
} |
||||
return cpy |
||||
} |
||||
|
||||
func (o *UserList) GetItems() []resource.Object { |
||||
items := make([]resource.Object, len(o.Items)) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
items[i] = &o.Items[i] |
||||
} |
||||
return items |
||||
} |
||||
|
||||
func (o *UserList) SetItems(items []resource.Object) { |
||||
o.Items = make([]User, len(items)) |
||||
for i := 0; i < len(items); i++ { |
||||
o.Items[i] = *items[i].(*User) |
||||
} |
||||
} |
||||
|
||||
func (o *UserList) DeepCopy() *UserList { |
||||
cpy := &UserList{} |
||||
o.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
func (o *UserList) DeepCopyInto(dst *UserList) { |
||||
resource.CopyObjectInto(dst, o) |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &UserList{} |
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *UserSpec) DeepCopy() *UserSpec { |
||||
cpy := &UserSpec{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *UserSpec) DeepCopyInto(dst *UserSpec) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
||||
|
||||
// DeepCopy creates a full deep copy of UserStatus
|
||||
func (s *UserStatus) DeepCopy() *UserStatus { |
||||
cpy := &UserStatus{} |
||||
s.DeepCopyInto(cpy) |
||||
return cpy |
||||
} |
||||
|
||||
// DeepCopyInto deep copies UserStatus into another UserStatus object
|
||||
func (s *UserStatus) DeepCopyInto(dst *UserStatus) { |
||||
resource.CopyObjectInto(dst, s) |
||||
} |
@ -0,0 +1,34 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var ( |
||||
schemaUser = resource.NewSimpleSchema("iam.grafana.app", "v0alpha1", &User{}, &UserList{}, resource.WithKind("User"), |
||||
resource.WithPlural("users"), resource.WithScope(resource.NamespacedScope)) |
||||
kindUser = resource.Kind{ |
||||
Schema: schemaUser, |
||||
Codecs: map[resource.KindEncoding]resource.Codec{ |
||||
resource.KindEncodingJSON: &UserJSONCodec{}, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func UserKind() resource.Kind { |
||||
return kindUser |
||||
} |
||||
|
||||
// Schema returns a resource.SimpleSchema representation of User
|
||||
func UserSchema() *resource.SimpleSchema { |
||||
return schemaUser |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindUser |
@ -0,0 +1,20 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type UserSpec struct { |
||||
Disabled bool `json:"disabled"` |
||||
Email string `json:"email"` |
||||
EmailVerified bool `json:"emailVerified"` |
||||
GrafanaAdmin bool `json:"grafanaAdmin"` |
||||
Login string `json:"login"` |
||||
Name string `json:"name"` |
||||
// What to do with salt, rands and password?
|
||||
Provisioned bool `json:"provisioned"` |
||||
} |
||||
|
||||
// NewUserSpec creates a new UserSpec object.
|
||||
func NewUserSpec() *UserSpec { |
||||
return &UserSpec{} |
||||
} |
@ -0,0 +1,44 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type UserstatusOperatorState struct { |
||||
// 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 UserStatusOperatorStateState `json:"state"` |
||||
// 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"` |
||||
} |
||||
|
||||
// NewUserstatusOperatorState creates a new UserstatusOperatorState object.
|
||||
func NewUserstatusOperatorState() *UserstatusOperatorState { |
||||
return &UserstatusOperatorState{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type UserStatus struct { |
||||
// 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]UserstatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// NewUserStatus creates a new UserStatus object.
|
||||
func NewUserStatus() *UserStatus { |
||||
return &UserStatus{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type UserStatusOperatorStateState string |
||||
|
||||
const ( |
||||
UserStatusOperatorStateStateSuccess UserStatusOperatorStateState = "success" |
||||
UserStatusOperatorStateStateInProgress UserStatusOperatorStateState = "in_progress" |
||||
UserStatusOperatorStateStateFailed UserStatusOperatorStateState = "failed" |
||||
) |
@ -0,0 +1,19 @@ |
||||
package v0alpha1 |
||||
|
||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type ServiceAccountTokenList struct { |
||||
metav1.TypeMeta `json:",inline"` |
||||
metav1.ListMeta `json:"metadata,omitempty"` |
||||
|
||||
Items []ServiceAccountToken `json:"items"` |
||||
} |
||||
|
||||
type ServiceAccountToken struct { |
||||
Name string `json:"name,omitempty"` |
||||
Revoked bool `json:"revoked,omitempty"` |
||||
Expires *metav1.Time `json:"expires,omitempty"` |
||||
LastUsed *metav1.Time `json:"lastUsed,omitempty"` |
||||
Created metav1.Time `json:"created"` |
||||
} |
@ -1,50 +0,0 @@ |
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
) |
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type ServiceAccount struct { |
||||
metav1.TypeMeta `json:",inline"` |
||||
metav1.ObjectMeta `json:"metadata,omitempty"` |
||||
|
||||
Spec ServiceAccountSpec `json:"spec,omitempty"` |
||||
} |
||||
|
||||
func (s ServiceAccount) AuthID() string { |
||||
return fmt.Sprintf("%d", s.Spec.InternalID) |
||||
} |
||||
|
||||
type ServiceAccountSpec struct { |
||||
Title string `json:"title,omitempty"` |
||||
Disabled bool `json:"disabled,omitempty"` |
||||
// This is currently used for authorization checks but we don't want to expose it
|
||||
InternalID int64 `json:"-"` |
||||
} |
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type ServiceAccountList struct { |
||||
metav1.TypeMeta `json:",inline"` |
||||
metav1.ListMeta `json:"metadata,omitempty"` |
||||
|
||||
Items []ServiceAccount `json:"items"` |
||||
} |
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type ServiceAccountTokenList struct { |
||||
metav1.TypeMeta `json:",inline"` |
||||
metav1.ListMeta `json:"metadata,omitempty"` |
||||
|
||||
Items []ServiceAccountToken `json:"items"` |
||||
} |
||||
|
||||
type ServiceAccountToken struct { |
||||
Name string `json:"name,omitempty"` |
||||
Revoked bool `json:"revoked,omitempty"` |
||||
Expires *metav1.Time `json:"expires,omitempty"` |
||||
LastUsed *metav1.Time `json:"lastUsed,omitempty"` |
||||
Created metav1.Time `json:"created"` |
||||
} |
@ -1,4 +1,3 @@ |
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/iam/v0alpha1,DisplayList,Items |
||||
API rule violation: list_type_missing,github.com/grafana/grafana/pkg/apis/iam/v0alpha1,TeamBindingSpec,Subjects |
||||
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/iam/v0alpha1,Display,InternalID |
||||
API rule violation: names_match,github.com/grafana/grafana/pkg/apis/iam/v0alpha1,DisplayList,Items |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue