Skip to content

Update template method API #14097

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ec9db0e
Implement notification template update auditing
dannykopping Jul 25, 2024
a7b400b
Add notification preferences migrations
dannykopping Jul 23, 2024
d88ab8b
Add preferences queries
dannykopping Jul 23, 2024
e6e4702
Allow notification templates to be auditable
dannykopping Jul 25, 2024
e9d904d
Add kind to notification_templates and query to retrieve templates by…
dannykopping Jul 26, 2024
b5a5932
Remove redundant suffix on trigger name
dannykopping Jul 29, 2024
eff74a2
Add notification preferences RBAC role
dannykopping Jul 29, 2024
af75c74
UpdateUserNotificationPreferences
dannykopping Jul 29, 2024
65e8546
RBAC for notification templates & preferences
dannykopping Aug 1, 2024
20e55d5
CI
dannykopping Aug 1, 2024
8061685
Self-review, appeasing CI
dannykopping Aug 1, 2024
b9f4ea6
Self-review, appeasing CI
dannykopping Aug 1, 2024
77cfe3e
Merge branch 'main' of https://github.com/coder/coder into dk/notific…
dannykopping Aug 2, 2024
c30f562
CI
dannykopping Aug 2, 2024
95960ca
Fixture, add composite primary key
dannykopping Aug 2, 2024
46a6d51
Merge branch 'dk/notification-prefs/db-audit' of github.com:coder/cod…
dannykopping Aug 2, 2024
76d4ca5
Self-review
dannykopping Aug 2, 2024
4a795e0
fix: typo in notification template (#14108)
mtojek Aug 2, 2024
6f4f3e4
chore: skip dogfood workflow for dependabot PRs (#14111)
matifali Aug 2, 2024
f7a102e
Update template method API
dannykopping Jul 25, 2024
1650818
Template method update tests
dannykopping Jul 29, 2024
62e1ad2
make gen
dannykopping Jul 29, 2024
c8ce53a
Using "kind" not "is_system"
dannykopping Jul 29, 2024
72cc4f1
Group routes in AGPL router
dannykopping Jul 29, 2024
a28ee3a
Use PUT since this endpoint is idempotent
dannykopping Jul 29, 2024
3e27046
Only use pg when necessary
dannykopping Aug 1, 2024
7c06846
Fix notification settings test
dannykopping Aug 1, 2024
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
3 changes: 1 addition & 2 deletions .github/workflows/dogfood.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:
- "flake.lock"
- "flake.nix"
pull_request:
branches-ignore:
- "dependabot/**"
paths:
- "dogfood/**"
- ".github/workflows/dogfood.yaml"
Expand All @@ -21,6 +19,7 @@ on:

jobs:
build_image:
if: github.actor != 'dependabot[bot]' # Skip Dependabot PRs
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
88 changes: 86 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 78 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/audit/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type Auditable interface {
database.OAuth2ProviderAppSecret |
database.CustomRole |
database.AuditableOrganizationMember |
database.Organization
database.Organization |
database.NotificationTemplate
}

// Map is a map of changed fields in an audited resource. It maps field names to
Expand Down
9 changes: 9 additions & 0 deletions coderd/audit/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"golang.org/x/xerrors"

"cdr.dev/slog"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/httpmw"

Check failure on line 22 in coderd/audit/request.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/coder/coder/v2/coderd/httpmw (-: # github.com/coder/coder/v2/coderd/httpmw
"github.com/coder/coder/v2/coderd/tracing"
)

Expand Down Expand Up @@ -117,6 +118,8 @@
return typed.Username
case database.Organization:
return typed.Name
case database.NotificationTemplate:
return typed.Name
default:
panic(fmt.Sprintf("unknown resource %T for ResourceTarget", tgt))
}
Expand Down Expand Up @@ -163,6 +166,8 @@
return typed.UserID
case database.Organization:
return typed.ID
case database.NotificationTemplate:
return typed.ID
default:
panic(fmt.Sprintf("unknown resource %T for ResourceID", tgt))
}
Expand Down Expand Up @@ -206,6 +211,8 @@
return database.ResourceTypeOrganizationMember
case database.Organization:
return database.ResourceTypeOrganization
case database.NotificationTemplate:
return database.ResourceTypeNotificationTemplate
default:
panic(fmt.Sprintf("unknown resource %T for ResourceType", typed))
}
Expand Down Expand Up @@ -251,6 +258,8 @@
return true
case database.Organization:
return true
case database.NotificationTemplate:
return false
default:
panic(fmt.Sprintf("unknown resource %T for ResourceRequiresOrgID", tgt))
}
Expand Down
8 changes: 7 additions & 1 deletion coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,9 +1243,15 @@ func New(options *Options) *API {
})
})
r.Route("/notifications", func(r chi.Router) {
r.Use(apiKeyMiddleware)
r.Use(
apiKeyMiddleware,
httpmw.RequireExperiment(api.Experiments, codersdk.ExperimentNotifications),
)
r.Get("/settings", api.notificationsSettings)
r.Put("/settings", api.putNotificationsSettings)
r.Route("/templates", func(r chi.Router) {
r.Get("/system", api.systemNotificationTemplates)
})
})
})

Expand Down
Loading
Loading