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
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Added option for wwclient port number. #1349
|
- Added option for wwclient port number. #1349
|
||||||
- Additional helper directions during syncuser conflict. #1359
|
- Additional helper directions during syncuser conflict. #1359
|
||||||
- Add `:cow` suffix to `wwctl container exec --bind` to temporarily copy files into the node image. #1365
|
- Add `:cow` suffix to `wwctl container exec --bind` to temporarily copy files into the node image. #1365
|
||||||
|
- Add `:copy` suffix to `wwctl container exec --bind` to temporarily copy files into the node image. #1365
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, mntPnt := range mountPts {
|
for _, mntPnt := range mountPts {
|
||||||
if mntPnt.Cow {
|
if mntPnt.Copy {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
wwlog.Debug("bind mounting: %s -> %s", mntPnt.Source, path.Join(containerPath, mntPnt.Dest))
|
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) {
|
func checkMountPoints(containerName string, binds []*warewulfconf.MountEntry) (overlayObjects []string) {
|
||||||
overlayObjects = []string{}
|
overlayObjects = []string{}
|
||||||
for _, b := range binds {
|
for _, b := range binds {
|
||||||
if b.Cow {
|
if b.Copy {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, err := os.Stat(b.Source)
|
_, 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
|
// command syscall.Exec which replaces the __child process with the
|
||||||
// exec command in the container. All the mounts, have to be done in
|
// 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
|
// __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
|
// to see if a file was modified after it was copied into the container
|
||||||
// so do this here.
|
// so do this here.
|
||||||
// At first read out conf, the parse commandline, as copy files has the
|
// 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
|
// 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
|
fileName string
|
||||||
src string
|
src string
|
||||||
modTime time.Time
|
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)
|
containerDest := path.Join(container.RootFsDir(containerName), this.fileName)
|
||||||
if _, err := os.Stat(path.Dir(containerDest)); err != nil {
|
if _, err := os.Stat(path.Dir(containerDest)); err != nil {
|
||||||
return fmt.Errorf("destination directory doesn't exist: %s", err)
|
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)
|
containerDest := path.Join(container.RootFsDir(containerName), this.fileName)
|
||||||
if this.modTime.IsZero() {
|
if this.modTime.IsZero() {
|
||||||
return fmt.Errorf("not previously copied: %s", this.fileName)
|
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
|
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 {
|
for _, bind := range binds {
|
||||||
if bind.Cow {
|
if bind.Copy {
|
||||||
copyObjects = append(copyObjects, &cowFile{
|
copyObjects = append(copyObjects, ©File{
|
||||||
fileName: bind.Dest,
|
fileName: bind.Dest,
|
||||||
src: bind.Source,
|
src: bind.Source,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
baseCmd.AddCommand(child.GetCommand())
|
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
|
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.`)
|
copies the file into the container.`)
|
||||||
baseCmd.PersistentFlags().BoolVar(&SyncUser, "syncuser", false, "Synchronize UIDs/GIDs from host to 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")
|
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() {
|
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
|
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.`)
|
copies the file into the container.`)
|
||||||
baseCmd.PersistentFlags().StringVarP(&nodeName, "node", "n", "", "Create a read only view of the container for the given node")
|
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"`
|
Dest string `yaml:"dest,omitempty"`
|
||||||
ReadOnly bool `yaml:"readonly,omitempty"`
|
ReadOnly bool `yaml:"readonly,omitempty"`
|
||||||
Options string `yaml:"options,omitempty"` // ignored at the moment
|
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]
|
dest = bind[1]
|
||||||
}
|
}
|
||||||
readonly := false
|
readonly := false
|
||||||
cow := false
|
copy_ := false
|
||||||
if len(bind) >= 3 {
|
if len(bind) >= 3 {
|
||||||
if bind[2] == "ro" {
|
if bind[2] == "ro" {
|
||||||
readonly = true
|
readonly = true
|
||||||
} else if bind[2] == "cow" {
|
} else if bind[2] == "copy" {
|
||||||
cow = true
|
copy_ = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mntPnt := warewulfconf.MountEntry{
|
mntPnt := warewulfconf.MountEntry{
|
||||||
Source: bind[0],
|
Source: bind[0],
|
||||||
Dest: dest,
|
Dest: dest,
|
||||||
ReadOnly: readonly,
|
ReadOnly: readonly,
|
||||||
Cow: cow,
|
Copy: copy_,
|
||||||
}
|
}
|
||||||
mounts = append(mounts, &mntPnt)
|
mounts = append(mounts, &mntPnt)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ can be specified in ``warewulf.conf``:
|
|||||||
readonly: true
|
readonly: true
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Instead of ``readonly: true`` you can set ``cow: true``. This causes the
|
Instead of ``readonly: true`` you can set ``copy: true``. This causes the
|
||||||
source file to be copied to the container and removed if it was not
|
source file to be copied to the container and removed if it was not
|
||||||
modified. This can be useful for files used for registrations.
|
modified. This can be useful for files used for registrations.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user