Skip to content

Commit

Permalink
feat: bind cardtemplate to formtemplate (#26)
Browse files Browse the repository at this point in the history
* feat(wip): cardtemplate and rbac discovery refactoring

* feat(wip): cardtemplates and formtemplates apis and client and refactoring

* feat: refactored card templates, columns, rows crds, clients, routes
  • Loading branch information
lucasepe authored Mar 25, 2024
1 parent f8ab8c9 commit 948af80
Show file tree
Hide file tree
Showing 55 changed files with 1,464 additions and 2,680 deletions.
38 changes: 28 additions & 10 deletions apis/ui/cardtemplates/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type FormTemplateRef struct {
// Name of the referenced object.
Name string `json:"name"`

// Namespace of the referenced object.
Namespace string `json:"namespace,omitempty"`
}

type Action struct {
//+kubebuilder:validation:Required
Path string `json:"path"`

// +optional
// +kubebuilder:default=GET
Verb string `json:"verb,omitempty"`
}

type Card struct {
//+kubebuilder:validation:Required
Title string `json:"title"`

//+kubebuilder:validation:Required
Content string `json:"content"`

// +optional
Expand All @@ -21,29 +40,28 @@ type Card struct {

// +optional
Tags string `json:"tags,omitempty"`

// +optional
Actions []*core.API `json:"actions,omitempty"`

// +optional
AllowedActions []string `json:"allowedActions,omitempty"`
}

// CardTemplate is a template for a Krateo UI Card widget.
type CardTemplateSpec struct {
//+kubebuilder:validation:Required
FormTemplateRef FormTemplateRef `json:"formTemplateRef"`

//+kubebuilder:validation:Required
// App is the card template info
App Card `json:"app"`

// +optional
Iterator *string `json:"iterator,omitempty"`

// CardTemplateInfo is the card template info
CardTemplateInfo Card `json:"app"`

// APIList list of api calls.
// +optional
APIList []*core.API `json:"api,omitempty"`
}

type CardTemplateStatus struct {
Cards []*Card `json:"content,omitempty"`
Cards []*Card `json:"content,omitempty"`
Actions []*Action `json:"actions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
62 changes: 44 additions & 18 deletions apis/ui/cardtemplates/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions apis/ui/formtemplates/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ func (di *DataItem) String() string {
strings.TrimSpace(di.Path), strings.TrimSpace(di.Value))
}

type Action struct {
//+kubebuilder:validation:Required
Path string `json:"path"`

// +optional
// +kubebuilder:default=GET
Verb string `json:"verb,omitempty"`
}

type FormTemplateSpec struct {
SchemaDefinitionRef *core.Reference `json:"schemaDefinitionRef"`
}
Expand All @@ -33,6 +42,7 @@ type FormTemplateStatusContent struct {

type FormTemplateStatus struct {
Content *FormTemplateStatusContent `json:"content,omitempty"`
Actions []*Action `json:"actions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
26 changes: 26 additions & 0 deletions apis/ui/formtemplates/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 25 additions & 85 deletions crds/widgets.ui.krateo.io_cardtemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,50 +78,8 @@ spec:
type: object
type: array
app:
description: CardTemplateInfo is the card template info
description: App is the card template info
properties:
actions:
items:
description: API contains external api call info.
properties:
dependOn:
type: string
endpointRef:
description: A Reference to a named object.
properties:
name:
description: Name of the referenced object.
type: string
namespace:
description: Namespace of the referenced object.
type: string
required:
- name
- namespace
type: object
headers:
items:
type: string
type: array
krateoGateway:
type: boolean
name:
type: string
path:
type: string
payload:
type: string
verb:
default: GET
type: string
required:
- name
type: object
type: array
allowedActions:
items:
type: string
type: array
color:
type: string
content:
Expand All @@ -138,58 +96,40 @@ spec:
- content
- title
type: object
formTemplateRef:
properties:
name:
description: Name of the referenced object.
type: string
namespace:
description: Namespace of the referenced object.
type: string
required:
- name
type: object
iterator:
type: string
required:
- app
- formTemplateRef
type: object
status:
properties:
actions:
items:
properties:
path:
type: string
verb:
default: GET
type: string
required:
- path
type: object
type: array
content:
items:
properties:
actions:
items:
description: API contains external api call info.
properties:
dependOn:
type: string
endpointRef:
description: A Reference to a named object.
properties:
name:
description: Name of the referenced object.
type: string
namespace:
description: Namespace of the referenced object.
type: string
required:
- name
- namespace
type: object
headers:
items:
type: string
type: array
krateoGateway:
type: boolean
name:
type: string
path:
type: string
payload:
type: string
verb:
default: GET
type: string
required:
- name
type: object
type: array
allowedActions:
items:
type: string
type: array
color:
type: string
content:
Expand Down
12 changes: 12 additions & 0 deletions crds/widgets.ui.krateo.io_formtemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ spec:
type: object
status:
properties:
actions:
items:
properties:
path:
type: string
verb:
default: GET
type: string
required:
- path
type: object
type: array
content:
properties:
instance:
Expand Down
Loading

0 comments on commit 948af80

Please sign in to comment.