Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: refactor entry into deployment and runtime#14575

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 8 commits intodk/runtime-configsfromstevenmasley/runtime_refactor
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
8 changes: 1 addition & 7 deletionscli/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -821,13 +821,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
return err
}

// TODO: Throw a caching layer infront of the RuntimeConfig to prevent
// excessive database queries.
// Note: This happens before dbauthz, which is really unfortunate.
// dbauthz is configured in `Coderd.New()`, but we need the manager
// at this level for notifications. We might have to move some init
// code around.
options.RuntimeConfig = runtimeconfig.NewStoreManager(options.Database)
options.RuntimeConfig = runtimeconfig.NewStoreManager()

// This should be output before the logs start streaming.
cliui.Infof(inv.Stdout, "\n==> Logs will stream in below (press ctrl+c to gracefully exit):")
Expand Down
5 changes: 1 addition & 4 deletionscoderd/coderdtest/coderdtest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -255,10 +255,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore{}
accessControlStore.Store(&acs)

// runtimeManager does not use dbauthz.
// TODO: It probably should, but the init code for prod happens before dbauthz
// is ready.
runtimeManager := runtimeconfig.NewStoreManager(options.Database)
runtimeManager := runtimeconfig.NewStoreManager()
options.Database = dbauthz.New(options.Database, options.Authorizer, *options.Logger, accessControlStore)

// Some routes expect a deployment ID, so just make sure one exists.
Expand Down
12 changes: 9 additions & 3 deletionscoderd/database/dbauthz/dbauthz.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1184,7 +1184,9 @@ func (q *querier) DeleteReplicasUpdatedBefore(ctx context.Context, updatedAt tim
}

func (q *querier) DeleteRuntimeConfig(ctx context.Context, key string) error {
// TODO: auth
if err := q.authorizeContext(ctx, policy.ActionDelete, rbac.ResourceSystem); err != nil {
return err
}
return q.db.DeleteRuntimeConfig(ctx, key)
}

Expand DownExpand Up@@ -1862,7 +1864,9 @@ func (q *querier) GetReplicasUpdatedAfter(ctx context.Context, updatedAt time.Ti
}

func (q *querier) GetRuntimeConfig(ctx context.Context, key string) (string, error) {
// TODO: auth
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem); err != nil {
return "", err
}
return q.db.GetRuntimeConfig(ctx, key)
}

Expand DownExpand Up@@ -3917,7 +3921,9 @@ func (q *querier) UpsertProvisionerDaemon(ctx context.Context, arg database.Upse
}

func (q *querier) UpsertRuntimeConfig(ctx context.Context, arg database.UpsertRuntimeConfigParams) error {
// TODO: auth
if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceSystem); err != nil {
return err
}
return q.db.UpsertRuntimeConfig(ctx, arg)
}

Expand Down
16 changes: 16 additions & 0 deletionscoderd/database/dbauthz/dbauthz_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2696,6 +2696,22 @@ func (s *MethodTestSuite) TestSystemFunctions() {
AgentID: uuid.New(),
}).Asserts(tpl, policy.ActionCreate)
}))
s.Run("DeleteRuntimeConfig", s.Subtest(func(db database.Store, check *expects) {
check.Args("test").Asserts(rbac.ResourceSystem, policy.ActionDelete)
}))
s.Run("GetRuntimeConfig", s.Subtest(func(db database.Store, check *expects) {
_ = db.UpsertRuntimeConfig(context.Background(), database.UpsertRuntimeConfigParams{
Key: "test",
Value: "value",
})
check.Args("test").Asserts(rbac.ResourceSystem, policy.ActionRead)
}))
s.Run("UpsertRuntimeConfig", s.Subtest(func(db database.Store, check *expects) {
check.Args(database.UpsertRuntimeConfigParams{
Key: "test",
Value: "value",
}).Asserts(rbac.ResourceSystem, policy.ActionCreate)
}))
}

func (s *MethodTestSuite) TestNotifications() {
Expand Down
161 changes: 0 additions & 161 deletionscoderd/runtimeconfig/config.go
View file
Open in desktop

This file was deleted.

Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp