Skip to content

Commit

Permalink
chore: move BindPath code out of runtime package
Browse files Browse the repository at this point in the history
Signed-off-by: Edita Kizinevic <[email protected]>
  • Loading branch information
dtrudg authored and edytuk committed Jul 24, 2023
1 parent 3b1abae commit 8dd1452
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
8 changes: 4 additions & 4 deletions internal/pkg/checkpoint/dmtcp/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os"
"path/filepath"

apptainerConfig "github.com/apptainer/apptainer/pkg/runtime/engine/apptainer/config"
"github.com/apptainer/apptainer/pkg/util/bind"
)

type Entry struct {
Expand All @@ -38,11 +38,11 @@ func (e *Entry) CoordinatorPort() (string, error) {
return s.Text(), nil
}

func (e *Entry) BindPath() apptainerConfig.BindPath {
return apptainerConfig.BindPath{
func (e *Entry) BindPath() bind.BindPath {
return bind.BindPath{
Source: e.path,
Destination: containerStatepath,
Options: map[string]*apptainerConfig.BindOption{
Options: map[string]*bind.BindOption{
"rw": {},
},
}
Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/runtime/launcher/native/launcher_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/apptainer/apptainer/pkg/runtime/engine/config"
"github.com/apptainer/apptainer/pkg/sylog"
"github.com/apptainer/apptainer/pkg/util/apptainerconf"
"github.com/apptainer/apptainer/pkg/util/bind"
"github.com/apptainer/apptainer/pkg/util/capabilities"
"github.com/apptainer/apptainer/pkg/util/cryptkey"
"github.com/apptainer/apptainer/pkg/util/fs/proc"
Expand Down Expand Up @@ -654,14 +655,14 @@ func (l *Launcher) useSuid(insideUserNs bool) (useSuid bool) {
// setBinds sets engine configuration for requested bind mounts.
func (l *Launcher) setBinds(fakerootPath string) error {
// First get binds from -B/--bind and env var
binds, err := apptainerConfig.ParseBindPath(l.cfg.BindPaths)
binds, err := bind.ParseBindPath(l.cfg.BindPaths)
if err != nil {
return fmt.Errorf("while parsing bind path: %w", err)
}
// Now add binds from one or more --mount and env var.
// Note that these do not get exported for nested containers
for _, m := range l.cfg.Mounts {
bps, err := apptainerConfig.ParseMountString(m)
bps, err := bind.ParseMountString(m)
if err != nil {
return fmt.Errorf("while parsing mount %q: %w", m, err)
}
Expand All @@ -675,7 +676,7 @@ func (l *Launcher) setBinds(fakerootPath string) error {
if err != nil {
return fmt.Errorf("while getting fakeroot bindpoints: %w", err)
}
fakebinds, err := apptainerConfig.ParseBindPath(fakebindPaths)
fakebinds, err := bind.ParseBindPath(fakebindPaths)
if err != nil {
return fmt.Errorf("while parsing fakeroot bind paths: %w", err)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/runtime/engine/apptainer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/apptainer/apptainer/internal/pkg/runtime/engine/config/oci"
"github.com/apptainer/apptainer/pkg/image"
"github.com/apptainer/apptainer/pkg/util/apptainerconf"
"github.com/apptainer/apptainer/pkg/util/bind"
)

// Name is the name of the runtime.
Expand Down Expand Up @@ -89,7 +90,7 @@ type JSONConfig struct {
LibrariesPath []string `json:"librariesPath,omitempty"`
FuseMount []FuseMount `json:"fuseMount,omitempty"`
ImageList []image.Image `json:"imageList,omitempty"`
BindPath []BindPath `json:"bindpath,omitempty"`
BindPath []bind.BindPath `json:"bindpath,omitempty"`
ApptainerEnv map[string]string `json:"apptainerEnv,omitempty"`
UnixSocketPair [2]int `json:"unixSocketPair,omitempty"`
OpenFd []int `json:"openFd,omitempty"`
Expand Down Expand Up @@ -305,12 +306,12 @@ func (e *EngineConfig) GetCustomHome() bool {
}

// SetBindPath sets the paths to bind into container.
func (e *EngineConfig) SetBindPath(bindpath []BindPath) {
func (e *EngineConfig) SetBindPath(bindpath []bind.BindPath) {
e.JSON.BindPath = bindpath
}

// GetBindPath retrieves the bind paths.
func (e *EngineConfig) GetBindPath() []BindPath {
func (e *EngineConfig) GetBindPath() []bind.BindPath {
return e.JSON.BindPath
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.

package apptainer
package bind

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2021, Sylabs Inc. All rights reserved.
// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.

package apptainer
package bind

import (
"reflect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.

package apptainer
package bind

import (
"encoding/csv"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2021, Sylabs Inc. All rights reserved.
// Copyright (c) 2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.

package apptainer
package bind

import (
"reflect"
Expand Down

0 comments on commit 8dd1452

Please sign in to comment.