Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ImageBuildOptions.Labels are overwritten #2632

Closed
rzajac opened this issue Jul 7, 2024 · 0 comments · Fixed by #2775
Closed

[Bug]: ImageBuildOptions.Labels are overwritten #2632

rzajac opened this issue Jul 7, 2024 · 0 comments · Fixed by #2775
Labels
bug An issue with the library

Comments

@rzajac
Copy link
Contributor

rzajac commented Jul 7, 2024

Testcontainers version

v0.32.0

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host arch

x86

Go version

1.22

Docker version

Client: Docker Engine - Community
 Version:           27.0.3
 API version:       1.46
 Go version:        go1.21.11
 Git commit:        7d4bcd8
 Built:             Sat Jun 29 00:02:26 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.0.3
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       662f78c
  Built:            Sat Jun 29 00:02:26 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.18
  GitCommit:        ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc:
  Version:          1.7.18
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client: Docker Engine - Community
 Version:    27.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.15.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.28.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 36
  Running: 1
  Paused: 0
  Stopped: 35
 Images: 769
 Server Version: 27.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-42-generic
 Operating System: Ubuntu 23.10
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.01GiB
 Name: thorx1
 ID: 94633125-a6fc-41db-ba45-8e359b3bb5ef
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  dkr.vrit.dev:5000
  127.0.0.0/8
 Live Restore Enabled: false

What happened?

In line

if !c.ShouldKeepBuiltImage() {
buildOptions.Labels = core.DefaultLabels(core.SessionID())
}
the labels that are set in
if c.FromDockerfile.BuildOptionsModifier != nil {
c.FromDockerfile.BuildOptionsModifier(&buildOptions)
}
are overwriten. The keys should be merged instead of overwritten.

Relevant log output

No response

Additional information

No response

@rzajac rzajac added the bug An issue with the library label Jul 7, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 9, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 9, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 16, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 16, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 17, 2024
rzajac added a commit to rzajac/testcontainers-go that referenced this issue Sep 17, 2024
mdelapenya added a commit that referenced this issue Sep 18, 2024
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
1 participant