Repository: score-spec/score-compose
Pull request #144 (2024-05-20 15:20:32)

fix(framework): update score-go
Pick up the fixes in https://github.com/score-spec/score-go/releases/tag/v1.7.1


Patch:
diff --git a/go.mod b/go.mod
index 56ca405..29b1f53 100644
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,7 @@ require (
 	github.com/compose-spec/compose-go/v2 v2.0.0-rc.8
 	github.com/imdario/mergo v0.3.13
 	github.com/mitchellh/mapstructure v1.5.0
-	github.com/score-spec/score-go v1.5.3
+	github.com/score-spec/score-go v1.7.0
 	github.com/spf13/cobra v1.6.0
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/testify v1.9.0
diff --git a/go.sum b/go.sum
index 622d8e4..6ede1b9 100644
--- a/go.sum
+++ b/go.sum
@@ -49,10 +49,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
-github.com/score-spec/score-go v1.5.2 h1:6zzeqx6D7Np7WnJmWWkhX89t5SmN6f0/6xYh40QJFZc=
-github.com/score-spec/score-go v1.5.2/go.mod h1:3QSPH5QVMIX7FdhktLLFtjLQTL1/ENqrWDe5lSdZGFc=
-github.com/score-spec/score-go v1.5.3 h1:K2qujBslD71vttRPE/djxQ0qb4oXZDhOUqzszRQP76U=
-github.com/score-spec/score-go v1.5.3/go.mod h1:3QSPH5QVMIX7FdhktLLFtjLQTL1/ENqrWDe5lSdZGFc=
+github.com/score-spec/score-go v1.7.0 h1:2MVvEzNT6Ct2ItiFkENmPEUs83LAg1lHlGEA2xM2Eds=
+github.com/score-spec/score-go v1.7.0/go.mod h1:3QSPH5QVMIX7FdhktLLFtjLQTL1/ENqrWDe5lSdZGFc=
 github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
 github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
diff --git a/internal/command/init.go b/internal/command/init.go
index de730c4..50911ca 100644
--- a/internal/command/init.go
+++ b/internal/command/init.go
@@ -135,7 +135,7 @@ acts as a namespace when multiple score files and containers are used.
 				Path: project.DefaultRelativeStateDirectory,
 				State: project.State{
 					Workloads:   map[string]framework.ScoreWorkloadState[project.WorkloadExtras]{},
-					Resources:   map[framework.ResourceUid]framework.ScoreResourceState{},
+					Resources:   map[framework.ResourceUid]framework.ScoreResourceState[framework.NoExtras]{},
 					SharedState: map[string]interface{}{},
 					Extras: project.StateExtras{
 						ComposeProjectName: cleanComposeProjectName(filepath.Base(wd)),
diff --git a/internal/project/project.go b/internal/project/project.go
index aac1a24..0959d3a 100644
--- a/internal/project/project.go
+++ b/internal/project/project.go
@@ -34,7 +34,7 @@ const (
 
 // State is the mega-structure that contains the state of our workload specifications and resources.
 // Score specs are added to this structure and it stores the current resource set.
-type State = framework.State[StateExtras, WorkloadExtras]
+type State = framework.State[StateExtras, WorkloadExtras, framework.NoExtras]
 
 type StateExtras struct {
 	ComposeProjectName string `yaml:"compose_project"`


Test patch:
diff --git a/internal/command/generate_examples_test.go b/internal/command/generate_examples_test.go
index 11d6c38..3de1aeb 100644
--- a/internal/command/generate_examples_test.go
+++ b/internal/command/generate_examples_test.go
@@ -141,11 +141,11 @@ services:
         image: nginx:latest
         volumes:
             - type: volume
-              source: hello-world-data-2saOb4
+              source: hello-world-data-8MjJEo
               target: /data
 volumes:
-    hello-world-data-2saOb4:
-        name: hello-world-data-2saOb4
+    hello-world-data-8MjJEo:
+        name: hello-world-data-8MjJEo
         driver: local
         labels:
             dev.score.compose.res.uid: volume.default#hello-world.data
diff --git a/internal/command/init_test.go b/internal/command/init_test.go
index fc376cc..e47a1a1 100644
--- a/internal/command/init_test.go
+++ b/internal/command/init_test.go
@@ -109,7 +109,7 @@ func TestInitNominal(t *testing.T) {
 		assert.Equal(t, filepath.Base(td), sd.State.Extras.ComposeProjectName)
 		assert.Equal(t, filepath.Join(project.DefaultRelativeStateDirectory, "mounts"), sd.State.Extras.MountsDirectory)
 		assert.Equal(t, map[string]framework.ScoreWorkloadState[project.WorkloadExtras]{}, sd.State.Workloads)
-		assert.Equal(t, map[framework.ResourceUid]framework.ScoreResourceState{}, sd.State.Resources)
+		assert.Equal(t, map[framework.ResourceUid]framework.ScoreResourceState[framework.NoExtras]{}, sd.State.Resources)
 		assert.Equal(t, map[string]interface{}{}, sd.State.SharedState)
 	}
 }
@@ -217,7 +217,7 @@ func TestInitNominal_run_twice(t *testing.T) {
 		assert.Equal(t, "bananas", sd.State.Extras.ComposeProjectName)
 		assert.Equal(t, filepath.Join(project.DefaultRelativeStateDirectory, "mounts"), sd.State.Extras.MountsDirectory)
 		assert.Equal(t, map[string]framework.ScoreWorkloadState[project.WorkloadExtras]{}, sd.State.Workloads)
-		assert.Equal(t, map[framework.ResourceUid]framework.ScoreResourceState{}, sd.State.Resources)
+		assert.Equal(t, map[framework.ResourceUid]framework.ScoreResourceState[framework.NoExtras]{}, sd.State.Resources)
 		assert.Equal(t, map[string]interface{}{}, sd.State.SharedState)
 	}
 }
diff --git a/internal/compose/convert_test.go b/internal/compose/convert_test.go
index 37f9ce3..6158526 100644
--- a/internal/compose/convert_test.go
+++ b/internal/compose/convert_test.go
@@ -425,14 +425,14 @@ func TestScoreConvert(t *testing.T) {
 						"some-dns": {Type: "thing"},
 					}}},
 				},
