Skip to content

Commit fe9d5d4

Browse files
authored
Rename ResolveResourceReferences to mutator.ResolveLookupVariables (#3362)
## Why ResourceResourceReferences sounds like it would be resolving ${resources...} like references which is also something we do.
1 parent f4badb4 commit fe9d5d4

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

acceptance/bundle/debug/direct/out.stderr.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
10:07:59 Debug: Apply pid=12345 mutator=RewriteWorkspacePrefix
4141
10:07:59 Debug: Apply pid=12345 mutator=SetVariables
4242
10:07:59 Debug: Apply pid=12345 mutator=ResolveVariableReferences
43-
10:07:59 Debug: Apply pid=12345 mutator=ResolveResourceReferences
43+
10:07:59 Debug: Apply pid=12345 mutator=ResolveLookupVariables
4444
10:07:59 Debug: Apply pid=12345 mutator=ResolveVariableReferences
4545
10:07:59 Debug: Apply pid=12345 mutator=validate:volume-path
4646
10:07:59 Debug: Apply pid=12345 mutator=ApplyTargetMode

acceptance/bundle/debug/tf/out.stderr.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
10:07:59 Debug: Apply pid=12345 mutator=RewriteWorkspacePrefix
3939
10:07:59 Debug: Apply pid=12345 mutator=SetVariables
4040
10:07:59 Debug: Apply pid=12345 mutator=ResolveVariableReferences
41-
10:07:59 Debug: Apply pid=12345 mutator=ResolveResourceReferences
41+
10:07:59 Debug: Apply pid=12345 mutator=ResolveLookupVariables
4242
10:07:59 Debug: Apply pid=12345 mutator=ResolveVariableReferences
4343
10:07:59 Debug: Apply pid=12345 mutator=validate:volume-path
4444
10:07:59 Debug: Apply pid=12345 mutator=ApplyTargetMode

bundle/config/mutator/resolve_resource_references.go renamed to bundle/config/mutator/resolve_lookup_variables.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"golang.org/x/sync/errgroup"
1111
)
1212

13-
type resolveResourceReferences struct{}
13+
type resolveLookupVariables struct{}
1414

15-
func ResolveResourceReferences() bundle.Mutator {
16-
return &resolveResourceReferences{}
15+
func ResolveLookupVariables() bundle.Mutator {
16+
return &resolveLookupVariables{}
1717
}
1818

19-
func (m *resolveResourceReferences) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
19+
func (m *resolveLookupVariables) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
2020
errs, errCtx := errgroup.WithContext(ctx)
2121

2222
for k := range b.Config.Variables {
@@ -44,6 +44,6 @@ func (m *resolveResourceReferences) Apply(ctx context.Context, b *bundle.Bundle)
4444
return diag.FromErr(errs.Wait())
4545
}
4646

47-
func (*resolveResourceReferences) Name() string {
48-
return "ResolveResourceReferences"
47+
func (*resolveLookupVariables) Name() string {
48+
return "ResolveLookupVariables"
4949
}

bundle/config/mutator/resolve_resource_references_test.go renamed to bundle/config/mutator/resolve_lookup_variables_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestResolveClusterReference(t *testing.T) {
5252
{ClusterId: "9876-5432-xywz", ClusterName: clusterRef2},
5353
}, nil)
5454

55-
diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
55+
diags := bundle.Apply(context.Background(), b, ResolveLookupVariables())
5656
require.NoError(t, diags.Error())
5757
require.Equal(t, "1234-5678-abcd", b.Config.Variables["my-cluster-id-1"].Value)
5858
require.Equal(t, "9876-5432-xywz", b.Config.Variables["my-cluster-id-2"].Value)
@@ -87,7 +87,7 @@ func TestResolveNonExistentClusterReference(t *testing.T) {
8787
{ClusterId: "1234-5678-abcd", ClusterName: "some other cluster"},
8888
}, nil)
8989

