-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not override ImageBuildOptions.Labels when building from a Do…
…ckerfile (#2775) * Fix #2632 - ImageBuildOptions.Labels are overwritten * Fix #2632 - fix linter errors. * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update container.go Co-authored-by: Manuel de la Peña <[email protected]> * Update internal/core/labels.go Co-authored-by: Manuel de la Peña <[email protected]> * Update container_test.go Co-authored-by: Manuel de la Peña <[email protected]> * Fix #2632 - remove given, when, then comments. * Update internal/core/labels.go Co-authored-by: Manuel de la Peña <[email protected]> * Fix #2632 - unit test update. * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Fix #2632 - return error when destination labels map is nil and custom labels are present. * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Update internal/core/labels_test.go Co-authored-by: Steven Hartland <[email protected]> * Fix #2632 - fix test. * Update container_test.go Co-authored-by: Manuel de la Peña <[email protected]> --------- Co-authored-by: Steven Hartland <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]>
- Loading branch information
1 parent
e2bd70f
commit 31a033c
Showing
4 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package core | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMergeCustomLabels(t *testing.T) { | ||
t.Run("success", func(t *testing.T) { | ||
dst := map[string]string{"A": "1", "B": "2"} | ||
src := map[string]string{"B": "X", "C": "3"} | ||
|
||
err := MergeCustomLabels(dst, src) | ||
require.NoError(t, err) | ||
require.Equal(t, map[string]string{"A": "1", "B": "X", "C": "3"}, dst) | ||
}) | ||
|
||
t.Run("invalid-prefix", func(t *testing.T) { | ||
dst := map[string]string{"A": "1", "B": "2"} | ||
src := map[string]string{"B": "X", LabelLang: "go"} | ||
|
||
err := MergeCustomLabels(dst, src) | ||
|
||
require.EqualError(t, err, `key "org.testcontainers.lang" has "org.testcontainers" prefix`) | ||
require.Equal(t, map[string]string{"A": "1", "B": "X"}, dst) | ||
}) | ||
|
||
t.Run("nil-destination", func(t *testing.T) { | ||
src := map[string]string{"A": "1"} | ||
err := MergeCustomLabels(nil, src) | ||
require.Error(t, err) | ||
}) | ||
} |