-				Resources: map[framework.ResourceUid]framework.ScoreResourceState{},
+				Resources: map[framework.ResourceUid]framework.ScoreResourceState[framework.NoExtras]{},
 			}
 			evt := new(envprov.Provisioner)
-			state.Resources["environment.default#test.env"] = framework.ScoreResourceState{OutputLookupFunc: evt.LookupOutput}
+			state.Resources["environment.default#test.env"] = framework.ScoreResourceState[framework.NoExtras]{OutputLookupFunc: evt.LookupOutput}
 			po, _ := evt.GenerateSubProvisioner("app-db", "").Provision(nil, nil)
-			state.Resources["thing.default#test.app-db"] = framework.ScoreResourceState{OutputLookupFunc: po.OutputLookupFunc}
+			state.Resources["thing.default#test.app-db"] = framework.ScoreResourceState[framework.NoExtras]{OutputLookupFunc: po.OutputLookupFunc}
 			po, _ = evt.GenerateSubProvisioner("some-dns", "").Provision(nil, nil)
-			state.Resources["thing.default#test.some-dns"] = framework.ScoreResourceState{OutputLookupFunc: po.OutputLookupFunc}
+			state.Resources["thing.default#test.some-dns"] = framework.ScoreResourceState[framework.NoExtras]{OutputLookupFunc: po.OutputLookupFunc}
 
 			proj, err := ConvertSpec(state, tt.Source)
 
diff --git a/internal/provisioners/core_test.go b/internal/provisioners/core_test.go
index c02daba..ccd17b6 100644
--- a/internal/provisioners/core_test.go
+++ b/internal/provisioners/core_test.go
@@ -35,7 +35,7 @@ import (
 func TestApplyToStateAndProject(t *testing.T) {
 	resUid := framework.NewResourceUid("w", "r", "t", nil, nil)
 	startState := &project.State{
-		Resources: map[framework.ResourceUid]framework.ScoreResourceState{
+		Resources: map[framework.ResourceUid]framework.ScoreResourceState[framework.NoExtras]{
 			resUid: {},
 		},
 	}
@@ -47,7 +47,7 @@ func TestApplyToStateAndProject(t *testing.T) {
 		output := &ProvisionOutput{}
 		afterState, err := output.ApplyToStateAndProject(startState, resUid, composeProject)
 		require.NoError(t, err)
-		assert.Equal(t, framework.ScoreResourceState{
+		assert.Equal(t, framework.ScoreResourceState[framework.NoExtras]{
 			State:   map[string]interface{}{},
 			Outputs: map[string]interface{}{},
 		}, afterState.Resources[resUid])
@@ -83,7 +83,7 @@ func TestApplyToStateAndProject(t *testing.T) {
 		}
 		afterState, err := output.ApplyToStateAndProject(startState, resUid, composeProject)
 		require.NoError(t, err)
-		assert.Equal(t, framework.ScoreResourceState{
+		assert.Equal(t, framework.ScoreResourceState[framework.NoExtras]{
 			State:   map[string]interface{}{"a": "b", "c": nil},
 			Outputs: map[string]interface{}{"x": "y"},
 		}, afterState.Resources[resUid])