MCPcopy Index your code
hub / github.com/coder/coder / generateRBAC

Function generateRBAC

scripts/typegen/main.go:90–115  ·  view source on GitHub ↗
(tmpl string)

Source from the content-addressed store, hash-verified

88}
89
90func generateRBAC(tmpl string) ([]byte, error) {
91 formatSource := format.Source
92 var source string
93 switch strings.ToLower(tmpl) {
94 case "codersdk":
95 source = codersdkTemplate
96 case "object":
97 source = rbacObjectTemplate
98 case "typescript":
99 source = typescriptTemplate
100 formatSource = func(src []byte) ([]byte, error) {
101 // No typescript formatting
102 return src, nil
103 }
104 case "scopenames":
105 source = scopenamesTemplate
106 default:
107 return nil, xerrors.Errorf("%q is not a valid RBAC template target", tmpl)
108 }
109
110 out, err := generateRbacObjects(source)
111 if err != nil {
112 return nil, err
113 }
114 return formatSource(out)
115}
116
117func generateCountries() ([]byte, error) {
118 tmpl, err := template.New("countries.tstmpl").Parse(countriesTemplate)

Callers 1

mainFunction · 0.85

Calls 2

generateRbacObjectsFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected