@@ -16,7 +16,7 @@ import (
16
16
// Scope targets identifiers to pull parameters from.
17
17
type Scope struct {
18
18
ImportJobID uuid.UUID
19
- OrganizationID sql. NullString
19
+ OrganizationID string
20
20
ProjectID uuid.NullUUID
21
21
UserID sql.NullString
22
22
WorkspaceID uuid.NullUUID
@@ -42,12 +42,10 @@ func Compute(ctx context.Context, db database.Store, scope Scope, additional ...
42
42
parameterSchemasByName : map [string ]database.ParameterSchema {},
43
43
}
44
44
45
- // All parameters for the project version !
45
+ // All parameters for the import job ID !
46
46
parameterSchemas , err := db .GetParameterSchemasByJobID (ctx , scope .ImportJobID )
47
47
if errors .Is (err , sql .ErrNoRows ) {
48
- // This occurs when the provided import job has
49
- // defined no parameters, so we have nothing to compute!
50
- return []Value {}, nil
48
+ err = nil
51
49
}
52
50
if err != nil {
53
51
return nil , xerrors .Errorf ("get project parameters: %w" , err )
@@ -56,15 +54,13 @@ func Compute(ctx context.Context, db database.Store, scope Scope, additional ...
56
54
compute .parameterSchemasByName [projectVersionParameter .Name ] = projectVersionParameter
57
55
}
58
56
59
- if scope .OrganizationID .Valid {
60
- // Organization parameters come first!
61
- err = compute .injectScope (ctx , database.GetParameterValuesByScopeParams {
62
- Scope : database .ParameterScopeOrganization ,
63
- ScopeID : scope .OrganizationID .String ,
64
- })
65
- if err != nil {
66
- return nil , err
67
- }
57
+ // Organization parameters come first!
58
+ err = compute .injectScope (ctx , database.GetParameterValuesByScopeParams {
59
+ Scope : database .ParameterScopeOrganization ,
60
+ ScopeID : scope .OrganizationID ,
61
+ })
62
+ if err != nil {
63
+ return nil , err
68
64
}
69
65
70
66
// Default project parameter values come second!
@@ -182,18 +178,16 @@ func (c *compute) injectScope(ctx context.Context, scopeParams database.GetParam
182
178
183
179
func (c * compute ) injectSingle (scopedParameter database.ParameterValue ) error {
184
180
parameterSchema , hasParameterSchema := c .parameterSchemasByName [scopedParameter .Name ]
185
- if ! hasParameterSchema {
181
+ if hasParameterSchema {
186
182
// Don't inject parameters that aren't defined by the project.
187
- return nil
188
- }
189
-
190
- _ , hasExistingParameter := c .computedParameterByName [scopedParameter .Name ]
191
- if hasExistingParameter {
192
- // If a parameter already exists, check if this variable can override it.
193
- // Injection hierarchy is the responsibility of the caller. This check ensures
194
- // project parameters cannot be overridden if already set.
195
- if ! parameterSchema .AllowOverrideSource && scopedParameter .Scope != database .ParameterScopeProject {
196
- return nil
183
+ _ , hasExistingParameter := c .computedParameterByName [scopedParameter .Name ]
184
+ if hasExistingParameter {
185
+ // If a parameter already exists, check if this variable can override it.
186
+ // Injection hierarchy is the responsibility of the caller. This check ensures
187
+ // project parameters cannot be overridden if already set.
188
+ if ! parameterSchema .AllowOverrideSource && scopedParameter .Scope != database .ParameterScopeProject {
189
+ return nil
190
+ }
197
191
}
198
192
}
199
193
@@ -204,7 +198,7 @@ func (c *compute) injectSingle(scopedParameter database.ParameterValue) error {
204
198
205
199
switch scopedParameter .SourceScheme {
206
200
case database .ParameterSourceSchemeData :
207
- c .computedParameterByName [parameterSchema .Name ] = Value {
201
+ c .computedParameterByName [scopedParameter .Name ] = Value {
208
202
Proto : & proto.ParameterValue {
209
203
DestinationScheme : destinationScheme ,
210
204
Name : scopedParameter .SourceValue ,
0 commit comments