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

DNM: example runtime config usage#14561

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

Closed

Conversation

dannykopping
Copy link
Contributor

@dannykoppingdannykopping commentedSep 4, 2024
edited
Loading

Demonstration of how#14470 could be used in practice.

This PR allows for the runtime reconfiguration of the notification webhook endpoint.
In reality, what we'dactually want it for this value to be configurable on a per-organization level, but the plumbing to get the org details into theDispatch function complicates the demonstration.

NOTE: incodersdk/deployment.go you'll notice at the bottom that we're iterating over all fields and callingInitialize(opt.Env):

// Initialize runtime fields.for_,opt:=rangeopts {d,ok:=opt.Value.(runtimeconfig.Initializer)if!ok {continue}ifopt.Env=="" {panic(fmt.Sprintf("developer error: option %q must have Env value defined to be runtime-configurable",opt.Name))}d.Initialize(opt.Env)}

This is because we need to assign aname to each wrapped field. This name is used to identify the field in the database, and this is the simplest approach@Emyrk and I could come up with. We need some stable identity for each field, and the field'sEnv value is stable.

NOTE: I've protectedfunc (DeploymentValues) Options() with async.OnceFunc because this method gets called in several places and it's both inefficient and dangerous to run this code several times; once is enough.

TestRuntimeEndpointChange demonstrates how it all comes together. Besides the changes incoderd/notifications/dispatch/webhook.go, this is mostly boilerplate.

dannykoppingand others added11 commitsSeptember 4, 2024 10:26
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Emyrkand others added4 commitsSeptember 4, 2024 16:47
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelSep 14, 2024
@github-actionsgithub-actionsbot deleted the dk/runtime-configs-usage branchMarch 5, 2025 00:07
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@dannykoppingdannykopping

Labels
staleThis issue is like stale bread.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@dannykopping@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp