瀏覽代碼

avoir use of []types.ServiceConfig

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 1 年之前
父節點
當前提交
5e77ae9247

+ 1 - 1
cmd/compose/compose_test.go

@@ -25,7 +25,7 @@ import (
 
 func TestFilterServices(t *testing.T) {
 	p := &types.Project{
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name:  "foo",
 				Links: []string{"bar"},

+ 3 - 3
cmd/compose/options_test.go

@@ -26,7 +26,7 @@ import (
 func TestApplyPlatforms_InferFromRuntime(t *testing.T) {
 	makeProject := func() *types.Project {
 		return &types.Project{
-			Services: []types.ServiceConfig{
+			Services: types.Services{
 				{
 					Name:  "test",
 					Image: "foo",
@@ -64,7 +64,7 @@ func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {
 			Environment: map[string]string{
 				"DOCKER_DEFAULT_PLATFORM": "linux/amd64",
 			},
-			Services: []types.ServiceConfig{
+			Services: types.Services{
 				{
 					Name:  "test",
 					Image: "foo",
@@ -100,7 +100,7 @@ func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) {
 			Environment: map[string]string{
 				"DOCKER_DEFAULT_PLATFORM": "commodore/64",
 			},
-			Services: []types.ServiceConfig{
+			Services: types.Services{
 				{
 					Name:  "test",
 					Image: "foo",

+ 1 - 1
cmd/compose/pullOptions_test.go

@@ -25,7 +25,7 @@ import (
 
 func TestApplyPullOptions(t *testing.T) {
 	project := &types.Project{
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name: "must-build",
 				// No image, local build only

+ 1 - 1
cmd/compose/up_test.go

@@ -25,7 +25,7 @@ import (
 
 func TestApplyScaleOpt(t *testing.T) {
 	p := types.Project{
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name: "foo",
 			},

+ 2 - 2
pkg/compose/convergence_test.go

@@ -224,7 +224,7 @@ func TestWaitDependencies(t *testing.T) {
 	t.Run("should skip dependencies with scale 0", func(t *testing.T) {
 		dbService := types.ServiceConfig{Name: "db", Scale: 0}
 		redisService := types.ServiceConfig{Name: "redis", Scale: 0}
-		project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{dbService, redisService}}
+		project := types.Project{Name: strings.ToLower(testProject), Services: types.Services{dbService, redisService}}
 		dependencies := types.DependsOnConfig{
 			"db":    {Condition: ServiceConditionRunningOrHealthy},
 			"redis": {Condition: ServiceConditionRunningOrHealthy},
@@ -234,7 +234,7 @@ func TestWaitDependencies(t *testing.T) {
 	t.Run("should skip dependencies with condition service_started", func(t *testing.T) {
 		dbService := types.ServiceConfig{Name: "db", Scale: 1}
 		redisService := types.ServiceConfig{Name: "redis", Scale: 1}
-		project := types.Project{Name: strings.ToLower(testProject), Services: []types.ServiceConfig{dbService, redisService}}
+		project := types.Project{Name: strings.ToLower(testProject), Services: types.Services{dbService, redisService}}
 		dependencies := types.DependsOnConfig{
 			"db":    {Condition: types.ServiceConditionStarted, Required: true},
 			"redis": {Condition: types.ServiceConditionStarted, Required: true},

+ 2 - 2
pkg/compose/dependencies_test.go

@@ -32,7 +32,7 @@ import (
 
 func createTestProject() *types.Project {
 	return &types.Project{
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name: "test1",
 				DependsOn: map[string]types.ServiceDependency{
@@ -59,7 +59,7 @@ func TestTraversalWithMultipleParents(t *testing.T) {
 	}
 
 	project := types.Project{
-		Services: []types.ServiceConfig{dependent},
+		Services: types.Services{dependent},
 	}
 
 	for i := 1; i <= 100; i++ {

+ 2 - 2
pkg/compose/pull.go

@@ -260,7 +260,7 @@ func encodedAuth(ref reference.Named, configFile driver.Auth) (string, error) {
 }
 
 func (s *composeService) pullRequiredImages(ctx context.Context, project *types.Project, images map[string]string, quietPull bool) error {
-	var needPull []types.ServiceConfig
+	var needPull types.Services
 	for _, service := range project.Services {
 		if service.Image == "" {
 			continue
@@ -308,7 +308,7 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
 	}, s.stdinfo())
 }
 
-func isServiceImageToBuild(service types.ServiceConfig, services []types.ServiceConfig) bool {
+func isServiceImageToBuild(service types.ServiceConfig, services types.Services) bool {
 	if service.Build != nil {
 		return true
 	}

+ 1 - 1
pkg/compose/viz_test.go

@@ -33,7 +33,7 @@ func TestViz(t *testing.T) {
 	project := types.Project{
 		Name:       "viz-test",
 		WorkingDir: "/home",
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name:  "service1",
 				Image: "image-for-service1",

+ 1 - 1
pkg/compose/watch_test.go

@@ -105,7 +105,7 @@ func TestWatch_Sync(t *testing.T) {
 	t.Cleanup(cancelFunc)
 
 	proj := types.Project{
-		Services: []types.ServiceConfig{
+		Services: types.Services{
 			{
 				Name: "test",
 			},