Skip to content

Commit 18b2552

Browse files
committed
Remove .Value calls
1 parent 8cc406e commit 18b2552

File tree

9 files changed

+38
-22
lines changed

9 files changed

+38
-22
lines changed

cli/bigcli/value.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
"net/url"
66
"strconv"
7+
"strings"
78
"time"
89
)
910

@@ -57,6 +58,21 @@ func (String) Type() string {
5758
return "string"
5859
}
5960

61+
type Strings []string
62+
63+
func (s *Strings) Set(v string) error {
64+
*s = strings.Split(v, ",")
65+
return nil
66+
}
67+
68+
func (s Strings) String() string {
69+
return strings.Join(s, ",")
70+
}
71+
72+
func (Strings) Type() string {
73+
return "strings"
74+
}
75+
6076
type Duration time.Duration
6177

6278
func (d *Duration) Set(v string) error {

coderd/apikey.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ func (api *API) validateAPIKeyLifetime(lifetime time.Duration) error {
291291
return xerrors.New("lifetime must be positive number greater than 0")
292292
}
293293

294-
if lifetime > api.DeploymentConfig.MaxTokenLifetime.Value {
295-
return xerrors.Errorf("lifetime must be less than %s", api.DeploymentConfig.MaxTokenLifetime.Value)
294+
if lifetime > api.DeploymentConfig.MaxTokenLifetime {
295+
return xerrors.Errorf("lifetime must be less than %s", api.DeploymentConfig.MaxTokenLifetime)
296296
}
297297

298298
return nil
@@ -311,8 +311,8 @@ func (api *API) createAPIKey(ctx context.Context, params createAPIKeyParams) (*h
311311
if params.LifetimeSeconds != 0 {
312312
params.ExpiresAt = database.Now().Add(time.Duration(params.LifetimeSeconds) * time.Second)
313313
} else {
314-
params.ExpiresAt = database.Now().Add(api.DeploymentConfig.SessionDuration.Value)
315-
params.LifetimeSeconds = int64(api.DeploymentConfig.SessionDuration.Value.Seconds())
314+
params.ExpiresAt = database.Now().Add(api.DeploymentConfig.SessionDuration)
315+
params.LifetimeSeconds = int64(api.DeploymentConfig.SessionDuration.Seconds())
316316
}
317317
}
318318
if params.LifetimeSeconds == 0 {

coderd/provisionerjobs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (api *API) provisionerJobResources(rw http.ResponseWriter, r *http.Request,
264264
}
265265
}
266266

267-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), agent, convertApps(dbApps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
267+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), agent, convertApps(dbApps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
268268
if err != nil {
269269
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
270270
Message: "Internal error reading job agent.",

coderd/userauth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (api *API) postLogin(rw http.ResponseWriter, r *http.Request) {
8989

9090
// If password authentication is disabled and the user does not have the
9191
// owner role, block the request.
92-
if api.DeploymentConfig.DisablePasswordAuth.Value {
92+
if api.DeploymentConfig.DisablePasswordAuth {
9393
httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{
9494
Message: "Password authentication is disabled.",
9595
})
@@ -285,7 +285,7 @@ func (api *API) userAuthMethods(rw http.ResponseWriter, r *http.Request) {
285285

286286
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.AuthMethods{
287287
Password: codersdk.AuthMethod{
288-
Enabled: !api.DeploymentConfig.DisablePasswordAuth.Value,
288+
Enabled: !api.DeploymentConfig.DisablePasswordAuth,
289289
},
290290
Github: codersdk.AuthMethod{Enabled: api.GithubOAuth2Config != nil},
291291
OIDC: codersdk.OIDCAuthMethod{

coderd/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) {
299299

300300
// If password auth is disabled, don't allow new users to be
301301
// created with a password!
302-
if api.DeploymentConfig.DisablePasswordAuth.Value {
302+
if api.DeploymentConfig.DisablePasswordAuth {
303303
httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{
304304
Message: "You cannot manually provision new users with password authentication disabled!",
305305
})

coderd/workspaceagents.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
6161
})
6262
return
6363
}
64-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, convertApps(dbApps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
64+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, convertApps(dbApps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
6565
if err != nil {
6666
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
6767
Message: "Internal error reading workspace agent.",
@@ -83,7 +83,7 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
8383
func (api *API) workspaceAgentMetadata(rw http.ResponseWriter, r *http.Request) {
8484
ctx := r.Context()
8585
workspaceAgent := httpmw.WorkspaceAgent(r)
86-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
86+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
8787
if err != nil {
8888
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
8989
Message: "Internal error reading workspace agent.",
@@ -169,7 +169,7 @@ func (api *API) workspaceAgentMetadata(rw http.ResponseWriter, r *http.Request)
169169
func (api *API) postWorkspaceAgentStartup(rw http.ResponseWriter, r *http.Request) {
170170
ctx := r.Context()
171171
workspaceAgent := httpmw.WorkspaceAgent(r)
172-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
172+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
173173
if err != nil {
174174
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
175175
Message: "Internal error reading workspace agent.",
@@ -232,7 +232,7 @@ func (api *API) workspaceAgentPTY(rw http.ResponseWriter, r *http.Request) {
232232
httpapi.ResourceNotFound(rw)
233233
return
234234
}
235-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
235+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
236236
if err != nil {
237237
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
238238
Message: "Internal error reading workspace agent.",
@@ -313,7 +313,7 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
313313
return
314314
}
315315

316-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
316+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), workspaceAgent, nil, api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
317317
if err != nil {
318318
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
319319
Message: "Internal error reading workspace agent.",

coderd/workspaceapps.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (api *API) workspaceAppsProxyPath(rw http.ResponseWriter, r *http.Request)
9797
workspace := httpmw.WorkspaceParam(r)
9898
agent := httpmw.WorkspaceAgentParam(r)
9999

100-
if api.DeploymentConfig.DisablePathApps.Value {
100+
if api.DeploymentConfig.DisablePathApps {
101101
site.RenderStaticErrorPage(rw, r, site.ErrorPageData{
102102
Status: http.StatusUnauthorized,
103103
Title: "Unauthorized",
@@ -452,7 +452,7 @@ func (api *API) authorizeWorkspaceApp(r *http.Request, accessMethod workspaceApp
452452
//
453453
// Site owners are blocked from accessing path-based apps unless the
454454
// Dangerous.AllowPathAppSiteOwnerAccess flag is enabled in the check below.
455-
if isPathApp && !api.DeploymentConfig.Dangerous.AllowPathAppSharing.Value {
455+
if isPathApp && !api.DeploymentConfig.Dangerous.AllowPathAppSharing {
456456
sharingLevel = database.AppSharingLevelOwner
457457
}
458458

@@ -474,7 +474,7 @@ func (api *API) authorizeWorkspaceApp(r *http.Request, accessMethod workspaceApp
474474
if isPathApp &&
475475
sharingLevel == database.AppSharingLevelOwner &&
476476
workspace.OwnerID.String() != roles.Actor.ID &&
477-
!api.DeploymentConfig.Dangerous.AllowPathAppSiteOwnerAccess.Value {
477+
!api.DeploymentConfig.Dangerous.AllowPathAppSiteOwnerAccess {
478478

479479
return false, nil
480480
}
@@ -742,9 +742,9 @@ func (api *API) workspaceApplicationAuth(rw http.ResponseWriter, r *http.Request
742742
// the current session.
743743
exp := apiKey.ExpiresAt
744744
lifetimeSeconds := apiKey.LifetimeSeconds
745-
if exp.IsZero() || time.Until(exp) > api.DeploymentConfig.SessionDuration.Value {
746-
exp = database.Now().Add(api.DeploymentConfig.SessionDuration.Value)
747-
lifetimeSeconds = int64(api.DeploymentConfig.SessionDuration.Value.Seconds())
745+
if exp.IsZero() || time.Until(exp) > api.DeploymentConfig.SessionDuration {
746+
exp = database.Now().Add(api.DeploymentConfig.SessionDuration)
747+
lifetimeSeconds = int64(api.DeploymentConfig.SessionDuration.Seconds())
748748
}
749749
cookie, _, err := api.createAPIKey(ctx, createAPIKeyParams{
750750
UserID: apiKey.UserID,

coderd/workspacebuilds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ func (api *API) convertWorkspaceBuild(
11121112
apiAgents := make([]codersdk.WorkspaceAgent, 0)
11131113
for _, agent := range agents {
11141114
apps := appsByAgentID[agent.ID]
1115-
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), agent, convertApps(apps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL.Value)
1115+
apiAgent, err := convertWorkspaceAgent(api.DERPMap, *api.TailnetCoordinator.Load(), agent, convertApps(apps), api.AgentInactiveDisconnectTimeout, api.DeploymentConfig.AgentFallbackTroubleshootingURL)
11161116
if err != nil {
11171117
return codersdk.WorkspaceBuild{}, xerrors.Errorf("converting workspace agent: %w", err)
11181118
}

enterprise/coderd/coderd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
257257
return err
258258
}
259259

260-
if entitlements.RequireTelemetry && !api.DeploymentConfig.Telemetry.Enable.Value {
260+
if entitlements.RequireTelemetry && !api.DeploymentConfig.Telemetry.Enable {
261261
// We can't fail because then the user couldn't remove the offending
262262
// license w/o a restart.
263263
//
@@ -270,7 +270,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
270270
return nil
271271
}
272272

273-
entitlements.Experimental = api.DeploymentConfig.Experimental.Value || len(api.AGPL.Experiments) != 0
273+
entitlements.Experimental = api.DeploymentConfig.Experimental || len(api.AGPL.Experiments) != 0
274274

275275
featureChanged := func(featureName codersdk.FeatureName) (changed bool, enabled bool) {
276276
if api.entitlements.Features == nil {

0 commit comments

Comments
 (0)