Repository: docker/compose-cli
Pull request #1648 (2021-05-06 08:00:14)

apply single ulimit as soft+hard limit
**What I did**
Applied "single" ulimit as both hard and soft

**Related issue**
close https://github.com/docker/compose-cli/issues/1638
https://docker.atlassian.net/browse/IL-135

ndeloof: This is a typical case where I miss ternary operator in Go

Patch:
diff --git a/aci/context.go b/aci/context.go
index 2ce1b6c1..7f9cdb4c 100644
--- a/aci/context.go
+++ b/aci/context.go
@@ -99,10 +99,7 @@ func (helper contextCreateACIHelper) createContextData(ctx context.Context, opts
 		}
 	}
 
-	location := opts.Location
-	if opts.Location == "" {
-		location = *group.Location
-	}
+	location := *group.Location
 
 	description := fmt.Sprintf("%s@%s", *group.Name, location)
 	if opts.Description != "" {
diff --git a/cli/cmd/context/create_aci.go b/cli/cmd/context/create_aci.go
index 775fd810..3efaee52 100644
--- a/cli/cmd/context/create_aci.go
+++ b/cli/cmd/context/create_aci.go
@@ -49,8 +49,8 @@ func createAciCommand() *cobra.Command {
 	}
 
 	addDescriptionFlag(cmd, &opts.Description)
-	cmd.Flags().StringVar(&opts.Location, "location", "", "Location")
-	cmd.Flags().StringVar(&opts.SubscriptionID, "subscription-id", "", "Subscription id")
+	cmd.Flags().StringVar(&opts.Location, "location", "eastus", "Location")
+	cmd.Flags().StringVar(&opts.SubscriptionID, "subscription-id", "", "Location")
 	cmd.Flags().StringVar(&opts.ResourceGroup, "resource-group", "", "Resource group")
 
 	return cmd
diff --git a/local/compose/convergence.go b/local/compose/convergence.go
index a46ff065..d394ad62 100644
--- a/local/compose/convergence.go
+++ b/local/compose/convergence.go
@@ -147,7 +147,6 @@ func getContainerProgressName(container moby.Container) string {
 func (s *composeService) waitDependencies(ctx context.Context, project *types.Project, service types.ServiceConfig) error {
 	eg, _ := errgroup.WithContext(ctx)
 	for dep, config := range service.DependsOn {
-		dep, config := dep, config
 		eg.Go(func() error {
 			ticker := time.NewTicker(500 * time.Millisecond)
 			defer ticker.Stop()
diff --git a/local/compose/create.go b/local/compose/create.go
index 560d7649..4df60777 100644
--- a/local/compose/create.go
+++ b/local/compose/create.go
@@ -438,10 +438,18 @@ func getDeployResources(s types.ServiceConfig) container.Resources {
 	}
 
 	for name, u := range s.Ulimits {
+		soft := u.Single
+		if u.Soft != 0 {
+			soft = u.Soft
+		}
+		hard := u.Single
+		if u.Hard != 0 {
+			hard = u.Hard
+		}
 		resources.Ulimits = append(resources.Ulimits, &units.Ulimit{
 			Name: name,
-			Hard: int64(u.Hard),
-			Soft: int64(u.Soft),
+			Hard: int64(soft),
+			Soft: int64(hard),
 		})
 	}
 	return resources


Test patch:
diff --git a/aci/context_test.go b/aci/context_test.go
index 51a384e3..88d72656 100644
--- a/aci/context_test.go
+++ b/aci/context_test.go
@@ -107,28 +107,6 @@ func TestCreateNewResourceGroup(t *testing.T) {
 	assert.DeepEqual(t, data, aciContext("1234", "newResourceGroup", "eastus"))
 }
 
-func TestCreateNewResourceGroupWithSpecificLocation(t *testing.T) {
-	ctx := context.TODO()
-	opts := options("1234", "")
-	opts.Location = "eastus2"
-	m := testContextMocks()
-	m.resourceGroupHelper.On("GetSubscriptionIDs", ctx).Return([]subscription.Model{subModel("1234", "Subscription1")}, nil)
-	m.resourceGroupHelper.On("GetGroup", ctx, "1234", "myResourceGroup").Return(group("myResourceGroup", "eastus"), nil)
-
-	selectOptions := []string{"create a new resource group", "group1 (eastus)", "group2 (westeurope)"}
-	m.userPrompt.On("Select", "Select a resource group", selectOptions).Return(0, nil)
-	m.resourceGroupHelper.On("CreateOrUpdate", ctx, "1234", mock.AnythingOfType("string"), mock.AnythingOfType("resources.Group")).Return(group("newResourceGroup", "eastus"), nil)
-	m.resourceGroupHelper.On("ListGroups", ctx, "1234").Return([]resources.Group{
-		group("group1", "eastus"),
-		group("group2", "westeurope"),
-	}, nil)
-
-	data, description, err := m.contextCreateHelper.createContextData(ctx, opts)
-	assert.NilError(t, err)
-	assert.Equal(t, description, "newResourceGroup@eastus2")
-	assert.DeepEqual(t, data, aciContext("1234", "newResourceGroup", "eastus2"))
-}
-
 func TestSelectExistingResourceGroup(t *testing.T) {
 	ctx := context.TODO()
 	opts := options("1234", "")
@@ -216,6 +194,7 @@ func options(subscriptionID string, resourceGroupName string) ContextParams {
 	return ContextParams{
 		SubscriptionID: subscriptionID,
 		ResourceGroup:  resourceGroupName,
+		Location:       "eastus",
 	}
 }