Updating documentation & API endpoint for container copy

This commit is contained in:
Arnaud Lecomte
2023-08-28 08:39:15 +02:00
parent b56f024e6f
commit f2392f6e37
14 changed files with 754 additions and 531 deletions

View File

@@ -18,6 +18,31 @@ import (
"github.com/pkg/errors"
)
func ContainerCopy(cbp *wwapiv1.ContainerCopyParameter) (err error) {
if cbp == nil {
return fmt.Errorf("ContainerCopyParameter is nil")
}
if !container.DoesSourceExist(cbp.ContainerSource) {
return fmt.Errorf("Container %s does not exists.", cbp.ContainerSource)
}
if !container.ValidName(cbp.ContainerDestination) {
return fmt.Errorf("Container name contains illegal characters : %s", cbp.ContainerDestination)
}
if container.DoesSourceExist(cbp.ContainerDestination) {
return fmt.Errorf("An other container with the name %s already exists", cbp.ContainerDestination)
}
err = container.Duplicate(cbp.ContainerSource, cbp.ContainerDestination)
if err != nil {
return fmt.Errorf("could not duplicate image: %s", err.Error())
}
return fmt.Errorf("Container %s has been succesfully duplicated as %s", cbp.ContainerSource, cbp.ContainerDestination)
}
func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) {
if cbp == nil {
return fmt.Errorf("ContainerBuildParameter is nil")