Skip to content

Commit 743e3b8

Browse files
committed
had to remove without state converter
The graph is required for daily cost information
1 parent d3850bb commit 743e3b8

File tree

2 files changed

+0
-55
lines changed

2 files changed

+0
-55
lines changed

provisioner/terraform/convertstate.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,6 @@ import (
2424
"github.com/coder/coder/v2/provisionersdk/proto"
2525
)
2626

27-
type ReducedState struct {
28-
Resources []*proto.Resource
29-
}
30-
31-
func ConvertStateWithoutGraph(ctx context.Context, modules []*tfjson.StateModule, logger slog.Logger) (*ReducedState, error) {
32-
converter := newConverter(ctx, logger, gographviz.NewGraph())
33-
34-
// Index all resources from the state.
35-
converter.indexTerraformResources(modules)
36-
37-
// Associate agent instance IDs.
38-
converter.processAgentInstances()
39-
40-
// Build the final resource list.
41-
converter.buildResources()
42-
43-
return &ReducedState{
44-
Resources: converter.resources,
45-
}, nil
46-
}
47-
4827
// ConvertState consumes Terraform state and a GraphViz representation
4928
// produced by `terraform graph` to produce resources consumable by Coder.
5029
func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph string, logger slog.Logger) (*State, error) {

provisioner/terraform/resources_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,40 +128,6 @@ func TestConvertStateGolden(t *testing.T) {
128128
require.NoError(t, err)
129129

130130
require.JSONEq(t, string(expBytes), string(gotBytes), "converted state")
131-
132-
if expectedState, ok := expectedOutput.(*terraform.State); ok {
133-
t.Run("WithoutGraph", func(t *testing.T) {
134-
gotState, err := terraform.ConvertStateWithoutGraph(ctx, modules, logger)
135-
require.NoError(t, err)
136-
sortResources(gotState.Resources)
137-
138-
for _, res := range expectedState.Resources {
139-
// Agents will not exist without the graph.
140-
original := res.Agents
141-
t.Cleanup(func() {
142-
res.Agents = original
143-
})
144-
res.Agents = nil
145-
146-
// Metadata will not exist without the graph.
147-
originalMetadata := res.Metadata
148-
t.Cleanup(func() {
149-
res.Metadata = originalMetadata
150-
})
151-
res.Metadata = nil
152-
}
153-
154-
require.Equal(t, len(expectedState.Resources), len(gotState.Resources), "number of resources")
155-
for i := range gotState.Resources {
156-
got, err := json.Marshal(gotState.Resources[i])
157-
require.NoError(t, err, "marshaling got resource to JSON")
158-
expected, err := json.Marshal(expectedState.Resources[i])
159-
require.NoError(t, err, "marshaling expected resource to JSON")
160-
161-
require.JSONEq(t, string(expected), string(got), "json cmp")
162-
}
163-
})
164-
}
165131
})
166132
}
167133
}

0 commit comments

Comments
 (0)