3
0

Expand envoy.Resource defs for easier state access

This commit is contained in:
Tomaž Jerman
2021-12-29 13:37:14 +01:00
parent bc1550938f
commit da1828642c
20 changed files with 85 additions and 0 deletions

View File

@@ -37,6 +37,10 @@ func (t *testResource) Placeholder() bool {
return t.ph
}
func (r *testResource) Resource() interface{} {
return nil
}
func (t *testResource) ReID(ii resource.Identifiers) {
// no need for implementation
panic("not implemented")

View File

@@ -38,6 +38,10 @@ func NewAPIGateway(res *types.ApigwRoute) *APIGateway {
return r
}
func (r *APIGateway) Resource() interface{} {
return r.Res
}
func (r *APIGateway) RBACParts() (resource string, ref *Ref, path []*Ref) {
ref = r.Ref()
path = nil

View File

@@ -34,6 +34,10 @@ func NewApplication(res *types.Application) *Application {
return r
}
func (r *Application) Resource() interface{} {
return r.Res
}
func (r *Application) SysID() uint64 {
return r.Res.ID
}

View File

@@ -54,6 +54,10 @@ func NewAutomationWorkflow(res *types.Workflow) *AutomationWorkflow {
return r
}
func (r *AutomationWorkflow) Resource() interface{} {
return r.Res
}
func (r *AutomationWorkflow) AddAutomationTrigger(res *types.Trigger) *AutomationTrigger {
t := &AutomationTrigger{
base: &base{},

View File

@@ -40,6 +40,10 @@ func NewComposeChart(res *types.Chart, nsRef string, mmRef []string) *ComposeCha
return r
}
func (r *ComposeChart) Resource() interface{} {
return r.Res
}
func (r *ComposeChart) ReRef(old RefSet, new RefSet) {
r.base.ReRef(old, new)

View File

@@ -76,6 +76,10 @@ func NewComposeModule(res *types.Module, nsRef string) *ComposeModule {
return r
}
func (r *ComposeModule) Resource() interface{} {
return r.Res
}
func (r *ComposeModule) ReRef(old RefSet, new RefSet) {
r.base.ReRef(old, new)
@@ -227,6 +231,10 @@ func NewComposeModuleField(res *types.ModuleField, nsRef, modRef string) *Compos
return r
}
func (r *ComposeModuleField) Resource() interface{} {
return r.Res
}
// ComposeModuleFieldExtractUserFieldRoles is a helper to extract roles
// from the given filer options.
func ComposeModuleFieldExtractUserFieldRoles(i interface{}) []string {

View File

@@ -27,6 +27,10 @@ func NewComposeNamespace(ns *types.Namespace) *ComposeNamespace {
return r
}
func (r *ComposeNamespace) Resource() interface{} {
return r.Res
}
func (r *ComposeNamespace) RBACParts() (resource string, ref *Ref, path []*Ref) {
ref = r.Ref()
path = nil

View File

@@ -129,6 +129,10 @@ func NewComposePage(pg *types.Page, nsRef, modRef, parentRef string) *ComposePag
return r
}
func (r *ComposePage) Resource() interface{} {
return r.Res
}
func (r *ComposePage) ReRef(old RefSet, new RefSet) {
r.base.ReRef(old, new)

View File

@@ -65,6 +65,10 @@ func NewComposeRecordSet(w CrsWalker, nsRef, modRef string) *ComposeRecord {
return r
}
func (r *ComposeRecord) Resource() interface{} {
return nil
}
func (r *ComposeRecord) SetUserFlakes(uu UserstampIndex) {
r.UserFlakes = uu

View File

@@ -38,6 +38,10 @@ func (crt *composeRecordShaper) Shape(rr []Interface) ([]Interface, error) {
return ii, nil
}
func (r *composeRecordShaper) Resource() interface{} {
return nil
}
func (crt *composeRecordShaper) toResource(def *ComposeRecordTemplate, dt *ResourceDataset) Interface {
w := func(f func(r *ComposeRecordRaw) error) error {
if err := dt.P.Reset(); err != nil {

View File

@@ -55,6 +55,10 @@ func NewComposeRecordTemplate(modRef, nsRef, name string, defaultable bool, fiel
return r
}
func (r *ComposeRecordTemplate) Resource() interface{} {
return nil
}
// MapToMappingTplSet converts the given string map to a propper MappingTplSet
func MapToMappingTplSet(b map[string]string) MappingTplSet {
mp := make(MappingTplSet, 0, len(b))

View File

@@ -24,3 +24,7 @@ func NewResourceDataset(name string, p provider) *ResourceDataset {
return r
}
func (r *ResourceDataset) Resource() interface{} {
return nil
}

View File

@@ -50,6 +50,10 @@ func NewRbacRule(res *rbac.Rule, refRole string, refRes *Ref, refResource string
return r
}
func (r *RbacRule) Resource() interface{} {
return r.Res
}
func (r *RbacRule) handleComposeRecord(res *rbac.Rule, refPath []*Ref) {
// records are grouped under module

View File

@@ -43,6 +43,10 @@ func NewReport(res *types.Report) *Report {
return r
}
func (r *Report) Resource() interface{} {
return r.Res
}
func (r *Report) AddReportSource(res *types.ReportDataSource) *ReportSource {
s := &ReportSource{
base: &base{},

View File

@@ -48,6 +48,10 @@ func NewResourceTranslation(res types.ResourceTranslationSet, refResource string
return r
}
func (r *ResourceTranslation) Resource() interface{} {
return r.Res
}
func (r *ResourceTranslation) ReRef(old RefSet, new RefSet) {
r.base.ReRef(old, new)

View File

@@ -28,6 +28,10 @@ func NewRole(rl *types.Role) *Role {
return r
}
func (r *Role) Resource() interface{} {
return r.Res
}
func (r *Role) SysID() uint64 {
return r.Res.ID
}

View File

@@ -47,3 +47,11 @@ func NewSetting(s *types.SettingValue) *Setting {
return r
}
func (r *Setting) Resource() interface{} {
return r.Res
}
func (r *Settings) Resource() interface{} {
return r.Res
}

View File

@@ -28,6 +28,10 @@ func NewTemplate(t *types.Template) *Template {
return r
}
func (r *Template) Resource() interface{} {
return r.Res
}
func (r *Template) SysID() uint64 {
return r.Res.ID
}

View File

@@ -8,6 +8,7 @@ type (
Interface interface {
Identifiers() Identifiers
ResourceType() string
Resource() interface{}
Refs() RefSet
MarkPlaceholder()
Placeholder() bool

View File

@@ -28,6 +28,10 @@ func NewUser(u *types.User) *User {
return r
}
func (r *User) Resource() interface{} {
return r.Res
}
func (r *User) SysID() uint64 {
return r.Res.ID
}