Skip to content

Commit

Permalink
chore(pkg/container/config): rename capabilities config fields
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Giovagnoli <[email protected]>
  • Loading branch information
maxgio92 committed Dec 19, 2024
1 parent 8e46080 commit d66f8b7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,10 @@ func (b *Build) buildWorkspaceConfig(ctx context.Context) *container.Config {
cfg.Disk = b.Configuration.Package.Resources.Disk
}
if b.Configuration.Capabilities.Add != nil {
cfg.Capabilities.CapAdd = b.Configuration.Capabilities.Add
cfg.Capabilities.Add = b.Configuration.Capabilities.Add
}
if b.Configuration.Capabilities.Drop != nil {
cfg.Capabilities.CapDrop = b.Configuration.Capabilities.Drop
cfg.Capabilities.Drop = b.Configuration.Capabilities.Drop
}

for k, v := range b.Configuration.Environment.Environment {
Expand Down
4 changes: 2 additions & 2 deletions pkg/build/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,10 @@ func (t *Test) buildWorkspaceConfig(ctx context.Context, imgRef, pkgName string,
RunAs: imgcfg.Accounts.RunAs,
}
if t.Configuration.Capabilities.Add != nil {
cfg.Capabilities.CapAdd = t.Configuration.Capabilities.Add
cfg.Capabilities.Add = t.Configuration.Capabilities.Add
}
if t.Configuration.Capabilities.Drop != nil {
cfg.Capabilities.CapDrop = t.Configuration.Capabilities.Drop
cfg.Capabilities.Drop = t.Configuration.Capabilities.Drop
}

for k, v := range imgcfg.Environment {
Expand Down
8 changes: 4 additions & 4 deletions pkg/container/bubblewrap_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ func (bw *bubblewrap) cmd(ctx context.Context, cfg *Config, debug bool, envOverr
baseargs = append(baseargs, "--cap-add", c)
}
// Add additional process kernel capabilities to the container as configured.
if cfg.Capabilities.CapAdd != nil {
for _, c := range cfg.Capabilities.CapAdd {
if cfg.Capabilities.Add != nil {
for _, c := range cfg.Capabilities.Add {
baseargs = append(baseargs, "--cap-add", c)
}
}
// Drop process kernel capabilities from the container as configured.
if cfg.Capabilities.CapDrop != nil {
for _, c := range cfg.Capabilities.CapDrop {
if cfg.Capabilities.Drop != nil {
for _, c := range cfg.Capabilities.Drop {
baseargs = append(baseargs, "--cap-drop", c)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/container/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type BindMount struct {

type Capabilities struct {
Networking bool
CapAdd []string // List of kernel capabilities to add to the container.
CapDrop []string // List of kernel capabilities to drop from the container.
Add []string // List of kernel capabilities to add to the container.
Drop []string // List of kernel capabilities to drop from the container.
}

type Config struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/container/docker/docker_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ func (dk *docker) StartPod(ctx context.Context, cfg *mcontainer.Config) error {
Mounts: mounts,
}
// Add process kernel capabilities to the container if configured.
if len(cfg.Capabilities.CapAdd) > 0 {
hostConfig.CapAdd = cfg.Capabilities.CapAdd
if len(cfg.Capabilities.Add) > 0 {
hostConfig.CapAdd = cfg.Capabilities.Add
}
// Drop process kernel capabilities from the container if configured.
if len(cfg.Capabilities.CapDrop) > 0 {
hostConfig.CapDrop = cfg.Capabilities.CapDrop
if len(cfg.Capabilities.Drop) > 0 {
hostConfig.CapDrop = cfg.Capabilities.Drop
}

platform := &image_spec.Platform{
Expand Down

0 comments on commit d66f8b7

Please sign in to comment.