90-
diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
90+
diags := bundle.Apply(context.Background(), b, ResolveLookupVariables())
9191
require.ErrorContains(t, diags.Error(), "failed to resolve cluster: Random, err: cluster named 'Random' does not exist")
9292
}
9393

@@ -111,7 +111,7 @@ func TestNoLookupIfVariableIsSet(t *testing.T) {
111111
err := b.Config.Variables["my-cluster-id"].Set("random value")
112112
require.NoError(t, err)
113113

114-
diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
114+
diags := bundle.Apply(context.Background(), b, ResolveLookupVariables())
115115
require.NoError(t, diags.Error())
116116
require.Equal(t, "random value", b.Config.Variables["my-cluster-id"].Value)
117117
}
@@ -138,7 +138,7 @@ func TestResolveServicePrincipal(t *testing.T) {
138138
ApplicationId: "app-1234",
139139
}, nil)
140140

141-
diags := bundle.Apply(context.Background(), b, ResolveResourceReferences())
141+
diags := bundle.Apply(context.Background(), b, ResolveLookupVariables())
142142
require.NoError(t, diags.Error())
143143
require.Equal(t, "app-1234", b.Config.Variables["my-sp"].Value)
144144
}
@@ -176,7 +176,7 @@ func TestResolveVariableReferencesInVariableLookups(t *testing.T) {
176176
{ClusterId: "9876-5432-xywz", ClusterName: "some other cluster"},
177177
}, nil)
178178

179-
diags := bundle.ApplySeq(context.Background(), b, ResolveVariableReferencesInLookup(), ResolveResourceReferences())
179+
diags := bundle.ApplySeq(context.Background(), b, ResolveVariableReferencesInLookup(), ResolveLookupVariables())
180180
require.NoError(t, diags.Error())
181181
require.Equal(t, "cluster-bar-dev", b.Config.Variables["lookup"].Lookup.Cluster)
182182
require.Equal(t, "1234-5678-abcd", b.Config.Variables["lookup"].Value)
@@ -203,7 +203,7 @@ func TestResolveLookupVariableReferencesInVariableLookups(t *testing.T) {
203203
m := mocks.NewMockWorkspaceClient(t)
204204
b.SetWorkpaceClient(m.WorkspaceClient)
205205

206-
diags := bundle.ApplySeq(context.Background(), b, ResolveVariableReferencesInLookup(), ResolveResourceReferences())
206+
diags := bundle.ApplySeq(context.Background(), b, ResolveVariableReferencesInLookup(), ResolveLookupVariables())
207207
require.ErrorContains(t, diags.Error(), "lookup variables cannot contain references to another lookup variables")
208208
}
209209

@@ -229,7 +229,7 @@ func TestNoResolveLookupIfVariableSetWithEnvVariable(t *testing.T) {
229229
ctx := context.Background()
230230
ctx = env.Set(ctx, "BUNDLE_VAR_lookup", "1234-5678-abcd")
231231

232-
diags := bundle.ApplySeq(ctx, b, SetVariables(), ResolveVariableReferencesInLookup(), ResolveResourceReferences())
232+
diags := bundle.ApplySeq(ctx, b, SetVariables(), ResolveVariableReferencesInLookup(), ResolveLookupVariables())
233233
require.NoError(t, diags.Error())
234234
require.Equal(t, "1234-5678-abcd", b.Config.Variables["lookup"].Value)
235235
}

bundle/phases/initialize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func Initialize(ctx context.Context, b *bundle.Bundle) {
113113

114114
// Reads (dynamic): variables.*.lookup (checks for variables with lookup fields)
115115
// Updates (dynamic): variables.*.value (sets values based on resolved lookups)
116-
mutator.ResolveResourceReferences(),
116+
mutator.ResolveLookupVariables(),
117117

118118
// Reads (dynamic): * (strings) (searches for variable references in string values)
119119
// Updates (dynamic): * (except 'resources') (strings) (resolves variable references to their actual values)

0 commit comments

Comments
 (0)