(tmpl string)
| 88 | } |
| 89 | |
| 90 | func 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 | |
| 117 | func generateCountries() ([]byte, error) { |
| 118 | tmpl, err := template.New("countries.tstmpl").Parse(countriesTemplate) |
no test coverage detected