Rename :cow to :copy
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
committed by
Christian Goll
parent
3a36016707
commit
9e91b1c19a
@@ -142,7 +142,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
|
||||
for _, mntPnt := range mountPts {
|
||||
if mntPnt.Cow {
|
||||
if mntPnt.Copy {
|
||||
continue
|
||||
}
|
||||
wwlog.Debug("bind mounting: %s -> %s", mntPnt.Source, path.Join(containerPath, mntPnt.Dest))
|
||||
@@ -199,7 +199,7 @@ the invalid mount points. Directories always have '/' as suffix
|
||||
func checkMountPoints(containerName string, binds []*warewulfconf.MountEntry) (overlayObjects []string) {
|
||||
overlayObjects = []string{}
|
||||
for _, b := range binds {
|
||||
if b.Cow {
|
||||
if b.Copy {
|
||||
continue
|
||||
}
|
||||
_, err := os.Stat(b.Source)
|
||||
|
||||
@@ -67,7 +67,7 @@ func runContainedCmd(cmd *cobra.Command, containerName string, args []string) (e
|
||||
// command syscall.Exec which replaces the __child process with the
|
||||
// exec command in the container. All the mounts, have to be done in
|
||||
// __child so that the used mounts don't propagate outside on the host
|
||||
// (see the CLONE attributes), but as for the cow copy option we need
|
||||
// (see the CLONE attributes), but as for the copy option we need
|
||||
// to see if a file was modified after it was copied into the container
|
||||
// so do this here.
|
||||
// At first read out conf, the parse commandline, as copy files has the
|
||||
@@ -177,13 +177,13 @@ func SetNode(myNode string) {
|
||||
}
|
||||
|
||||
// file name and last modification time so we can remove the file if it wasn't modified
|
||||
type cowFile struct {
|
||||
type copyFile struct {
|
||||
fileName string
|
||||
src string
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
func (this *cowFile) copyToContainer(containerName string) error {
|
||||
func (this *copyFile) copyToContainer(containerName string) error {
|
||||
containerDest := path.Join(container.RootFsDir(containerName), this.fileName)
|
||||
if _, err := os.Stat(path.Dir(containerDest)); err != nil {
|
||||
return fmt.Errorf("destination directory doesn't exist: %s", err)
|
||||
@@ -201,7 +201,7 @@ func (this *cowFile) copyToContainer(containerName string) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *cowFile) removeFromContainer(containerName string) error {
|
||||
func (this *copyFile) removeFromContainer(containerName string) error {
|
||||
containerDest := path.Join(container.RootFsDir(containerName), this.fileName)
|
||||
if this.modTime.IsZero() {
|
||||
return fmt.Errorf("not previously copied: %s", this.fileName)
|
||||
@@ -217,10 +217,10 @@ func (this *cowFile) removeFromContainer(containerName string) error {
|
||||
/*
|
||||
Check the objects we want to copy in, instead of mounting
|
||||
*/
|
||||
func getCopyFiles(binds []*warewulfconf.MountEntry) (copyObjects []*cowFile) {
|
||||
func getCopyFiles(binds []*warewulfconf.MountEntry) (copyObjects []*copyFile) {
|
||||
for _, bind := range binds {
|
||||
if bind.Cow {
|
||||
copyObjects = append(copyObjects, &cowFile{
|
||||
if bind.Copy {
|
||||
copyObjects = append(copyObjects, ©File{
|
||||
fileName: bind.Dest,
|
||||
src: bind.Source,
|
||||
})
|
||||
|
||||
@@ -32,9 +32,9 @@ var (
|
||||
|
||||
func init() {
|
||||
baseCmd.AddCommand(child.GetCommand())
|
||||
baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|cow}]]
|
||||
baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|copy}]]
|
||||
Bind a local path which must exist into the container. If destination is not
|
||||
set, uses the same path as source. "ro" binds read-only. "cow" temporarily
|
||||
set, uses the same path as source. "ro" binds read-only. "copy" temporarily
|
||||
copies the file into the container.`)
|
||||
baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to container")
|
||||
baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node")
|
||||
|
||||
@@ -28,9 +28,9 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|cow}]]
|
||||
baseCmd.PersistentFlags().StringArrayVarP(&binds, "bind", "b", []string{}, `source[:destination[:{ro|copy}]]
|
||||
Bind a local path which must exist into the container. If destination is not
|
||||
set, uses the same path as source. "ro" binds read-only. "cow" temporarily
|
||||
set, uses the same path as source. "ro" binds read-only. "copy" temporarily
|
||||
copies the file into the container.`)
|
||||
baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node")
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ type MountEntry struct {
|
||||
Dest string `yaml:"dest,omitempty"`
|
||||
ReadOnly bool `yaml:"readonly,omitempty"`
|
||||
Options string `yaml:"options,omitempty"` // ignored at the moment
|
||||
Cow bool `yaml:"cow,omitempty"` // copy the file into the container and don't remove if modified
|
||||
Copy bool `yaml:"copy,omitempty"` // temporarily copy the file into the container
|
||||
}
|
||||
|
||||
@@ -21,19 +21,19 @@ func InitMountPnts(binds []string) (mounts []*warewulfconf.MountEntry) {
|
||||
dest = bind[1]
|
||||
}
|
||||
readonly := false
|
||||
cow := false
|
||||
copy_ := false
|
||||
if len(bind) >= 3 {
|
||||
if bind[2] == "ro" {
|
||||
readonly = true
|
||||
} else if bind[2] == "cow" {
|
||||
cow = true
|
||||
} else if bind[2] == "copy" {
|
||||
copy_ = true
|
||||
}
|
||||
}
|
||||
mntPnt := warewulfconf.MountEntry{
|
||||
Source: bind[0],
|
||||
Dest: dest,
|
||||
ReadOnly: readonly,
|
||||
Cow: cow,
|
||||
Copy: copy_,
|
||||
}
|
||||
mounts = append(mounts, &mntPnt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user