Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change role template vars to lowercase #53

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions api/ephemeral-access/v1alpha1/roletemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,15 @@ func (rt *RoleTemplate) Render(projName, appName, appNs string) (*RoleTemplate,
}

func (rt *RoleTemplate) execTemplate(tmpl *template.Template, projName, appName, appNs string) (string, error) {
type vars struct {
Role string
Project string
Application string
Namespace string
}
roleName := rt.AppProjectRoleName(appName, appNs)
v := vars{
Role: fmt.Sprintf("proj:%s:%s", projName, roleName),
Project: projName,
Application: appName,
Namespace: appNs,
vars := map[string]string{
"role": fmt.Sprintf("proj:%s:%s", projName, roleName),
"project": projName,
"application": appName,
"namespace": appNs,
}
var s strings.Builder
err := tmpl.Execute(&s, v)
err := tmpl.Execute(&s, vars)
if err != nil {
return "", err
}
Expand Down
24 changes: 12 additions & 12 deletions internal/controller/accessrequest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ var _ = Describe("AccessRequest Controller", func() {
var f *fixture
var r resources
policies := []string{
"p, {{.Role}}, applications, sync, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, action/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, delete/*/Pod/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, logs, get, {{.Project}}/{{.Namespace}}/{{.Application}}, allow",
"p, {{.role}}, applications, sync, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, action/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, delete/*/Pod/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, logs, get, {{.project}}/{{.namespace}}/{{.application}}, allow",
}

When("The subject has the necessary access", func() {
Expand Down Expand Up @@ -278,10 +278,10 @@ var _ = Describe("AccessRequest Controller", func() {
var f *fixture
var r resources
policies := []string{
"p, {{.Role}}, applications, sync, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, action/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, delete/*/Pod/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, logs, get, {{.Project}}/{{.Namespace}}/{{.Application}}, allow",
"p, {{.role}}, applications, sync, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, action/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, delete/*/Pod/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, logs, get, {{.project}}/{{.namespace}}/{{.application}}, allow",
}

When("protected fields values change after applied", func() {
Expand Down Expand Up @@ -383,10 +383,10 @@ var _ = Describe("AccessRequest Controller", func() {
var f *fixture
var r resources
policies := []string{
"p, {{.Role}}, applications, sync, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, action/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, applications, delete/*/Pod/*, {{.Project}}/{{.Application}}, allow",
"p, {{.Role}}, logs, get, {{.Project}}/{{.Namespace}}/{{.Application}}, allow",
"p, {{.role}}, applications, sync, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, action/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, applications, delete/*/Pod/*, {{.project}}/{{.application}}, allow",
"p, {{.role}}, logs, get, {{.project}}/{{.namespace}}/{{.application}}, allow",
}

When("used by multiple AccessRequests", func() {
Expand Down
Loading