-
Notifications
You must be signed in to change notification settings - Fork 897
feat: Add dry run for provisioners #178
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
Changes from 1 commit
4345922
ac61247
0e7f380
391640b
d15f0b3
c07224e
4f07c3e
0bc1390
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,11 @@ import ( | |
|
||
// Scope targets identifiers to pull parameters from. | ||
type Scope struct { | ||
OrganizationID string | ||
ProjectID uuid.UUID | ||
ProjectVersionID uuid.UUID | ||
UserID string | ||
WorkspaceID uuid.UUID | ||
WorkspaceHistoryID uuid.UUID | ||
OrganizationID string | ||
ProjectID uuid.UUID | ||
ProjectVersionID uuid.UUID | ||
UserID sql.NullString | ||
WorkspaceID uuid.NullUUID | ||
} | ||
|
||
// Value represents a computed parameter. | ||
|
@@ -106,22 +105,26 @@ func Compute(ctx context.Context, db database.Store, scope Scope) ([]Value, erro | |
return nil, err | ||
} | ||
|
||
// User parameters come fourth! | ||
err = compute.inject(ctx, database.GetParameterValuesByScopeParams{ | ||
Scope: database.ParameterScopeUser, | ||
ScopeID: scope.UserID, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
if scope.UserID.Valid { | ||
// User parameters come fourth! | ||
err = compute.inject(ctx, database.GetParameterValuesByScopeParams{ | ||
Scope: database.ParameterScopeUser, | ||
ScopeID: scope.UserID.String, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be wrapped? I think there's a linter that can check for that too. |
||
} | ||
} | ||
|
||
// Workspace parameters come last! | ||
err = compute.inject(ctx, database.GetParameterValuesByScopeParams{ | ||
Scope: database.ParameterScopeWorkspace, | ||
ScopeID: scope.WorkspaceID.String(), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
if scope.WorkspaceID.Valid { | ||
// Workspace parameters come last! | ||
err = compute.inject(ctx, database.GetParameterValuesByScopeParams{ | ||
Scope: database.ParameterScopeWorkspace, | ||
ScopeID: scope.WorkspaceID.UUID.String(), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
for _, projectVersionParameter := range compute.projectVersionParametersByName { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,14 @@ func TestCompute(t *testing.T) { | |
OrganizationID: uuid.New().String(), | ||
ProjectID: uuid.New(), | ||
ProjectVersionID: uuid.New(), | ||
UserID: uuid.NewString(), | ||
WorkspaceID: uuid.NullUUID{ | ||
UUID: uuid.New(), | ||
Valid: true, | ||
}, | ||
UserID: sql.NullString{ | ||
String: uuid.NewString(), | ||
Valid: true, | ||
}, | ||
} | ||
} | ||
type projectParameterOptions struct { | ||
|
@@ -163,7 +170,7 @@ func TestCompute(t *testing.T) { | |
ID: uuid.New(), | ||
Name: parameter.Name, | ||
Scope: database.ParameterScopeWorkspace, | ||
ScopeID: scope.WorkspaceID.String(), | ||
ScopeID: scope.WorkspaceID.UUID.String(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since ID is typed as a uuid.UUID, why is it that we can't do the same for ScopeID, to avoid the need to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish! We're supporting v1 user and organization IDs, so we have to use string, unfortunately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to do a one-time migration? Seems unfortunate that we have to support our past decisions indefinitely 😬 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why not. We could probably just add a UUID column to the users and organizations tables in v1, and use them in v2. |
||
SourceScheme: database.ParameterSourceSchemeData, | ||
SourceValue: "nop", | ||
DestinationScheme: database.ParameterDestinationSchemeEnvironmentVariable, | ||
|
@@ -189,7 +196,7 @@ func TestCompute(t *testing.T) { | |
ID: uuid.New(), | ||
Name: parameter.Name, | ||
Scope: database.ParameterScopeWorkspace, | ||
ScopeID: scope.WorkspaceID.String(), | ||
ScopeID: scope.WorkspaceID.UUID.String(), | ||
SourceScheme: database.ParameterSourceSchemeData, | ||
SourceValue: "nop", | ||
DestinationScheme: database.ParameterDestinationSchemeEnvironmentVariable, | ||
|
Uh oh!
There was an error while loading. Please reload this page.