Support for kebab case and dot notation in permission generation tool (#3222)
* support for fullstop and hypen in permissions.yaml * updated the readme.
This commit is contained in:
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
## Defining the Permissions
|
## Defining the Permissions
|
||||||
|
|
||||||
Permissions are defined in lower snake case as `permission_name:access_level`.
|
Permissions can be defined in:
|
||||||
|
- lower snake case as `permission_name:access_level`
|
||||||
|
- kebab case as `permission-name:read`
|
||||||
|
- dot notation as `permission.name:read`
|
||||||
|
|
||||||
The Permissions are initially defined as a [yaml file](analyzers/twilio/permissions.yaml).
|
The Permissions are initially defined as a [yaml file](analyzers/twilio/permissions.yaml).
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ func ToCamelCase(s string) string {
|
|||||||
parts := strings.Split(s, ":")
|
parts := strings.Split(s, ":")
|
||||||
caser := cases.Title(language.English)
|
caser := cases.Title(language.English)
|
||||||
for i := range parts {
|
for i := range parts {
|
||||||
subParts := strings.Split(parts[i], "_")
|
subParts := regexp.MustCompile(`[\_\.\-]+`).Split(parts[i], -1)
|
||||||
for j := range subParts {
|
for j := range subParts {
|
||||||
subParts[j] = caser.String(subParts[j])
|
subParts[j] = caser.String(subParts[j])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user