Rename "container" to "image"

- Updated `wwctl upgrade` to handle updates
- Maintained `.Container` and `.ContainerName` in tstruct
- Added `ContainerName()` methods to node and profile objects
- Added `--container`, `-C` aliases to wwctl commands (`<node|profile> <add|set>`)
- Added `wwctl container` alias
- Added support for `container_exit.sh` if `image_exit.sh` is not found

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-18 17:34:48 -07:00
parent 96396ed47e
commit 45a690ca4e
142 changed files with 2212 additions and 2183 deletions

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"fmt"
@@ -10,7 +10,7 @@ import (
"github.com/containers/image/v5/types"
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/kernel"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/util"
@@ -18,71 +18,71 @@ import (
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
func ContainerCopy(cbp *wwapiv1.ContainerCopyParameter) (err error) {
func ImageCopy(cbp *wwapiv1.ImageCopyParameter) (err error) {
if cbp == nil {
return fmt.Errorf("containerCopyParameter is nil")
return fmt.Errorf("imageCopyParameter is nil")
}
if !container.DoesSourceExist(cbp.ContainerSource) {
return fmt.Errorf("container %s does not exists.", cbp.ContainerSource)
if !image.DoesSourceExist(cbp.ImageSource) {
return fmt.Errorf("image %s does not exists.", cbp.ImageSource)
}
if !container.ValidName(cbp.ContainerDestination) {
return fmt.Errorf("container name contains illegal characters : %s", cbp.ContainerDestination)
if !image.ValidName(cbp.ImageDestination) {
return fmt.Errorf("image name contains illegal characters : %s", cbp.ImageDestination)
}
if container.DoesSourceExist(cbp.ContainerDestination) {
return fmt.Errorf("An other container with the name %s already exists", cbp.ContainerDestination)
if image.DoesSourceExist(cbp.ImageDestination) {
return fmt.Errorf("An other image with the name %s already exists", cbp.ImageDestination)
}
err = container.Duplicate(cbp.ContainerSource, cbp.ContainerDestination)
err = image.Duplicate(cbp.ImageSource, cbp.ImageDestination)
if err != nil {
return fmt.Errorf("could not duplicate image: %s", err.Error())
}
if cbp.Build {
err = container.Build(cbp.ContainerDestination, true)
err = image.Build(cbp.ImageDestination, true)
if err != nil {
return err
}
}
return fmt.Errorf("Container %s has been succesfully duplicated as %s", cbp.ContainerSource, cbp.ContainerDestination)
return fmt.Errorf("Image %s has been succesfully duplicated as %s", cbp.ImageSource, cbp.ImageDestination)
}
func ContainerBuild(cbp *wwapiv1.ContainerBuildParameter) (err error) {
func ImageBuild(cbp *wwapiv1.ImageBuildParameter) (err error) {
if cbp == nil {
return fmt.Errorf("ContainerBuildParameter is nil")
return fmt.Errorf("ImageBuildParameter is nil")
}
var containers []string
var images []string
if cbp.All {
containers, err = container.ListSources()
images, err = image.ListSources()
} else {
containers = cbp.ContainerNames
images = cbp.ImageNames
}
if len(containers) == 0 {
if len(images) == 0 {
return
}
for _, c := range containers {
if !container.ValidSource(c) {
return fmt.Errorf("VNFS name does not exist: %s", c)
for _, c := range images {
if !image.ValidSource(c) {
return fmt.Errorf("Image name does not exist: %s", c)
}
err = container.Build(c, cbp.Force)
err = image.Build(c, cbp.Force)
if err != nil {
return fmt.Errorf("could not build container %s: %s", c, err)
return fmt.Errorf("could not build image %s: %s", c, err)
}
}
return
}
func ContainerDelete(cdp *wwapiv1.ContainerDeleteParameter) (err error) {
func ImageDelete(cdp *wwapiv1.ImageDeleteParameter) (err error) {
if cdp == nil {
return fmt.Errorf("ContainerDeleteParameter is nil")
return fmt.Errorf("ImageDeleteParameter is nil")
}
nodeDB, err := node.New()
@@ -96,36 +96,36 @@ func ContainerDelete(cdp *wwapiv1.ContainerDeleteParameter) (err error) {
}
ARG_LOOP:
for i := 0; i < len(cdp.ContainerNames); i++ {
for i := 0; i < len(cdp.ImageNames); i++ {
//_, arg := range args {
containerName := cdp.ContainerNames[i]
imageName := cdp.ImageNames[i]
for _, n := range nodes {
if n.ContainerName == containerName {
wwlog.Error("Container is configured for nodes, skipping: %s", containerName)
if n.ImageName == imageName {
wwlog.Error("Image is configured for nodes, skipping: %s", imageName)
continue ARG_LOOP
}
}
if !container.ValidSource(containerName) {
wwlog.Error("Container name is not a valid source: %s", containerName)
if !image.ValidSource(imageName) {
wwlog.Error("Image name is not a valid source: %s", imageName)
continue
}
err := container.DeleteSource(containerName)
err := image.DeleteSource(imageName)
if err != nil {
wwlog.Error("Could not remove source: %s", containerName)
wwlog.Error("Could not remove source: %s", imageName)
}
err = container.DeleteImage(containerName)
err = image.DeleteImage(imageName)
if err != nil {
wwlog.Error("Could not remove image files %s", containerName)
wwlog.Error("Could not remove image files %s", imageName)
}
fmt.Printf("Container has been deleted: %s\n", containerName)
fmt.Printf("Image has been deleted: %s\n", imageName)
}
return
}
func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName string, err error) {
func ImageImport(cip *wwapiv1.ImageImportParameter) (imageName string, err error) {
if cip == nil {
err = fmt.Errorf("NodeAddParameter is nil")
return
@@ -133,20 +133,20 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
if cip.Name == "" {
name := path.Base(cip.Source)
wwlog.Info("Setting VNFS name: %s", name)
wwlog.Info("Setting image name: %s", name)
cip.Name = name
}
if !container.ValidName(cip.Name) {
err = fmt.Errorf("VNFS name contains illegal characters: %s", cip.Name)
if !image.ValidName(cip.Name) {
err = fmt.Errorf("Image name contains illegal characters: %s", cip.Name)
return
}
containerName = cip.Name
fullPath := container.SourceDir(cip.Name)
imageName = cip.Name
fullPath := image.SourceDir(cip.Name)
// container already exists and should be removed first
// image already exists and should be removed first
if util.IsDir(fullPath) && cip.Force {
wwlog.Info("Overwriting existing VNFS")
wwlog.Info("Overwriting existing image")
err = os.RemoveAll(fullPath)
if err != nil {
return
@@ -155,10 +155,10 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
if util.IsDir(fullPath) {
if !cip.Update {
err = fmt.Errorf("VNFS Name exists, specify --force, --update, or choose a different name: %s", cip.Name)
err = fmt.Errorf("Image name exists, specify --force, --update, or choose a different name: %s", cip.Name)
return
}
wwlog.Info("Updating existing VNFS")
wwlog.Info("Updating existing image")
} else if strings.HasPrefix(cip.Source, "docker://") || strings.HasPrefix(cip.Source, "docker-daemon://") ||
strings.HasPrefix(cip.Source, "file://") || util.IsFile(cip.Source) {
var sCtx *types.SystemContext
@@ -174,17 +174,17 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
return
}
}
err = container.ImportDocker(cip.Source, cip.Name, sCtx)
err = image.ImportDocker(cip.Source, cip.Name, sCtx)
if err != nil {
err = fmt.Errorf("could not import image: %s", err.Error())
_ = container.DeleteSource(cip.Name)
_ = image.DeleteSource(cip.Name)
return
}
} else if util.IsDir(cip.Source) {
err = container.ImportDirectory(cip.Source, cip.Name)
err = image.ImportDirectory(cip.Source, cip.Name)
if err != nil {
err = fmt.Errorf("could not import image: %s", err.Error())
_ = container.DeleteSource(cip.Name)
_ = image.DeleteSource(cip.Name)
return
}
} else {
@@ -193,7 +193,7 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
}
if cip.SyncUser {
err = container.SyncUids(cip.Name, true)
err = image.SyncUids(cip.Name, true)
if err != nil {
err = fmt.Errorf("error in user sync, fix error and run 'syncuser' manually: %s", err)
return
@@ -201,20 +201,20 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
}
if cip.Build {
wwlog.Info("Building container: %s", cip.Name)
err = container.Build(cip.Name, true)
wwlog.Info("Building image: %s", cip.Name)
err = image.Build(cip.Name, true)
if err != nil {
err = fmt.Errorf("could not build container %s: %s", cip.Name, err.Error())
err = fmt.Errorf("could not build image %s: %s", cip.Name, err.Error())
return
}
}
return
}
func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
func ImageList() (imageInfo []*wwapiv1.ImageInfo, err error) {
var sources []string
sources, err = container.ListSources()
sources, err = image.ListSources()
if err != nil {
wwlog.Error("%s", err)
return
@@ -234,7 +234,7 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
nodemap := make(map[string]int)
for _, n := range nodes {
nodemap[n.ContainerName]++
nodemap[n.ImageName]++
}
for _, source := range sources {
@@ -249,31 +249,31 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
kernelVersion = kernel.Version()
}
var creationTime uint64
sourceStat, err := os.Stat(container.SourceDir(source))
wwlog.Debug("Checking creation time for: %s,%v", container.SourceDir(source), sourceStat.ModTime())
sourceStat, err := os.Stat(image.SourceDir(source))
wwlog.Debug("Checking creation time for: %s,%v", image.SourceDir(source), sourceStat.ModTime())
if err != nil {
wwlog.Error("%s\n", err)
} else {
creationTime = uint64(sourceStat.ModTime().Unix())
}
var modTime uint64
imageStat, err := os.Stat(container.ImageFile(source))
imageStat, err := os.Stat(image.ImageFile(source))
if err == nil {
modTime = uint64(imageStat.ModTime().Unix())
}
size, err := util.DirSize(container.SourceDir(source))
size, err := util.DirSize(image.SourceDir(source))
if err != nil {
wwlog.Error("%s\n", err)
}
imgSize := 0
if imgF, err := os.Stat(container.ImageFile(source)); err == nil {
if imgF, err := os.Stat(image.ImageFile(source)); err == nil {
imgSize = int(imgF.Size())
}
imgCSize := 0
if imgFC, err := os.Stat(container.ImageFile(source) + ".gz"); err == nil {
if imgFC, err := os.Stat(image.ImageFile(source) + ".gz"); err == nil {
imgCSize = int(imgFC.Size())
}
containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
imageInfo = append(imageInfo, &wwapiv1.ImageInfo{
Name: source,
NodeCount: uint32(nodemap[source]),
KernelVersion: kernelVersion,
@@ -288,20 +288,20 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
return
}
func ContainerShow(csp *wwapiv1.ContainerShowParameter) (response *wwapiv1.ContainerShowResponse, err error) {
containerName := csp.ContainerName
func ImageShow(csp *wwapiv1.ImageShowParameter) (response *wwapiv1.ImageShowResponse, err error) {
imageName := csp.ImageName
if !container.ValidName(containerName) {
err = fmt.Errorf("%s is not a valid container name", containerName)
if !image.ValidName(imageName) {
err = fmt.Errorf("%s is not a valid image name", imageName)
return
}
rootFsDir := container.RootFsDir(containerName)
rootFsDir := image.RootFsDir(imageName)
if !util.IsDir(rootFsDir) {
err = fmt.Errorf("%s is not a valid container", containerName)
err = fmt.Errorf("%s is not a valid image", imageName)
return
}
kernel := kernel.FindKernels(containerName).Default()
kernel := kernel.FindKernels(imageName).Default()
kernelVersion := ""
if kernel != nil {
kernelVersion = kernel.Version()
@@ -319,13 +319,13 @@ func ContainerShow(csp *wwapiv1.ContainerShowParameter) (response *wwapiv1.Conta
var nodeList []string
for _, n := range nodes {
if n.ContainerName == containerName {
if n.ImageName == imageName {
nodeList = append(nodeList, n.Id())
}
}
response = &wwapiv1.ContainerShowResponse{
Name: containerName,
response = &wwapiv1.ImageShowResponse{
Name: imageName,
Rootfs: rootFsDir,
Nodes: nodeList,
KernelVersion: kernelVersion,
@@ -333,28 +333,28 @@ func ContainerShow(csp *wwapiv1.ContainerShowParameter) (response *wwapiv1.Conta
return
}
func ContainerRename(crp *wwapiv1.ContainerRenameParameter) (err error) {
// rename the container source folder
sourceDir := container.SourceDir(crp.ContainerName)
destDir := container.SourceDir(crp.TargetName)
func ImageRename(crp *wwapiv1.ImageRenameParameter) (err error) {
// rename the image source folder
sourceDir := image.SourceDir(crp.ImageName)
destDir := image.SourceDir(crp.TargetName)
err = os.Rename(sourceDir, destDir)
if err != nil {
return err
}
err = container.DeleteImage(crp.ContainerName)
err = image.DeleteImage(crp.ImageName)
if err != nil {
wwlog.Warn("Could not remove image files for %s: %s", crp.ContainerName, err)
wwlog.Warn("Could not remove image files for %s: %s", crp.ImageName, err)
}
if crp.Build {
err = container.Build(crp.TargetName, true)
err = image.Build(crp.TargetName, true)
if err != nil {
return err
}
}
// update the nodes profiles container name
// update the nodes profiles image name
nodeDB, err := node.New()
if err != nil {
return err
@@ -365,8 +365,8 @@ func ContainerRename(crp *wwapiv1.ContainerRenameParameter) (err error) {
return err
}
for _, node := range nodes {
if node.ContainerName == crp.ContainerName {
node.ContainerName = crp.TargetName
if node.ImageName == crp.ImageName {
node.ImageName = crp.TargetName
}
}
@@ -375,8 +375,8 @@ func ContainerRename(crp *wwapiv1.ContainerRenameParameter) (err error) {
return err
}
for _, profile := range profiles {
if profile.ContainerName == crp.ContainerName {
profile.ContainerName = crp.TargetName
if profile.ImageName == crp.ImageName {
profile.ImageName = crp.TargetName
}
}

View File

@@ -74,7 +74,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
}
} else if nodeGet.Type == wwapiv1.GetNodeList_Long {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s", "NODE NAME", "KERNEL VERSION", "CONTAINER", "OVERLAYS (S/R)"))
fmt.Sprintf("%s:=:%s:=:%s:=:%s", "NODE NAME", "KERNEL VERSION", "IMAGE", "OVERLAYS (S/R)"))
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
kernelVersion := ""
if n.Kernel != nil {
@@ -83,7 +83,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s", n.Id(),
kernelVersion,
n.ContainerName,
n.ImageName,
strings.Join(n.SystemOverlay, ",")+"/"+strings.Join(n.RuntimeOverlay, ",")))
}
} else if nodeGet.Type == wwapiv1.GetNodeList_All {

View File

@@ -16,33 +16,33 @@ message NodeDBHash {
string hash = 1;
}
// Container
// Image
// ContainerBuildParameter contains input for building zero or more containers.
message ContainerBuildParameter {
repeated string containerNames = 1;
// ImageBuildParameter contains input for building zero or more images.
message ImageBuildParameter {
repeated string imageNames = 1;
bool force = 2;
bool all = 3;
// bool default = 4;
}
// ContainerDeleteParameter contains input for removing containers from Warewulf
// ImageDeleteParameter contains input for removing images from Warewulf
// management.
message ContainerDeleteParameter {
repeated string containerNames = 1;
message ImageDeleteParameter {
repeated string imageNames = 1;
}
// ContainerCopyParameter contains 2 inputs : first one for the source container name and second one for the duplicated container name.
message ContainerCopyParameter {
string containerSource = 1;
string containerDestination = 2;
// ImageCopyParameter contains 2 inputs : first one for the image source name and second one for the duplicated image name.
message ImageCopyParameter {
string imageSource = 1;
string imageDestination = 2;
bool build = 3;
}
// ContainerImportParameter has all input for importing a container.
message ContainerImportParameter{
string source = 1; // container source uri
string name = 2; // container name
// ImageImportParameter has all input for importing an image.
message ImageImportParameter{
string source = 1; // image source uri
string name = 2; // image name
bool force = 3;
bool update = 4;
bool build = 5;
@@ -54,9 +54,9 @@ message ContainerImportParameter{
string platform = 11;
}
// ContainerInfo has data on each container. This is emitted in the
// ContainerListResponse.
message ContainerInfo {
// ImageInfo has data on each image. This is emitted in the
// ImageListResponse.
message ImageInfo {
string name = 1;
uint32 nodeCount = 2;
string kernelVersion = 3;
@@ -67,32 +67,32 @@ message ContainerInfo {
uint64 imgSizeComp = 8;
}
// ContainerListResponse has all information that ContainerList provides.
message ContainerListResponse {
repeated ContainerInfo containers = 1;
// ImageListResponse has all information that ImageList provides.
message ImageListResponse {
repeated ImageInfo images = 1;
}
// ContainerShowParameter is the input for ContainerShow.
message ContainerShowParameter {
string containerName = 1;
// ImageShowParameter is the input for ImageShow.
message ImageShowParameter {
string imageName = 1;
}
// ContainerShowResponse has all information emitted on ContainerShow.
message ContainerShowResponse {
// ImageShowResponse has all information emitted on ImageShow.
message ImageShowResponse {
string Name = 1;
string Rootfs = 2;
repeated string Nodes = 3;
string KernelVersion = 4;
}
// ContainerSyncUserParameter is the input for ContainerSyncUser.
message ContainerSyncUserParameter {
string containerName = 1;
// ImageSyncUserParameter is the input for ImageSyncUser.
message ImageSyncUserParameter {
string imageName = 1;
}
// ContainerRenameParameter is the input for ContainerRename
message ContainerRenameParameter {
string containerName = 1;
// ImageRenameParameter is the input for ImageRename
message ImageRenameParameter {
string imageName = 1;
string targetName = 2;
bool build = 3;
}
@@ -241,56 +241,56 @@ message CanWriteConfig {
// WWApi defines the wwapid service web interface.
service WWApi {
// Containers
// Images
// ContainerBuild builds zero or more containers.
rpc ContainerBuild(ContainerBuildParameter) returns (ContainerListResponse) {
// ImageBuild builds zero or more images.
rpc ImageBuild(ImageBuildParameter) returns (ImageListResponse) {
option (google.api.http) = {
post: "/v1/containerbuild"
post: "/v1/imagebuild"
body: "*"
};
}
// ContainerDelete removes one or more container from Warewulf management.
rpc ContainerDelete(ContainerDeleteParameter) returns (google.protobuf.Empty) {
// ImageDelete removes one or more image from Warewulf management.
rpc ImageDelete(ImageDeleteParameter) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/container"
delete: "/v1/image"
};
}
rpc ContainerCopy(ContainerCopyParameter) returns (google.protobuf.Empty) {
rpc ImageCopy(ImageCopyParameter) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v1/containercopy"
post: "/v1/imagecopy"
body: "*"
};
}
// ContainerImport imports a container to Warewulf.
rpc ContainerImport(ContainerImportParameter) returns (ContainerListResponse) {
// ImageImport imports an image to Warewulf.
rpc ImageImport(ImageImportParameter) returns (ImageListResponse) {
option(google.api.http) = {
post: "/v1/container"
post: "/v1/image"
body: "*"
};
}
// ContainerList lists ContainerInfo for each container.
rpc ContainerList(google.protobuf.Empty) returns (ContainerListResponse) {
// ImageList lists ImageInfo for each image.
rpc ImageList(google.protobuf.Empty) returns (ImageListResponse) {
option (google.api.http) = {
get: "/v1/container"
get: "/v1/image"
};
}
// ContainerShow lists ContainerShow for each container.
rpc ContainerShow(ContainerShowParameter) returns (ContainerShowResponse) {
// ImageShow lists ImageShow for each image.
rpc ImageShow(ImageShowParameter) returns (ImageShowResponse) {
option (google.api.http) = {
get: "/v1/containershow"
get: "/v1/imageshow"
};
}
// ContainerRename renames the container
rpc ContainerRename(ContainerRenameParameter) returns (google.protobuf.Empty) {
// ImageRename renames the image
rpc ImageRename(ImageRenameParameter) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v1/containerrename"
post: "/v1/imagerename"
body: "*"
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -32,8 +32,8 @@ var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
func request_WWApi_ContainerBuild_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerBuildParameter
func request_WWApi_ImageBuild_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageBuildParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -44,13 +44,13 @@ func request_WWApi_ContainerBuild_0(ctx context.Context, marshaler runtime.Marsh
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerBuild(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageBuild(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerBuild_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerBuildParameter
func local_request_WWApi_ImageBuild_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageBuildParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -61,49 +61,49 @@ func local_request_WWApi_ContainerBuild_0(ctx context.Context, marshaler runtime
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerBuild(ctx, &protoReq)
msg, err := server.ImageBuild(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_WWApi_ContainerDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
filter_WWApi_ImageDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_WWApi_ContainerDelete_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerDeleteParameter
func request_WWApi_ImageDelete_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageDeleteParameter
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ContainerDelete_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ImageDelete_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerDelete_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerDeleteParameter
func local_request_WWApi_ImageDelete_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageDeleteParameter
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ContainerDelete_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ImageDelete_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerDelete(ctx, &protoReq)
msg, err := server.ImageDelete(ctx, &protoReq)
return msg, metadata, err
}
func request_WWApi_ContainerCopy_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerCopyParameter
func request_WWApi_ImageCopy_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageCopyParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -114,13 +114,13 @@ func request_WWApi_ContainerCopy_0(ctx context.Context, marshaler runtime.Marsha
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerCopy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageCopy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerCopy_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerCopyParameter
func local_request_WWApi_ImageCopy_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageCopyParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -131,13 +131,13 @@ func local_request_WWApi_ContainerCopy_0(ctx context.Context, marshaler runtime.
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerCopy(ctx, &protoReq)
msg, err := server.ImageCopy(ctx, &protoReq)
return msg, metadata, err
}
func request_WWApi_ContainerImport_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerImportParameter
func request_WWApi_ImageImport_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageImportParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -148,13 +148,13 @@ func request_WWApi_ContainerImport_0(ctx context.Context, marshaler runtime.Mars
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerImport(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageImport(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerImport_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerImportParameter
func local_request_WWApi_ImageImport_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageImportParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -165,67 +165,67 @@ func local_request_WWApi_ContainerImport_0(ctx context.Context, marshaler runtim
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerImport(ctx, &protoReq)
msg, err := server.ImageImport(ctx, &protoReq)
return msg, metadata, err
}
func request_WWApi_ContainerList_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func request_WWApi_ImageList_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq emptypb.Empty
var metadata runtime.ServerMetadata
msg, err := client.ContainerList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageList(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerList_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func local_request_WWApi_ImageList_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq emptypb.Empty
var metadata runtime.ServerMetadata
msg, err := server.ContainerList(ctx, &protoReq)
msg, err := server.ImageList(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_WWApi_ContainerShow_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
filter_WWApi_ImageShow_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_WWApi_ContainerShow_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerShowParameter
func request_WWApi_ImageShow_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageShowParameter
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ContainerShow_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ImageShow_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerShow(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageShow(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerShow_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerShowParameter
func local_request_WWApi_ImageShow_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageShowParameter
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ContainerShow_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_WWApi_ImageShow_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerShow(ctx, &protoReq)
msg, err := server.ImageShow(ctx, &protoReq)
return msg, metadata, err
}
func request_WWApi_ContainerRename_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerRenameParameter
func request_WWApi_ImageRename_0(ctx context.Context, marshaler runtime.Marshaler, client WWApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageRenameParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -236,13 +236,13 @@ func request_WWApi_ContainerRename_0(ctx context.Context, marshaler runtime.Mars
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ContainerRename(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ImageRename(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_WWApi_ContainerRename_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ContainerRenameParameter
func local_request_WWApi_ImageRename_0(ctx context.Context, marshaler runtime.Marshaler, server WWApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ImageRenameParameter
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
@@ -253,7 +253,7 @@ func local_request_WWApi_ContainerRename_0(ctx context.Context, marshaler runtim
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ContainerRename(ctx, &protoReq)
msg, err := server.ImageRename(ctx, &protoReq)
return msg, metadata, err
}
@@ -458,7 +458,7 @@ func local_request_WWApi_Version_0(ctx context.Context, marshaler runtime.Marsha
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterWWApiHandlerFromEndpoint instead.
func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WWApiServer) error {
mux.Handle("POST", pattern_WWApi_ContainerBuild_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageBuild_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -466,12 +466,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerBuild", runtime.WithHTTPPathPattern("/v1/containerbuild"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageBuild", runtime.WithHTTPPathPattern("/v1/imagebuild"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerBuild_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageBuild_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -479,11 +479,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerBuild_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageBuild_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_WWApi_ContainerDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("DELETE", pattern_WWApi_ImageDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -491,12 +491,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerDelete", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageDelete", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -504,11 +504,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerCopy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageCopy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -516,12 +516,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerCopy", runtime.WithHTTPPathPattern("/v1/containercopy"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageCopy", runtime.WithHTTPPathPattern("/v1/imagecopy"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerCopy_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageCopy_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -529,11 +529,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerCopy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageCopy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerImport_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageImport_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -541,12 +541,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerImport", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageImport", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerImport_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageImport_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -554,11 +554,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerImport_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageImport_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_WWApi_ContainerList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_WWApi_ImageList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -566,12 +566,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerList", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageList", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerList_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageList_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -579,11 +579,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_WWApi_ContainerShow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_WWApi_ImageShow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -591,12 +591,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerShow", runtime.WithHTTPPathPattern("/v1/containershow"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageShow", runtime.WithHTTPPathPattern("/v1/imageshow"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerShow_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageShow_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -604,11 +604,11 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerShow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageShow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerRename_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageRename_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -616,12 +616,12 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerRename", runtime.WithHTTPPathPattern("/v1/containerrename"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageRename", runtime.WithHTTPPathPattern("/v1/imagerename"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_WWApi_ContainerRename_0(annotatedContext, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_WWApi_ImageRename_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
@@ -629,7 +629,7 @@ func RegisterWWApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
return
}
forward_WWApi_ContainerRename_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageRename_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
@@ -824,157 +824,157 @@ func RegisterWWApiHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc
// "WWApiClient" to call the correct interceptors.
func RegisterWWApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WWApiClient) error {
mux.Handle("POST", pattern_WWApi_ContainerBuild_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageBuild_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerBuild", runtime.WithHTTPPathPattern("/v1/containerbuild"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageBuild", runtime.WithHTTPPathPattern("/v1/imagebuild"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerBuild_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageBuild_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerBuild_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageBuild_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_WWApi_ContainerDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("DELETE", pattern_WWApi_ImageDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerDelete", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageDelete", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerCopy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageCopy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerCopy", runtime.WithHTTPPathPattern("/v1/containercopy"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageCopy", runtime.WithHTTPPathPattern("/v1/imagecopy"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerCopy_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageCopy_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerCopy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageCopy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerImport_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageImport_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerImport", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageImport", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerImport_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageImport_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerImport_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageImport_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_WWApi_ContainerList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_WWApi_ImageList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerList", runtime.WithHTTPPathPattern("/v1/container"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageList", runtime.WithHTTPPathPattern("/v1/image"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerList_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageList_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageList_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_WWApi_ContainerShow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_WWApi_ImageShow_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerShow", runtime.WithHTTPPathPattern("/v1/containershow"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageShow", runtime.WithHTTPPathPattern("/v1/imageshow"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerShow_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageShow_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerShow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageShow_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_WWApi_ContainerRename_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_WWApi_ImageRename_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ContainerRename", runtime.WithHTTPPathPattern("/v1/containerrename"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/wwapi.v1.WWApi/ImageRename", runtime.WithHTTPPathPattern("/v1/imagerename"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WWApi_ContainerRename_0(annotatedContext, inboundMarshaler, client, req, pathParams)
resp, md, err := request_WWApi_ImageRename_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_WWApi_ContainerRename_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_WWApi_ImageRename_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
@@ -1114,19 +1114,19 @@ func RegisterWWApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}
var (
pattern_WWApi_ContainerBuild_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "containerbuild"}, ""))
pattern_WWApi_ImageBuild_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "imagebuild"}, ""))
pattern_WWApi_ContainerDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "container"}, ""))
pattern_WWApi_ImageDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "image"}, ""))
pattern_WWApi_ContainerCopy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "containercopy"}, ""))
pattern_WWApi_ImageCopy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "imagecopy"}, ""))
pattern_WWApi_ContainerImport_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "container"}, ""))
pattern_WWApi_ImageImport_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "image"}, ""))
pattern_WWApi_ContainerList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "container"}, ""))
pattern_WWApi_ImageList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "image"}, ""))
pattern_WWApi_ContainerShow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "containershow"}, ""))
pattern_WWApi_ImageShow_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "imageshow"}, ""))
pattern_WWApi_ContainerRename_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "containerrename"}, ""))
pattern_WWApi_ImageRename_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "imagerename"}, ""))
pattern_WWApi_NodeAdd_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "node"}, ""))
@@ -1142,19 +1142,19 @@ var (
)
var (
forward_WWApi_ContainerBuild_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageBuild_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerDelete_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageDelete_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerCopy_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageCopy_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerImport_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageImport_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerList_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageList_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerShow_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageShow_0 = runtime.ForwardResponseMessage
forward_WWApi_ContainerRename_0 = runtime.ForwardResponseMessage
forward_WWApi_ImageRename_0 = runtime.ForwardResponseMessage
forward_WWApi_NodeAdd_0 = runtime.ForwardResponseMessage

View File

@@ -23,19 +23,19 @@ const _ = grpc.SupportPackageIsVersion7
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type WWApiClient interface {
// ContainerBuild builds zero or more containers.
ContainerBuild(ctx context.Context, in *ContainerBuildParameter, opts ...grpc.CallOption) (*ContainerListResponse, error)
// ContainerDelete removes one or more container from Warewulf management.
ContainerDelete(ctx context.Context, in *ContainerDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
ContainerCopy(ctx context.Context, in *ContainerCopyParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
// ContainerImport imports a container to Warewulf.
ContainerImport(ctx context.Context, in *ContainerImportParameter, opts ...grpc.CallOption) (*ContainerListResponse, error)
// ContainerList lists ContainerInfo for each container.
ContainerList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ContainerListResponse, error)
// ContainerShow lists ContainerShow for each container.
ContainerShow(ctx context.Context, in *ContainerShowParameter, opts ...grpc.CallOption) (*ContainerShowResponse, error)
// ContainerRename renames the container
ContainerRename(ctx context.Context, in *ContainerRenameParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
// ImageBuild builds zero or more images.
ImageBuild(ctx context.Context, in *ImageBuildParameter, opts ...grpc.CallOption) (*ImageListResponse, error)
// ImageDelete removes one or more image from Warewulf management.
ImageDelete(ctx context.Context, in *ImageDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
ImageCopy(ctx context.Context, in *ImageCopyParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
// ImageImport imports an image to Warewulf.
ImageImport(ctx context.Context, in *ImageImportParameter, opts ...grpc.CallOption) (*ImageListResponse, error)
// ImageList lists ImageInfo for each image.
ImageList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImageListResponse, error)
// ImageShow lists ImageShow for each image.
ImageShow(ctx context.Context, in *ImageShowParameter, opts ...grpc.CallOption) (*ImageShowResponse, error)
// ImageRename renames the image
ImageRename(ctx context.Context, in *ImageRenameParameter, opts ...grpc.CallOption) (*emptypb.Empty, error)
// NodeAdd adds one or more nodes for management by Warewulf and returns
// the added nodes. Node fields may be shimmed in per profiles.
NodeAdd(ctx context.Context, in *NodeAddParameter, opts ...grpc.CallOption) (*NodeListResponse, error)
@@ -61,63 +61,63 @@ func NewWWApiClient(cc grpc.ClientConnInterface) WWApiClient {
return &wWApiClient{cc}
}
func (c *wWApiClient) ContainerBuild(ctx context.Context, in *ContainerBuildParameter, opts ...grpc.CallOption) (*ContainerListResponse, error) {
out := new(ContainerListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerBuild", in, out, opts...)
func (c *wWApiClient) ImageBuild(ctx context.Context, in *ImageBuildParameter, opts ...grpc.CallOption) (*ImageListResponse, error) {
out := new(ImageListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageBuild", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerDelete(ctx context.Context, in *ContainerDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
func (c *wWApiClient) ImageDelete(ctx context.Context, in *ImageDeleteParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerDelete", in, out, opts...)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageDelete", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerCopy(ctx context.Context, in *ContainerCopyParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
func (c *wWApiClient) ImageCopy(ctx context.Context, in *ImageCopyParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerCopy", in, out, opts...)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageCopy", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerImport(ctx context.Context, in *ContainerImportParameter, opts ...grpc.CallOption) (*ContainerListResponse, error) {
out := new(ContainerListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerImport", in, out, opts...)
func (c *wWApiClient) ImageImport(ctx context.Context, in *ImageImportParameter, opts ...grpc.CallOption) (*ImageListResponse, error) {
out := new(ImageListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageImport", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ContainerListResponse, error) {
out := new(ContainerListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerList", in, out, opts...)
func (c *wWApiClient) ImageList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImageListResponse, error) {
out := new(ImageListResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageList", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerShow(ctx context.Context, in *ContainerShowParameter, opts ...grpc.CallOption) (*ContainerShowResponse, error) {
out := new(ContainerShowResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerShow", in, out, opts...)
func (c *wWApiClient) ImageShow(ctx context.Context, in *ImageShowParameter, opts ...grpc.CallOption) (*ImageShowResponse, error) {
out := new(ImageShowResponse)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageShow", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *wWApiClient) ContainerRename(ctx context.Context, in *ContainerRenameParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
func (c *wWApiClient) ImageRename(ctx context.Context, in *ImageRenameParameter, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ContainerRename", in, out, opts...)
err := c.cc.Invoke(ctx, "/wwapi.v1.WWApi/ImageRename", in, out, opts...)
if err != nil {
return nil, err
}
@@ -182,19 +182,19 @@ func (c *wWApiClient) Version(ctx context.Context, in *emptypb.Empty, opts ...gr
// All implementations must embed UnimplementedWWApiServer
// for forward compatibility
type WWApiServer interface {
// ContainerBuild builds zero or more containers.
ContainerBuild(context.Context, *ContainerBuildParameter) (*ContainerListResponse, error)
// ContainerDelete removes one or more container from Warewulf management.
ContainerDelete(context.Context, *ContainerDeleteParameter) (*emptypb.Empty, error)
ContainerCopy(context.Context, *ContainerCopyParameter) (*emptypb.Empty, error)
// ContainerImport imports a container to Warewulf.
ContainerImport(context.Context, *ContainerImportParameter) (*ContainerListResponse, error)
// ContainerList lists ContainerInfo for each container.
ContainerList(context.Context, *emptypb.Empty) (*ContainerListResponse, error)
// ContainerShow lists ContainerShow for each container.
ContainerShow(context.Context, *ContainerShowParameter) (*ContainerShowResponse, error)
// ContainerRename renames the container
ContainerRename(context.Context, *ContainerRenameParameter) (*emptypb.Empty, error)
// ImageBuild builds zero or more images.
ImageBuild(context.Context, *ImageBuildParameter) (*ImageListResponse, error)
// ImageDelete removes one or more image from Warewulf management.
ImageDelete(context.Context, *ImageDeleteParameter) (*emptypb.Empty, error)
ImageCopy(context.Context, *ImageCopyParameter) (*emptypb.Empty, error)
// ImageImport imports an image to Warewulf.
ImageImport(context.Context, *ImageImportParameter) (*ImageListResponse, error)
// ImageList lists ImageInfo for each image.
ImageList(context.Context, *emptypb.Empty) (*ImageListResponse, error)
// ImageShow lists ImageShow for each image.
ImageShow(context.Context, *ImageShowParameter) (*ImageShowResponse, error)
// ImageRename renames the image
ImageRename(context.Context, *ImageRenameParameter) (*emptypb.Empty, error)
// NodeAdd adds one or more nodes for management by Warewulf and returns
// the added nodes. Node fields may be shimmed in per profiles.
NodeAdd(context.Context, *NodeAddParameter) (*NodeListResponse, error)
@@ -217,26 +217,26 @@ type WWApiServer interface {
type UnimplementedWWApiServer struct {
}
func (UnimplementedWWApiServer) ContainerBuild(context.Context, *ContainerBuildParameter) (*ContainerListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerBuild not implemented")
func (UnimplementedWWApiServer) ImageBuild(context.Context, *ImageBuildParameter) (*ImageListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageBuild not implemented")
}
func (UnimplementedWWApiServer) ContainerDelete(context.Context, *ContainerDeleteParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerDelete not implemented")
func (UnimplementedWWApiServer) ImageDelete(context.Context, *ImageDeleteParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageDelete not implemented")
}
func (UnimplementedWWApiServer) ContainerCopy(context.Context, *ContainerCopyParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerCopy not implemented")
func (UnimplementedWWApiServer) ImageCopy(context.Context, *ImageCopyParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageCopy not implemented")
}
func (UnimplementedWWApiServer) ContainerImport(context.Context, *ContainerImportParameter) (*ContainerListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerImport not implemented")
func (UnimplementedWWApiServer) ImageImport(context.Context, *ImageImportParameter) (*ImageListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageImport not implemented")
}
func (UnimplementedWWApiServer) ContainerList(context.Context, *emptypb.Empty) (*ContainerListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerList not implemented")
func (UnimplementedWWApiServer) ImageList(context.Context, *emptypb.Empty) (*ImageListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageList not implemented")
}
func (UnimplementedWWApiServer) ContainerShow(context.Context, *ContainerShowParameter) (*ContainerShowResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerShow not implemented")
func (UnimplementedWWApiServer) ImageShow(context.Context, *ImageShowParameter) (*ImageShowResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageShow not implemented")
}
func (UnimplementedWWApiServer) ContainerRename(context.Context, *ContainerRenameParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ContainerRename not implemented")
func (UnimplementedWWApiServer) ImageRename(context.Context, *ImageRenameParameter) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImageRename not implemented")
}
func (UnimplementedWWApiServer) NodeAdd(context.Context, *NodeAddParameter) (*NodeListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method NodeAdd not implemented")
@@ -269,128 +269,128 @@ func RegisterWWApiServer(s grpc.ServiceRegistrar, srv WWApiServer) {
s.RegisterService(&WWApi_ServiceDesc, srv)
}
func _WWApi_ContainerBuild_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerBuildParameter)
func _WWApi_ImageBuild_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageBuildParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerBuild(ctx, in)
return srv.(WWApiServer).ImageBuild(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerBuild",
FullMethod: "/wwapi.v1.WWApi/ImageBuild",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerBuild(ctx, req.(*ContainerBuildParameter))
return srv.(WWApiServer).ImageBuild(ctx, req.(*ImageBuildParameter))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerDeleteParameter)
func _WWApi_ImageDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageDeleteParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerDelete(ctx, in)
return srv.(WWApiServer).ImageDelete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerDelete",
FullMethod: "/wwapi.v1.WWApi/ImageDelete",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerDelete(ctx, req.(*ContainerDeleteParameter))
return srv.(WWApiServer).ImageDelete(ctx, req.(*ImageDeleteParameter))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerCopy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerCopyParameter)
func _WWApi_ImageCopy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageCopyParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerCopy(ctx, in)
return srv.(WWApiServer).ImageCopy(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerCopy",
FullMethod: "/wwapi.v1.WWApi/ImageCopy",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerCopy(ctx, req.(*ContainerCopyParameter))
return srv.(WWApiServer).ImageCopy(ctx, req.(*ImageCopyParameter))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerImport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerImportParameter)
func _WWApi_ImageImport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageImportParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerImport(ctx, in)
return srv.(WWApiServer).ImageImport(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerImport",
FullMethod: "/wwapi.v1.WWApi/ImageImport",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerImport(ctx, req.(*ContainerImportParameter))
return srv.(WWApiServer).ImageImport(ctx, req.(*ImageImportParameter))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
func _WWApi_ImageList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerList(ctx, in)
return srv.(WWApiServer).ImageList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerList",
FullMethod: "/wwapi.v1.WWApi/ImageList",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerList(ctx, req.(*emptypb.Empty))
return srv.(WWApiServer).ImageList(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerShowParameter)
func _WWApi_ImageShow_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageShowParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerShow(ctx, in)
return srv.(WWApiServer).ImageShow(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerShow",
FullMethod: "/wwapi.v1.WWApi/ImageShow",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerShow(ctx, req.(*ContainerShowParameter))
return srv.(WWApiServer).ImageShow(ctx, req.(*ImageShowParameter))
}
return interceptor(ctx, in, info, handler)
}
func _WWApi_ContainerRename_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContainerRenameParameter)
func _WWApi_ImageRename_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImageRenameParameter)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WWApiServer).ContainerRename(ctx, in)
return srv.(WWApiServer).ImageRename(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wwapi.v1.WWApi/ContainerRename",
FullMethod: "/wwapi.v1.WWApi/ImageRename",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WWApiServer).ContainerRename(ctx, req.(*ContainerRenameParameter))
return srv.(WWApiServer).ImageRename(ctx, req.(*ImageRenameParameter))
}
return interceptor(ctx, in, info, handler)
}
@@ -511,32 +511,32 @@ var WWApi_ServiceDesc = grpc.ServiceDesc{
HandlerType: (*WWApiServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ContainerBuild",
Handler: _WWApi_ContainerBuild_Handler,
MethodName: "ImageBuild",
Handler: _WWApi_ImageBuild_Handler,
},
{
MethodName: "ContainerDelete",
Handler: _WWApi_ContainerDelete_Handler,
MethodName: "ImageDelete",
Handler: _WWApi_ImageDelete_Handler,
},
{
MethodName: "ContainerCopy",
Handler: _WWApi_ContainerCopy_Handler,
MethodName: "ImageCopy",
Handler: _WWApi_ImageCopy_Handler,
},
{
MethodName: "ContainerImport",
Handler: _WWApi_ContainerImport_Handler,
MethodName: "ImageImport",
Handler: _WWApi_ImageImport_Handler,
},
{
MethodName: "ContainerList",
Handler: _WWApi_ContainerList_Handler,
MethodName: "ImageList",
Handler: _WWApi_ImageList_Handler,
},
{
MethodName: "ContainerShow",
Handler: _WWApi_ContainerShow_Handler,
MethodName: "ImageShow",
Handler: _WWApi_ImageShow_Handler,
},
{
MethodName: "ContainerRename",
Handler: _WWApi_ContainerRename_Handler,
MethodName: "ImageRename",
Handler: _WWApi_ImageRename_Handler,
},
{
MethodName: "NodeAdd",

View File

@@ -1,13 +1,13 @@
package config
// A MountEntry represents a bind mount that is applied to a container
// A MountEntry represents a bind mount that is applied to an image
// during exec and shell.
type MountEntry struct {
Source string `yaml:"source"`
Dest string `yaml:"dest,omitempty"`
ReadOnlyP *bool `yaml:"readonly,omitempty"`
Options string `yaml:"options,omitempty"` // ignored at the moment
CopyP *bool `yaml:"copy,omitempty"` // temporarily copy the file into the container
CopyP *bool `yaml:"copy,omitempty"` // temporarily copy the file into the image
}
func (this MountEntry) ReadOnly() bool {

View File

@@ -27,21 +27,21 @@ var cachedConf WarewulfYaml
// some information about the Warewulf server locally, and has
// [WarewulfConf], [DHCPConf], [TFTPConf], and [NFSConf] sub-sections.
type WarewulfYaml struct {
Comment string `yaml:"comment,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty"`
Ipaddr6 string `yaml:"ipaddr6,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Network string `yaml:"network,omitempty"`
Ipv6net string `yaml:"ipv6net,omitempty"`
Fqdn string `yaml:"fqdn,omitempty"`
Warewulf *WarewulfConf `yaml:"warewulf,omitempty"`
DHCP *DHCPConf `yaml:"dhcp,omitempty"`
TFTP *TFTPConf `yaml:"tftp,omitempty"`
NFS *NFSConf `yaml:"nfs,omitempty"`
SSH *SSHConf `yaml:"ssh,omitempty"`
MountsContainer []*MountEntry `yaml:"container mounts,omitempty" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
Paths *BuildConfig `yaml:"paths,omitempty"`
WWClient *WWClientConf `yaml:"wwclient,omitempty"`
Comment string `yaml:"comment,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty"`
Ipaddr6 string `yaml:"ipaddr6,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Network string `yaml:"network,omitempty"`
Ipv6net string `yaml:"ipv6net,omitempty"`
Fqdn string `yaml:"fqdn,omitempty"`
Warewulf *WarewulfConf `yaml:"warewulf,omitempty"`
DHCP *DHCPConf `yaml:"dhcp,omitempty"`
TFTP *TFTPConf `yaml:"tftp,omitempty"`
NFS *NFSConf `yaml:"nfs,omitempty"`
SSH *SSHConf `yaml:"ssh,omitempty"`
MountsImage []*MountEntry `yaml:"image mounts,omitempty" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"`
Paths *BuildConfig `yaml:"paths,omitempty"`
WWClient *WWClientConf `yaml:"wwclient,omitempty"`
warewulfconf string
}

View File

@@ -35,10 +35,10 @@ func TestDefaultWarewulfYaml(t *testing.T) {
assert.Empty(t, conf.NFS.ExportsExtended)
assert.Equal(t, "nfsd", conf.NFS.SystemdName)
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Source)
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Dest)
assert.False(t, conf.MountsContainer[0].ReadOnly())
assert.Empty(t, conf.MountsContainer[0].Options)
assert.Equal(t, "/etc/resolv.conf", conf.MountsImage[0].Source)
assert.Equal(t, "/etc/resolv.conf", conf.MountsImage[0].Dest)
assert.False(t, conf.MountsImage[0].ReadOnly())
assert.Empty(t, conf.MountsImage[0].Options)
assert.NotEmpty(t, conf.Paths.Bindir)
assert.NotEmpty(t, conf.Paths.Sysconfdir)
@@ -97,7 +97,7 @@ nfs:
- path: /opt
export options: ro,sync,no_root_squash
systemd name: nfs-server
container mounts:
image mounts:
- source: /etc/resolv.conf
dest: /etc/resolv.conf
readonly: true`
@@ -138,9 +138,9 @@ container mounts:
assert.Equal(t, "ro,sync,no_root_squash", conf.NFS.ExportsExtended[1].ExportOptions)
assert.Equal(t, "nfs-server", conf.NFS.SystemdName)
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Source)
assert.Equal(t, "/etc/resolv.conf", conf.MountsContainer[0].Dest)
assert.True(t, conf.MountsContainer[0].ReadOnly())
assert.Equal(t, "/etc/resolv.conf", conf.MountsImage[0].Source)
assert.Equal(t, "/etc/resolv.conf", conf.MountsImage[0].Dest)
assert.True(t, conf.MountsImage[0].ReadOnly())
}
func TestCache(t *testing.T) {

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"fmt"
@@ -11,19 +11,19 @@ import (
)
func Build(name string, buildForce bool) error {
wwlog.Info("Building container: %s", name)
wwlog.Info("Building image: %s", name)
rootfsPath := RootFsDir(name)
imagePath := ImageFile(name)
if !ValidSource(name) {
return errors.Errorf("Container does not exist: %s", name)
return errors.Errorf("Image does not exist: %s", name)
}
if !buildForce {
wwlog.Debug("Checking if there have been any updates to the VNFS directory")
wwlog.Debug("Checking if there have been any updates to the image source directory")
if util.PathIsNewer(rootfsPath, imagePath) {
wwlog.Info("Skipping (VNFS is current)")
wwlog.Info("Skipping (Image is current)")
return nil
}
}
@@ -39,7 +39,7 @@ func Build(name string, buildForce bool) error {
}
err := util.BuildFsImage(
"VNFS container "+name,
"Image "+name,
rootfsPath,
imagePath,
[]string{"*"},

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"path"
@@ -25,7 +25,7 @@ func RunDir(name string) string {
func ImageParentDir() string {
conf := warewulfconf.Get()
return path.Join(conf.Paths.WWProvisiondir, "container")
return path.Join(conf.Paths.WWProvisiondir, "image")
}
func ImageFile(name string) string {

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"context"
@@ -24,7 +24,7 @@ func ImportDocker(uri string, name string, sCtx *types.SystemContext) error {
}
if !ValidName(name) {
return errors.New("VNFS name contains illegal characters: " + name)
return errors.New("Image name contains illegal characters: " + name)
}
fullPath := RootFsDir(name)

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"path/filepath"
@@ -12,12 +12,12 @@ import (
"github.com/warewulf/warewulf/internal/pkg/util"
)
func Test_ImportContainerDir(t *testing.T) {
func Test_ImportImageDir(t *testing.T) {
var tests = map[string]struct {
files []string
sockets []string
}{
"empty container": {
"empty image": {
files: nil,
sockets: nil,
},
@@ -33,7 +33,7 @@ func Test_ImportContainerDir(t *testing.T) {
t.Run(name, func(t *testing.T) {
env := testenv.New(t)
defer env.RemoveAll()
src := "/tmp/testcontainer"
src := "/tmp/testImage"
env.CreateFile(filepath.Join(src, "/bin/sh"))
for _, file := range tt.files {
env.CreateFile(filepath.Join(src, file))
@@ -42,8 +42,8 @@ func Test_ImportContainerDir(t *testing.T) {
env.MkdirAll(filepath.Dir(filepath.Join(src, socket)))
assert.NoError(t, unix.Mknod(env.GetPath(filepath.Join(src, socket)), unix.S_IFSOCK|0777, 0))
}
assert.NoError(t, ImportDirectory(env.GetPath(src), "testcontainer"))
rootfs := "/var/lib/warewulf/chroots/testcontainer/rootfs"
assert.NoError(t, ImportDirectory(env.GetPath(src), "testImage"))
rootfs := "/var/lib/warewulf/chroots/testImage/rootfs"
for _, file := range tt.files {
assert.True(t, util.IsFile(env.GetPath(filepath.Join(rootfs, file))))
}

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"path/filepath"
@@ -24,8 +24,8 @@ func init() {
}
type Initramfs struct {
Path string
ContainerName string
Path string
imageName string
}
func (this *Initramfs) version() *version.Version {
@@ -48,13 +48,13 @@ func (this *Initramfs) Version() string {
}
func (this *Initramfs) FullPath() string {
root := RootFsDir(this.ContainerName)
root := RootFsDir(this.imageName)
return filepath.Join(root, this.Path)
}
func FindInitramfsFromPattern(containerName string, version string, pattern string) (initramfs *Initramfs) {
wwlog.Debug("FindInitramfsFromPattern(%v, %v, %v)", containerName, version, pattern)
root := RootFsDir(containerName)
func FindInitramfsFromPattern(imageName string, version string, pattern string) (initramfs *Initramfs) {
wwlog.Debug("FindInitramfsFromPattern(%v, %v, %v)", imageName, version, pattern)
root := RootFsDir(imageName)
fullPaths, err := filepath.Glob(filepath.Join(root, pattern))
wwlog.Debug("%v: fullPaths: %v", filepath.Join(root, pattern), fullPaths)
if err != nil {
@@ -65,7 +65,7 @@ func FindInitramfsFromPattern(containerName string, version string, pattern stri
if err != nil {
continue
} else {
initramfs := &Initramfs{Path: filepath.Join("/", path), ContainerName: containerName}
initramfs := &Initramfs{Path: filepath.Join("/", path), imageName: imageName}
wwlog.Info("%v", initramfs)
if strings.HasPrefix(initramfs.Version(), version) {
return initramfs
@@ -75,10 +75,10 @@ func FindInitramfsFromPattern(containerName string, version string, pattern stri
return nil
}
// FindInitramfs returns the Initramfs for a given container and (kernel) version
func FindInitramfs(containerName string, version string) *Initramfs {
// FindInitramfs returns the Initramfs for a given image and (kernel) version
func FindInitramfs(imageName string, version string) *Initramfs {
for _, pattern := range initramfsSearchPaths {
initramfs := FindInitramfsFromPattern(containerName, version, pattern)
initramfs := FindInitramfsFromPattern(imageName, version, pattern)
if initramfs != nil {
return initramfs
}

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"os"

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"strings"

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"os"
@@ -44,35 +44,35 @@ func grubNames() []string {
}
/*
find the path of the shim binary in container
find the path of the shim binary in image
*/
func ShimFind(container string) string {
var container_path string
if container != "" {
container_path = RootFsDir(container)
func ShimFind(image string) string {
var image_path string
if image != "" {
image_path = RootFsDir(image)
} else {
container_path = "/"
image_path = "/"
}
wwlog.Debug("Finding shim under paths: %s", container_path)
return BootLoaderFindPath(container_path, shimNames, shimDirs)
wwlog.Debug("Finding shim under paths: %s", image_path)
return BootLoaderFindPath(image_path, shimNames, shimDirs)
}
/*
find a grub.efi in the used container
find a grub.efi in the used image
*/
func GrubFind(container string) string {
var container_path string
if container != "" {
container_path = RootFsDir(container)
func GrubFind(image string) string {
var image_path string
if image != "" {
image_path = RootFsDir(image)
} else {
container_path = "/"
image_path = "/"
}
wwlog.Debug("Finding grub under paths: %s", container_path)
return BootLoaderFindPath(container_path, grubNames, grubDirs)
wwlog.Debug("Finding grub under paths: %s", image_path)
return BootLoaderFindPath(image_path, grubNames, grubDirs)
}
/*
find the path of the shim binary in container
find the path of the shim binary in image
*/
func BootLoaderFindPath(cpath string, names func() []string, paths func() []string) string {
for _, bdir := range paths() {

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"os"

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"bufio"
@@ -20,30 +20,30 @@ const passwdPath = "/etc/passwd"
const groupPath = "/etc/group"
// SyncUids updates the /etc/passwd and /etc/group files in the
// container identified by containerName by installing the equivalent
// image identified by imageName by installing the equivalent
// files from the host and appending names only in the
// container. Files in the container are updated to match the new
// image. Files in the image are updated to match the new
// numeric id assignments.
//
// If write is false, the container is not actually updated, but
// If write is false, the image is not actually updated, but
// relevant log entries and output are generated.
//
// Any I/O errors are returned unmodified.
//
// A conflict arises if the container has an entry with the same id as
// A conflict arises if the image has an entry with the same id as
// an entry in the host and the host does not have an entry with the
// same name. In this case, an error is returned.
func SyncUids(containerName string, write bool) error {
wwlog.Debug("SyncUids(containerName=%v, write=%v)", containerName, write)
containerPath := RootFsDir(containerName)
containerPasswdPath := path.Join(containerPath, passwdPath)
containerGroupPath := path.Join(containerPath, groupPath)
func SyncUids(imageName string, write bool) error {
wwlog.Debug("SyncUids(imageName=%v, write=%v)", imageName, write)
imagePath := RootFsDir(imageName)
imagePasswdPath := path.Join(imagePath, passwdPath)
imageGroupPath := path.Join(imagePath, groupPath)
passwdSync := make(syncDB)
if err := passwdSync.readFromHost(passwdPath); err != nil {
return err
}
if err := passwdSync.readFromContainer(containerPasswdPath); err != nil {
if err := passwdSync.readFromimage(imagePasswdPath); err != nil {
return err
}
if err := passwdSync.checkConflicts(); err != nil {
@@ -54,17 +54,17 @@ func SyncUids(containerName string, write bool) error {
if err := groupSync.readFromHost(groupPath); err != nil {
return err
}
if err := groupSync.readFromContainer(containerGroupPath); err != nil {
if err := groupSync.readFromimage(imageGroupPath); err != nil {
return err
}
if err := groupSync.checkConflicts(); err != nil {
return err
}
if err := passwdSync.findUserFiles(containerPath); err != nil {
if err := passwdSync.findUserFiles(imagePath); err != nil {
return err
}
if err := groupSync.findGroupFiles(containerPath); err != nil {
if err := groupSync.findGroupFiles(imagePath); err != nil {
return err
}
@@ -78,16 +78,16 @@ func SyncUids(containerName string, write bool) error {
if err := groupSync.chownGroupFiles(); err != nil {
return err
}
if err := passwdSync.update(containerPasswdPath, passwdPath); err != nil {
if err := passwdSync.update(imagePasswdPath, passwdPath); err != nil {
return err
}
if err := groupSync.update(containerGroupPath, groupPath); err != nil {
if err := groupSync.update(imageGroupPath, groupPath); err != nil {
return err
}
wwlog.Info("uid/gid synced for container %s", containerName)
wwlog.Info("uid/gid synced for image %s", imageName)
} else {
if passwdSync.needsSync() || groupSync.needsSync() {
wwlog.Info("uid/gid not synced: run `wwctl container syncuser --write %s`", containerName)
wwlog.Info("uid/gid not synced: run `wwctl image syncuser --write %s`", imageName)
} else {
wwlog.Info("uid/gid already synced")
}
@@ -97,24 +97,24 @@ func SyncUids(containerName string, write bool) error {
}
// A syncDB maps user or group names to syncInfo instances, which
// correlate IDs between host and container and track affected
// correlate IDs between host and image and track affected
// files. This can be used for either /etc/passwd or /etc/group IDs.
type syncDB map[string]syncInfo
// checkConflicts inspects a syncDB map for irreconcilable
// conflicts. A conflict arises if the container has an entry with the
// conflicts. A conflict arises if the image has an entry with the
// same id as an entry in the host and the host does not have an entry
// with the same name.
func (db syncDB) checkConflicts() error {
for nameInContainer, containerIds := range db {
if !containerIds.inContainer() || containerIds.inHost() {
for nameInimage, imageIds := range db {
if !imageIds.inimage() || imageIds.inHost() {
continue
}
for nameInHost, hostIds := range db {
if hostIds.HostID == containerIds.ContainerID {
wwlog.Warn("syncuser cannot determine what name should be assigned to id number %v: on the local host it is assigned to '%s'; but in the container it is assigned to '%s'. Since '%s' does not exist on the local host, it cannot be reassigned to a different id number. To resolve the conflict, add '%s' to the local host and re-run syncuser.", containerIds.ContainerID, nameInHost, nameInContainer, nameInContainer, nameInContainer)
return errors.New(fmt.Sprintf("id(%v) collision: host(%s) container(%s)", containerIds.ContainerID, nameInHost, nameInContainer))
if hostIds.HostID == imageIds.imageID {
wwlog.Warn("syncuser cannot determine what name should be assigned to id number %v: on the local host it is assigned to '%s'; but in the image it is assigned to '%s'. Since '%s' does not exist on the local host, it cannot be reassigned to a different id number. To resolve the conflict, add '%s' to the local host and re-run syncuser.", imageIds.imageID, nameInHost, nameInimage, nameInimage, nameInimage)
return errors.New(fmt.Sprintf("id(%v) collision: host(%s) image(%s)", imageIds.imageID, nameInHost, nameInimage))
}
}
}
@@ -127,11 +127,11 @@ func (db syncDB) checkConflicts() error {
// for the given syncDB map. (e.g., to differentiate between a user or
// group map)
func (db syncDB) log(prefix string) {
var onlyContainer, onlyHost, match, differ []string
var onlyimage, onlyHost, match, differ []string
for name, ids := range db {
wwlog.Debug("%s: %s: host(%v) container(%v) files: %v", prefix, name, ids.HostID, ids.ContainerID, ids.ContainerFiles)
if ids.onlyContainer() {
onlyContainer = append(onlyContainer, name)
wwlog.Debug("%s: %s: host(%v) image(%v) files: %v", prefix, name, ids.HostID, ids.imageID, ids.imageFiles)
if ids.onlyimage() {
onlyimage = append(onlyimage, name)
}
if ids.onlyHost() {
onlyHost = append(onlyHost, name)
@@ -144,7 +144,7 @@ func (db syncDB) log(prefix string) {
}
}
wwlog.Verbose("%s: container only: %v", prefix, onlyContainer)
wwlog.Verbose("%s: image only: %v", prefix, onlyimage)
wwlog.Verbose("%s: host only: %v", prefix, onlyHost)
wwlog.Verbose("%s: match: %v", prefix, match)
wwlog.Verbose("%s: differ: %v", prefix, differ)
@@ -154,10 +154,10 @@ func (db syncDB) log(prefix string) {
// syncDB map. Since the name and numerical id for both files are
// stored at fields 0 and 2, the same function can read both files.
//
// fromContainer identifies whether the given fileName includes
// entries from the host or the container.
func (db syncDB) read(fileName string, fromContainer bool) error {
wwlog.Debug("read %s (container: %t)", fileName, fromContainer)
// fromimage identifies whether the given fileName includes
// entries from the host or the image.
func (db syncDB) read(fileName string, fromimage bool) error {
wwlog.Debug("read %s (image: %t)", fileName, fromimage)
if file, err := os.Open(fileName); err != nil {
return err
} else {
@@ -186,14 +186,14 @@ func (db syncDB) read(fileName string, fromContainer bool) error {
}
entry, ok := db[name]
if !ok {
entry = syncInfo{HostID: -1, ContainerID: -1}
entry = syncInfo{HostID: -1, imageID: -1}
}
if fromContainer {
if entry.ContainerID == -1 {
entry.ContainerID = id
} else if entry.ContainerID != id {
wwlog.Warn("Ignoring container id(%v) for %s from %s after existing value %v", id, name, fileName, entry.ContainerID)
if fromimage {
if entry.imageID == -1 {
entry.imageID = id
} else if entry.imageID != id {
wwlog.Warn("Ignoring image id(%v) for %s from %s after existing value %v", id, name, fileName, entry.imageID)
continue
}
} else {
@@ -216,27 +216,27 @@ func (db syncDB) read(fileName string, fromContainer bool) error {
// Equivalent to read(fileName, false)
func (db syncDB) readFromHost(fileName string) error { return db.read(fileName, false) }
// readFromContainer reads fileName into a syncDB map.
// readFromimage reads fileName into a syncDB map.
//
// Equivalent to read(fileName, true)
func (db syncDB) readFromContainer(fileName string) error { return db.read(fileName, true) }
func (db syncDB) readFromimage(fileName string) error { return db.read(fileName, true) }
// findFiles finds files under containerPath that are owned by each
// tracked container ID.
// findFiles finds files under imagePath that are owned by each
// tracked image ID.
//
// If byGid is true, files with a matching gid are
// recorded. Otherwise, files with a matching uid are recorded.
func (db syncDB) findFiles(containerPath string, byGid bool) error {
wwlog.Debug("findFiles(containerPath=%v, byGid=%v)", containerPath, byGid)
func (db syncDB) findFiles(imagePath string, byGid bool) error {
wwlog.Debug("findFiles(imagePath=%v, byGid=%v)", imagePath, byGid)
syncIDs := make(map[int]string)
for name, info := range db {
if info.inHost() && info.inContainer() && !info.match() {
wwlog.Debug("syncID[%v] = %v", info.ContainerID, name)
syncIDs[info.ContainerID] = name
if info.inHost() && info.inimage() && !info.match() {
wwlog.Debug("syncID[%v] = %v", info.imageID, name)
syncIDs[info.imageID] = name
}
}
return filepath.Walk(containerPath, func(filePath string, fileInfo fs.FileInfo, err error) error {
return filepath.Walk(imagePath, func(filePath string, fileInfo fs.FileInfo, err error) error {
if stat, ok := fileInfo.Sys().(*syscall.Stat_t); ok {
var id int
if byGid {
@@ -246,8 +246,8 @@ func (db syncDB) findFiles(containerPath string, byGid bool) error {
}
if name, ok := syncIDs[id]; ok {
info := db[name]
wwlog.Debug("findFiles: %s: (%v -> %v, gid: %v)", filePath, info.ContainerID, info.HostID, byGid)
info.ContainerFiles = append(info.ContainerFiles, filePath)
wwlog.Debug("findFiles: %s: (%v -> %v, gid: %v)", filePath, info.imageID, info.HostID, byGid)
info.imageFiles = append(info.imageFiles, filePath)
db[name] = info
} else {
wwlog.Debug("findFiles: %s", filePath)
@@ -257,11 +257,11 @@ func (db syncDB) findFiles(containerPath string, byGid bool) error {
})
}
// findUserFiles is equivalent to findFiles(containerPath, false)
func (db syncDB) findUserFiles(containerPath string) error { return db.findFiles(containerPath, false) }
// findUserFiles is equivalent to findFiles(imagePath, false)
func (db syncDB) findUserFiles(imagePath string) error { return db.findFiles(imagePath, false) }
// findGroupFiles is equivalent to findFiles(containerPath, true)
func (db syncDB) findGroupFiles(containerPath string) error { return db.findFiles(containerPath, true) }
// findGroupFiles is equivalent to findFiles(imagePath, true)
func (db syncDB) findGroupFiles(imagePath string) error { return db.findFiles(imagePath, true) }
// chownFiles updates found files (see findFiles) to reflect ownership
// using host ids.
@@ -283,13 +283,13 @@ func (db syncDB) chownUserFiles() error { return db.chownFiles(false) }
// chownUserFiles is equivalent to chownFiles(true)
func (db syncDB) chownGroupFiles() error { return db.chownFiles(true) }
// getOnlyContainerLines returns the lines from fileName (either an
// getOnlyimageLines returns the lines from fileName (either an
// /etc/passwd or /etc/group file) for names that occur only in the
// container.
// image.
//
// These lines are added to the respective file from the host when
// updating the container.
func (db syncDB) getOnlyContainerLines(fileName string) ([]string, error) {
// updating the image.
func (db syncDB) getOnlyimageLines(fileName string) ([]string, error) {
file, err := os.Open(fileName)
if err != nil {
return nil, err
@@ -303,34 +303,34 @@ func (db syncDB) getOnlyContainerLines(fileName string) ([]string, error) {
fields := strings.Split(line, ":")
for name, ids := range db {
if fields[0] == name {
if ids.onlyContainer() {
if ids.onlyimage() {
lines = append(lines, line)
}
break
}
}
}
wwlog.Debug("file: %s, entries only in container: %v", fileName, lines)
wwlog.Debug("file: %s, entries only in image: %v", fileName, lines)
return lines, nil
}
// update replaces containerPath with hostPath and adds lines from
// getOnlyContainerLines to the end of containerPath. This is used to
// replace /etc/passwd (or /etc/group) in the container with the
// update replaces imagePath with hostPath and adds lines from
// getOnlyimageLines to the end of imagePath. This is used to
// replace /etc/passwd (or /etc/group) in the image with the
// equivalent file from the host while retaining names unique to the
// container.
func (db syncDB) update(containerPath string, hostPath string) error {
wwlog.Debug("update %s from %s)", containerPath, hostPath)
if lines, err := db.getOnlyContainerLines(containerPath); err != nil {
// image.
func (db syncDB) update(imagePath string, hostPath string) error {
wwlog.Debug("update %s from %s)", imagePath, hostPath)
if lines, err := db.getOnlyimageLines(imagePath); err != nil {
return err
} else {
if err := os.Remove(containerPath); err != nil {
if err := os.Remove(imagePath); err != nil {
return err
}
if err := util.CopyFile(hostPath, containerPath); err != nil {
if err := util.CopyFile(hostPath, imagePath); err != nil {
return err
}
if err := util.AppendLines(containerPath, lines); err != nil {
if err := util.AppendLines(imagePath, lines); err != nil {
return err
}
return nil
@@ -338,7 +338,7 @@ func (db syncDB) update(containerPath string, hostPath string) error {
}
// needsSync returns true if the syncDB map indicates that ids between
// the container and host are out-of-sync.
// the image and host are out-of-sync.
func (db syncDB) needsSync() bool {
for name, ids := range db {
if ids.onlyHost() {
@@ -346,7 +346,7 @@ func (db syncDB) needsSync() bool {
return true
}
if ids.differ() {
wwlog.Debug("sync required: %s is %v in host and %v in container", name, ids.HostID, ids.ContainerID)
wwlog.Debug("sync required: %s is %v in host and %v in image", name, ids.HostID, ids.imageID)
return true
}
}
@@ -354,13 +354,13 @@ func (db syncDB) needsSync() bool {
}
// sycncInfo correlates the numerical id of a name on the host
// (HostID) and the container (ContainerID), along with the files in
// the container that are owned by that name. This allows affected
// files to be updated when the HostID is applied to the container.
// (HostID) and the image (imageID), along with the files in
// the image that are owned by that name. This allows affected
// files to be updated when the HostID is applied to the image.
type syncInfo struct {
HostID int `access:"r,w"`
ContainerID int `access:"r,w"`
ContainerFiles []string `access:"r,w"`
HostID int `access:"r,w"`
imageID int `access:"r,w"`
imageFiles []string `access:"r,w"`
}
// inHost returns true if info has a record of an id for this name in
@@ -369,43 +369,43 @@ func (info *syncInfo) inHost() bool {
return info.HostID != -1
}
// inContainer returns true if info has a record of an id for this
// name in the container.
func (info *syncInfo) inContainer() bool {
return info.ContainerID != -1
// inimage returns true if info has a record of an id for this
// name in the image.
func (info *syncInfo) inimage() bool {
return info.imageID != -1
}
// onlyHost returns true if info has a record of an id for this name
// in the host and not in the container.
// in the host and not in the image.
func (info *syncInfo) onlyHost() bool {
return info.inHost() && !info.inContainer()
return info.inHost() && !info.inimage()
}
// onlyHost returns true if info has a record of an id for this name
// in the container and not in the host.
func (info *syncInfo) onlyContainer() bool {
return info.inContainer() && !info.inHost()
// in the image and not in the host.
func (info *syncInfo) onlyimage() bool {
return info.inimage() && !info.inHost()
}
// match returns true if info represents a name that exists with the
// same numerical id in both the host and the container.
// same numerical id in both the host and the image.
func (info *syncInfo) match() bool {
return info.inContainer() && info.inHost() && info.HostID == info.ContainerID
return info.inimage() && info.inHost() && info.HostID == info.imageID
}
// differ returns true if info represents a name that exists in both
// the host and the container but with different numerical ids.
// the host and the image but with different numerical ids.
func (info *syncInfo) differ() bool {
return info.inContainer() && info.inHost() && info.HostID != info.ContainerID
return info.inimage() && info.inHost() && info.HostID != info.imageID
}
// chownFiles updates the files recorded in info.ContainerFiles to use
// chownFiles updates the files recorded in info.imageFiles to use
// the numerical IDs from the host.
//
// If byGid is true, the file's gid is updated; otherwise, the file's
// uid is updated.
func (info *syncInfo) chownFiles(byGid bool) error {
for _, file := range info.ContainerFiles {
for _, file := range info.imageFiles {
if fileInfo, err := os.Stat(file); err != nil {
return err
} else {

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"bytes"
@@ -18,16 +18,16 @@ func writeTempFile(t *testing.T, input string) string {
return tempFile.Name()
}
func makeSyncDB(t *testing.T, hostInput string, containerInput string) syncDB {
func makeSyncDB(t *testing.T, hostInput string, imageInput string) syncDB {
hostFileName := writeTempFile(t, hostInput)
defer os.Remove(hostFileName)
containerFileName := writeTempFile(t, containerInput)
defer os.Remove(containerFileName)
imageFileName := writeTempFile(t, imageInput)
defer os.Remove(imageFileName)
db := make(syncDB)
var err error
err = db.readFromHost(hostFileName)
assert.NoError(t, err)
err = db.readFromContainer(containerFileName)
err = db.readFromimage(imageFileName)
assert.NoError(t, err)
return db
}
@@ -42,7 +42,7 @@ func Test_readFromHost_single(t *testing.T) {
assert.Len(t, db, 1)
assert.Equal(t, 1001, db["testuser"].HostID)
assert.Equal(t, -1, db["testuser"].ContainerID)
assert.Equal(t, -1, db["testuser"].imageID)
}
func Test_readFromHost_multiple(t *testing.T) {
@@ -58,47 +58,47 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash
assert.Len(t, db, 2)
assert.Equal(t, 1001, db["testuser1"].HostID)
assert.Equal(t, -1, db["testuser1"].ContainerID)
assert.Equal(t, -1, db["testuser1"].imageID)
assert.Equal(t, 1002, db["testuser2"].HostID)
assert.Equal(t, -1, db["testuser2"].ContainerID)
assert.Equal(t, -1, db["testuser2"].imageID)
}
func Test_readFromContainer_single(t *testing.T) {
containerFileName := writeTempFile(t, `testuser:x:1001:1001::/home/testuser:/bin/bash`)
defer os.Remove(containerFileName)
func Test_readFromimage_single(t *testing.T) {
imageFileName := writeTempFile(t, `testuser:x:1001:1001::/home/testuser:/bin/bash`)
defer os.Remove(imageFileName)
db := make(syncDB)
err := db.readFromContainer(containerFileName)
err := db.readFromimage(imageFileName)
assert.NoError(t, err)
assert.Len(t, db, 1)
assert.Equal(t, 1001, db["testuser"].ContainerID)
assert.Equal(t, 1001, db["testuser"].imageID)
assert.Equal(t, -1, db["testuser"].HostID)
}
func Test_readFromContainer_multiple(t *testing.T) {
containerFileName := writeTempFile(t, `
func Test_readFromimage_multiple(t *testing.T) {
imageFileName := writeTempFile(t, `
testuser1:x:1001:1001::/home/testuser:/bin/bash
testuser2:x:1002:1002::/home/testuser:/bin/bash
`)
defer os.Remove(containerFileName)
defer os.Remove(imageFileName)
db := make(syncDB)
err := db.readFromContainer(containerFileName)
err := db.readFromimage(imageFileName)
assert.NoError(t, err)
assert.Len(t, db, 2)
assert.Equal(t, 1001, db["testuser1"].ContainerID)
assert.Equal(t, 1001, db["testuser1"].imageID)
assert.Equal(t, -1, db["testuser1"].HostID)
assert.Equal(t, 1002, db["testuser2"].ContainerID)
assert.Equal(t, 1002, db["testuser2"].imageID)
assert.Equal(t, -1, db["testuser2"].HostID)
}
func Test_readFromBoth_multiple(t *testing.T) {
containerFileName := writeTempFile(t, `
imageFileName := writeTempFile(t, `
testuser1:x:1001:1001::/home/testuser:/bin/bash
testuser2:x:1002:1002::/home/testuser:/bin/bash
`)
defer os.Remove(containerFileName)
defer os.Remove(imageFileName)
hostFileName := writeTempFile(t, `
testuser1:x:2001:2001::/home/testuser:/bin/bash
@@ -108,16 +108,16 @@ testuser3:x:2003:2003::/home/testuser:/bin/bash
db := make(syncDB)
var err error
err = db.readFromContainer(containerFileName)
err = db.readFromimage(imageFileName)
assert.NoError(t, err)
err = db.readFromHost(hostFileName)
assert.NoError(t, err)
assert.Len(t, db, 3)
assert.Equal(t, 1001, db["testuser1"].ContainerID)
assert.Equal(t, 1001, db["testuser1"].imageID)
assert.Equal(t, 2001, db["testuser1"].HostID)
assert.Equal(t, 1002, db["testuser2"].ContainerID)
assert.Equal(t, 1002, db["testuser2"].imageID)
assert.Equal(t, -1, db["testuser2"].HostID)
assert.Equal(t, -1, db["testuser3"].ContainerID)
assert.Equal(t, -1, db["testuser3"].imageID)
assert.Equal(t, 2003, db["testuser3"].HostID)
}
@@ -145,12 +145,12 @@ func Test_checkConflicts_conflict(t *testing.T) {
assert.Error(t, db.checkConflicts())
}
func Test_getOnlyContainerLines(t *testing.T) {
containerFileName := writeTempFile(t, `
func Test_getOnlyimageLines(t *testing.T) {
imageFileName := writeTempFile(t, `
testuser1:x:1001:1001::/home/testuser:/bin/bash
testuser2:x:1002:1002::/home/testuser:/bin/bash
`)
defer os.Remove(containerFileName)
defer os.Remove(imageFileName)
hostFileName := writeTempFile(t, `
testuser1:x:2001:2001::/home/testuser:/bin/bash
@@ -160,12 +160,12 @@ testuser3:x:2003:2003::/home/testuser:/bin/bash
db := make(syncDB)
var err error
err = db.readFromContainer(containerFileName)
err = db.readFromimage(imageFileName)
assert.NoError(t, err)
err = db.readFromHost(hostFileName)
assert.NoError(t, err)
lines, err := db.getOnlyContainerLines(containerFileName)
lines, err := db.getOnlyimageLines(imageFileName)
assert.NoError(t, err)
assert.Len(t, lines, 1)
@@ -177,7 +177,7 @@ func Test_needsSync_empty(t *testing.T) {
assert.False(t, db.needsSync())
}
func Test_needsSync_containerOnly(t *testing.T) {
func Test_needsSync_imageOnly(t *testing.T) {
db := makeSyncDB(t, "", `
testuser1:x:1001:1001::/home/testuser:/bin/bash
testuser2:x:1002:1002::/home/testuser:/bin/bash`)
@@ -217,20 +217,20 @@ func Test_onlyHost(t *testing.T) {
db := makeSyncDB(t, "testuser1:x:2001:2001::/home/testuser:/bin/bash", "")
entry := db["testuser1"]
assert.True(t, entry.inHost())
assert.False(t, entry.inContainer())
assert.False(t, entry.inimage())
assert.True(t, entry.onlyHost())
assert.False(t, entry.onlyContainer())
assert.False(t, entry.onlyimage())
assert.False(t, entry.match())
assert.False(t, entry.differ())
}
func Test_onlyContainer(t *testing.T) {
func Test_onlyimage(t *testing.T) {
db := makeSyncDB(t, "", "testuser1:x:2001:2001::/home/testuser:/bin/bash")
entry := db["testuser1"]
assert.False(t, entry.inHost())
assert.True(t, entry.inContainer())
assert.True(t, entry.inimage())
assert.False(t, entry.onlyHost())
assert.True(t, entry.onlyContainer())
assert.True(t, entry.onlyimage())
assert.False(t, entry.match())
assert.False(t, entry.differ())
}
@@ -241,9 +241,9 @@ func Test_match(t *testing.T) {
"testuser1:x:2001:2001::/home/testuser:/bin/bash")
entry := db["testuser1"]
assert.True(t, entry.inHost())
assert.True(t, entry.inContainer())
assert.True(t, entry.inimage())
assert.False(t, entry.onlyHost())
assert.False(t, entry.onlyContainer())
assert.False(t, entry.onlyimage())
assert.True(t, entry.match())
assert.False(t, entry.differ())
}
@@ -254,9 +254,9 @@ func Test_differ(t *testing.T) {
"testuser1:x:2001:2001::/home/testuser:/bin/bash")
entry := db["testuser1"]
assert.True(t, entry.inHost())
assert.True(t, entry.inContainer())
assert.True(t, entry.inimage())
assert.False(t, entry.onlyHost())
assert.False(t, entry.onlyContainer())
assert.False(t, entry.onlyimage())
assert.False(t, entry.match())
assert.True(t, entry.differ())
}

View File

@@ -1,4 +1,4 @@
package container
package image
import (
"os"
@@ -12,7 +12,7 @@ import (
func ValidName(name string) bool {
if !util.ValidString(name, "^[\\w\\-\\.\\:]+$") {
wwlog.Warn("VNFS name has illegal characters: %s", name)
wwlog.Warn("Image name has illegal characters: %s", name)
return false
}
return true
@@ -23,9 +23,9 @@ func ListSources() ([]string, error) {
err := os.MkdirAll(SourceParentDir(), 0755)
if err != nil {
return ret, errors.New("Could not create VNFS source parent directory: " + SourceParentDir())
return ret, errors.New("Could not create image source parent directory: " + SourceParentDir())
}
wwlog.Debug("Searching for VNFS Rootfs directories: %s", SourceParentDir())
wwlog.Debug("Searching for image rootfs directories: %s", SourceParentDir())
sources, err := os.ReadDir(SourceParentDir())
if err != nil {
@@ -33,7 +33,7 @@ func ListSources() ([]string, error) {
}
for _, source := range sources {
wwlog.Verbose("Found VNFS source: %s", source.Name())
wwlog.Verbose("Found image source: %s", source.Name())
if !ValidName(source.Name()) {
continue
@@ -60,7 +60,7 @@ func ValidSource(name string) bool {
}
if !DoesSourceExist(name) {
wwlog.Verbose("Location is not a VNFS source directory: %s", name)
wwlog.Verbose("Location is not an image source directory: %s", name)
return false
}
@@ -68,7 +68,7 @@ func ValidSource(name string) bool {
}
/*
Delete the chroot of a container
Delete the chroot of an image
*/
func DeleteSource(name string) error {
fullPath := SourceDir(name)
@@ -91,24 +91,24 @@ func Duplicate(name string, destination string) error {
}
/*
Delete the image of a container
Delete the image of an image
*/
func DeleteImage(name string) error {
imageFile := ImageFile(name)
if util.IsFile(imageFile) {
wwlog.Verbose("removing %s for container %s", imageFile, name)
wwlog.Verbose("removing %s for image %s", imageFile, name)
errImg := os.Remove(imageFile)
wwlog.Verbose("removing %s for container %s", imageFile+".gz", name)
wwlog.Verbose("removing %s for image %s", imageFile+".gz", name)
errGz := os.Remove(imageFile + ".gz")
if errImg != nil {
return errors.Errorf("Problems delete %s for container %s: %s\n", imageFile, name, errImg)
return errors.Errorf("Problems delete %s for image %s: %s\n", imageFile, name, errImg)
}
if errGz != nil {
return errors.Errorf("Problems delete %s for container %s: %s\n", imageFile+".gz", name, errGz)
return errors.Errorf("Problems delete %s for image %s: %s\n", imageFile+".gz", name, errGz)
}
return nil
}
return errors.Errorf("Image %s of container %s doesn't exist\n", imageFile, name)
return errors.Errorf("Image %s of image %s doesn't exist\n", imageFile, name)
}
func IsWriteAble(name string) bool {

View File

@@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/util"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
@@ -67,29 +67,29 @@ func (k collection) Version(version string) *Kernel {
}
type Kernel struct {
Path string
ContainerName string
Path string
ImageName string
}
func FromNode(node *node.Node) *Kernel {
wwlog.Debug("FromNode(%v)", node)
if node.ContainerName == "" {
if node.ImageName == "" {
return nil
} else if node.Kernel != nil && node.Kernel.Version != "" {
kernel := &Kernel{ContainerName: node.ContainerName, Path: filepath.Join("/", node.Kernel.Version)}
kernel := &Kernel{ImageName: node.ImageName, Path: filepath.Join("/", node.Kernel.Version)}
if util.IsFile(kernel.FullPath()) {
return kernel
} else {
return FindKernels(node.ContainerName).Version(node.Kernel.Version)
return FindKernels(node.ImageName).Version(node.Kernel.Version)
}
} else {
return FindKernels(node.ContainerName).Default()
return FindKernels(node.ImageName).Default()
}
}
func FindKernelsFromPattern(containerName string, pattern string) (kernels collection) {
wwlog.Debug("FindKernelsFromPattern(%v, %v)", containerName, pattern)
root := container.RootFsDir(containerName)
func FindKernelsFromPattern(imageName string, pattern string) (kernels collection) {
wwlog.Debug("FindKernelsFromPattern(%v, %v)", imageName, pattern)
root := image.RootFsDir(imageName)
fullPaths, err := filepath.Glob(filepath.Join(root, pattern))
wwlog.Debug("%v: fullPaths: %v", filepath.Join(root, pattern), fullPaths)
if err != nil {
@@ -100,23 +100,23 @@ func FindKernelsFromPattern(containerName string, pattern string) (kernels colle
if err != nil {
continue
} else {
kernels = append(kernels, &Kernel{ContainerName: containerName, Path: filepath.Join("/", path)})
kernels = append(kernels, &Kernel{ImageName: imageName, Path: filepath.Join("/", path)})
}
}
return kernels
}
func FindKernels(containerName string) (kernels collection) {
wwlog.Debug("FindKernels(%v)", containerName)
func FindKernels(imageName string) (kernels collection) {
wwlog.Debug("FindKernels(%v)", imageName)
for _, pattern := range kernelSearchPaths {
kernels = append(kernels, FindKernelsFromPattern(containerName, pattern)...)
kernels = append(kernels, FindKernelsFromPattern(imageName, pattern)...)
}
return kernels
}
func FindAllKernels() (kernels collection) {
wwlog.Debug("FindAllKernels()")
if sources, err := container.ListSources(); err == nil {
if sources, err := image.ListSources(); err == nil {
for _, source := range sources {
kernels = append(kernels, FindKernels(source)...)
}
@@ -148,6 +148,6 @@ func (this *Kernel) IsRescue() bool {
}
func (this *Kernel) FullPath() string {
root := container.RootFsDir(this.ContainerName)
root := image.RootFsDir(this.ImageName)
return filepath.Join(root, this.Path)
}

View File

@@ -89,18 +89,18 @@ func Test_FindKernel(t *testing.T) {
t.Run(name, func(t *testing.T) {
env := testenv.New(t)
defer env.RemoveAll()
rootfs := "/var/lib/warewulf/chroots/testcontainer/rootfs"
rootfs := "/var/lib/warewulf/chroots/testimage/rootfs"
for _, file := range tt.files {
env.CreateFile(filepath.Join(rootfs, file))
}
kernels := FindKernels("testcontainer")
kernels := FindKernels("testimage")
assert.Equal(t, len(tt.files), len(kernels))
kernel := kernels.Default()
if tt.version == "" && tt.path == "" {
assert.Nil(t, kernel)
} else {
assert.Equal(t, "testcontainer", kernel.ContainerName)
assert.Equal(t, "testimage", kernel.ImageName)
assert.Equal(t, tt.version, kernel.Version())
assert.Equal(t, tt.path, kernel.Path)
assert.Equal(t, env.GetPath(filepath.Join(rootfs, tt.path)), kernel.FullPath())
@@ -152,18 +152,18 @@ func Test_FromNode(t *testing.T) {
t.Run(name, func(t *testing.T) {
env := testenv.New(t)
defer env.RemoveAll()
rootfs := "/var/lib/warewulf/chroots/testcontainer/rootfs"
rootfs := "/var/lib/warewulf/chroots/testimage/rootfs"
for _, file := range tt.files {
env.CreateFile(filepath.Join(rootfs, file))
}
node := node.EmptyNode()
node.ContainerName = "testcontainer"
node.ImageName = "testimage"
node.Kernel.Version = tt.version
kernel := FromNode(&node)
if tt.path == "" {
assert.Nil(t, kernel)
} else {
assert.Equal(t, "testcontainer", kernel.ContainerName)
assert.Equal(t, "testimage", kernel.ImageName)
assert.Equal(t, tt.path, kernel.Path)
}
})
@@ -175,14 +175,14 @@ func Test_FindAllKernels(t *testing.T) {
files map[string][]string
count int
}{
"two containers": {
"two images": {
files: map[string][]string{
"container1": []string{
"image1": []string{
"/boot/vmlinuz-5.14.0-427.18.1.el9_4.x86_64",
"/boot/vmlinuz-5.14.0-427.24.1.el9_4.x86_64",
"/boot/vmlinuz-4.14.0-427.18.1.el8_4.x86_64",
},
"container2": []string{
"image2": []string{
"/boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0",
"/boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64",
"/boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug",
@@ -201,8 +201,8 @@ func Test_FindAllKernels(t *testing.T) {
t.Run(name, func(t *testing.T) {
env := testenv.New(t)
defer env.RemoveAll()
for container, files := range tt.files {
rootfs := filepath.Join(filepath.Join("/var/lib/warewulf/chroots", container), "rootfs")
for image, files := range tt.files {
rootfs := filepath.Join(filepath.Join("/var/lib/warewulf/chroots", image), "rootfs")
for _, file := range files {
env.CreateFile(filepath.Join(rootfs, file))
}
@@ -237,7 +237,7 @@ func Test_IsDebugOrRescue(t *testing.T) {
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
kernel := &Kernel{ContainerName: "", Path: tt.path}
kernel := &Kernel{ImageName: "", Path: tt.path}
assert.Equal(t, tt.debug, kernel.IsDebug())
assert.Equal(t, tt.rescue, kernel.IsRescue())
})

View File

@@ -40,13 +40,13 @@ type Profile struct {
Profiles []string `yaml:"profiles,omitempty" lopt:"profile" sopt:"P" comment:"Set the node's profile members (comma separated)"`
Comment string `yaml:"comment,omitempty" lopt:"comment" comment:"Set arbitrary string comment"`
ClusterName string `yaml:"cluster name,omitempty" lopt:"cluster" sopt:"c" comment:"Set cluster group"`
ContainerName string `yaml:"container name,omitempty" lopt:"container" sopt:"C" comment:"Set container name"`
ImageName string `yaml:"image name,omitempty" lopt:"image" comment:"Set image name"`
Ipxe string `yaml:"ipxe template,omitempty" lopt:"ipxe" comment:"Set the iPXE template name"`
RuntimeOverlay []string `yaml:"runtime overlay,omitempty" lopt:"runtime" sopt:"R" comment:"Set the runtime overlay"`
SystemOverlay []string `yaml:"system overlay,omitempty" lopt:"wwinit" sopt:"O" comment:"Set the system overlay"`
Kernel *KernelConf `yaml:"kernel,omitempty"`
Ipmi *IpmiConf `yaml:"ipmi,omitempty"`
Init string `yaml:"init,omitempty" lopt:"init" sopt:"i" comment:"Define the init process to boot the container"`
Init string `yaml:"init,omitempty" lopt:"init" sopt:"i" comment:"Define the init process to boot the image"`
Root string `yaml:"root,omitempty" lopt:"root" comment:"Define the rootfs" `
NetDevs map[string]*NetDev `yaml:"network devices,omitempty"`
Tags map[string]string `yaml:"tags,omitempty"`

View File

@@ -114,7 +114,7 @@ func Test_listFields(t *testing.T) {
"Profiles",
"Comment",
"ClusterName",
"ContainerName",
"ImageName",
"Ipxe",
"RuntimeOverlay",
"SystemOverlay",
@@ -168,7 +168,7 @@ func Test_listFields(t *testing.T) {
"Profiles",
"Comment",
"ClusterName",
"ContainerName",
"ImageName",
"Ipxe",
"RuntimeOverlay",
"SystemOverlay",

View File

@@ -311,6 +311,16 @@ func (node *Profile) Id() string {
return node.id
}
// ContainerName returns the value of the ImageName field for backwards-compatibility.
func (node *Node) ContainerName() string {
return node.ImageName
}
// ContainerName returns the value of the ImageName field for backwards-compatibility.
func (profile *Profile) ContainerName() string {
return profile.ImageName
}
/*
Returns if the node is a valid in the database
*/

View File

@@ -6,7 +6,7 @@ import (
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
)
var defaultCachePath = filepath.Join(warewulfconf.Get().Paths.Datadir, "/container-cache/oci/")
var defaultCachePath = filepath.Join(warewulfconf.Get().Paths.Datadir, "/image-cache/oci/")
const (
blobPrefix = "blobs"

View File

@@ -39,8 +39,9 @@ type TemplateStruct struct {
AllNodes []node.Node
node.Node
// backward compatiblity
Container string
ThisNode *node.Node
Container string
ContainerName string
ThisNode *node.Node
}
/*
@@ -74,7 +75,8 @@ func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (T
// init some convenience vars
tstruct.Id = nodeData.Id()
tstruct.Hostname = nodeData.Id()
tstruct.Container = nodeData.ContainerName
tstruct.Container = nodeData.ImageName
tstruct.ContainerName = nodeData.ImageName
// Backwards compatibility for templates using "Keys"
tstruct.AllNodes = allNodes
dt := time.Now()

View File

@@ -10,7 +10,7 @@ import (
"strings"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/util"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
@@ -73,32 +73,32 @@ func templateFileBlock(inc string, abortStr string) (string, error) {
}
/*
Reads a file relative to given container.
Reads a file relative to given image.
Templates in the file are no evaluated.
*/
func templateContainerFileInclude(containername string, filepath string) string {
wwlog.Verbose("Including file from Container into template: %s:%s", containername, filepath)
func templateImageFileInclude(imagename string, filepath string) string {
wwlog.Verbose("Including file from Image into template: %s:%s", imagename, filepath)
if containername == "" {
wwlog.Warn("Container is not defined for node: %s", filepath)
if imagename == "" {
wwlog.Warn("Image is not defined for node: %s", filepath)
return ""
}
if !container.ValidSource(containername) {
wwlog.Warn("Template requires file(s) from non-existant container: %s:%s", containername, filepath)
if !image.ValidSource(imagename) {
wwlog.Warn("Template requires file(s) from non-existant image: %s:%s", imagename, filepath)
return ""
}
containerDir := container.RootFsDir(containername)
imageDir := image.RootFsDir(imagename)
wwlog.Debug("Including file from container: %s:%s", containerDir, filepath)
wwlog.Debug("Including file from image: %s:%s", imageDir, filepath)
if !util.IsFile(path.Join(containerDir, filepath)) {
wwlog.Warn("Requested file from container does not exist: %s:%s", containername, filepath)
if !util.IsFile(path.Join(imageDir, filepath)) {
wwlog.Warn("Requested file from image does not exist: %s:%s", imagename, filepath)
return ""
}
content, err := os.ReadFile(path.Join(containerDir, filepath))
content, err := os.ReadFile(path.Join(imageDir, filepath))
if err != nil {
wwlog.Error("Template include failed: %s", err)

View File

@@ -227,7 +227,7 @@ func FindOverlays() (overlayList []string, err error) {
}
/*
Build the given overlays for a node and create a Image for them
Build the given overlays for a node and create an image for them
*/
func BuildOverlay(nodeConf node.Node, allNodes []node.Node, context string, overlayNames []string) error {
if len(overlayNames) == 0 && context == "" {
@@ -469,7 +469,7 @@ func RenderTemplateFile(fileName string, data TemplateStruct) (
// Build our FuncMap
funcMap := template.FuncMap{
"Include": templateFileInclude,
"IncludeFrom": templateContainerFileInclude,
"IncludeFrom": templateImageFileInclude,
"IncludeBlock": templateFileBlock,
"ImportLink": importSoftlink,
"basename": path.Base,

View File

@@ -29,6 +29,7 @@ type WarewulfYaml struct {
TFTP *TFTPConf `yaml:"tftp"`
NFS *NFSConf `yaml:"nfs"`
SSH *SSHConf `yaml:"ssh"`
MountsImage []*MountEntry `yaml:"image mounts"`
MountsContainer []*MountEntry `yaml:"container mounts"`
Paths *BuildConfig `yaml:"paths"`
WWClient *WWClientConf `yaml:"wwclient"`
@@ -61,9 +62,14 @@ func (this *WarewulfYaml) Upgrade() (upgraded *config.WarewulfYaml) {
if this.SSH != nil {
upgraded.SSH = this.SSH.Upgrade()
}
upgraded.MountsContainer = make([]*config.MountEntry, 0)
for _, mount := range this.MountsContainer {
upgraded.MountsContainer = append(upgraded.MountsContainer, mount.Upgrade())
upgraded.MountsImage = make([]*config.MountEntry, 0)
for _, mount := range this.MountsImage {
upgraded.MountsImage = append(upgraded.MountsImage, mount.Upgrade())
}
if len(upgraded.MountsImage) == 0 {
for _, mount := range this.MountsContainer {
upgraded.MountsImage = append(upgraded.MountsImage, mount.Upgrade())
}
}
if this.Paths != nil {
upgraded.Paths = this.Paths.Upgrade()

View File

@@ -388,7 +388,7 @@ ssh:
- dsa
- ecdsa
- ed25519
container mounts:
image mounts:
- source: /etc/resolv.conf
dest: /etc/resolv.conf
readonly: true
@@ -482,7 +482,7 @@ ssh:
- dsa
- ecdsa
- ed25519
container mounts:
image mounts:
- source: /etc/resolv.conf
dest: /etc/resolv.conf
readonly: true

View File

@@ -154,7 +154,10 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
upgraded.AssetKey = this.AssetKey
upgraded.ClusterName = this.ClusterName
upgraded.Comment = this.Comment
upgraded.ContainerName = this.ContainerName
upgraded.ImageName = this.ImageName
if upgraded.ImageName == "" {
upgraded.ImageName = this.ContainerName
}
if this.Disabled != "" {
logIgnore("Disabled", this.Disabled, "obsolete")
}
@@ -206,14 +209,14 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
}
upgraded.Ipxe = this.Ipxe
if this.Kernel != nil {
upgraded.Kernel = this.Kernel.Upgrade(this.ContainerName)
upgraded.Kernel = this.Kernel.Upgrade(upgraded.ImageName)
} else {
inlineKernel := &KernelConf{
Args: this.KernelArgs,
Version: this.KernelVersion,
Override: this.KernelOverride,
}
upgraded.Kernel = inlineKernel.Upgrade(this.ContainerName)
upgraded.Kernel = inlineKernel.Upgrade(upgraded.ImageName)
}
if this.Keys != nil {
for key, value := range this.Keys {
@@ -298,6 +301,7 @@ type Profile struct {
AssetKey string `yaml:"asset key,omitempty"`
ClusterName string `yaml:"cluster name,omitempty"`
Comment string `yaml:"comment,omitempty"`
ImageName string `yaml:"image name,omitempty"`
ContainerName string `yaml:"container name,omitempty"`
Disabled string `yaml:"disabled,omitempty"`
Discoverable string `yaml:"discoverable,omitempty"`
@@ -342,7 +346,10 @@ func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *
}
upgraded.ClusterName = this.ClusterName
upgraded.Comment = this.Comment
upgraded.ContainerName = this.ContainerName
upgraded.ImageName = this.ImageName
if upgraded.ImageName == "" {
upgraded.ImageName = this.ContainerName
}
if this.Disabled != "" {
logIgnore("Disabled", this.Disabled, "obsolete")
}
@@ -395,14 +402,14 @@ func (this *Profile) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *
}
upgraded.Ipxe = this.Ipxe
if this.Kernel != nil {
upgraded.Kernel = this.Kernel.Upgrade(this.ContainerName)
upgraded.Kernel = this.Kernel.Upgrade(upgraded.ImageName)
} else {
inlineKernel := &KernelConf{
Args: this.KernelArgs,
Version: this.KernelVersion,
Override: this.KernelOverride,
}
upgraded.Kernel = inlineKernel.Upgrade(this.ContainerName)
upgraded.Kernel = inlineKernel.Upgrade(upgraded.ImageName)
}
if this.Keys != nil {
for key, value := range this.Keys {
@@ -525,29 +532,29 @@ type KernelConf struct {
Version string `yaml:"version,omitempty"`
}
func (this *KernelConf) Upgrade(containerName string) (upgraded *node.KernelConf) {
func (this *KernelConf) Upgrade(imageName string) (upgraded *node.KernelConf) {
upgraded = new(node.KernelConf)
upgraded.Args = this.Args
kernels := kernel.FindKernels(containerName)
wwlog.Debug("referencing kernels: %v (containerName: %v)", kernels, containerName)
kernels := kernel.FindKernels(imageName)
wwlog.Debug("referencing kernels: %v (imageName: %v)", kernels, imageName)
if this.Override != "" {
if version := util.ParseVersion(legacyKernelVersion(this.Override)); version != nil {
for _, kernel_ := range kernels {
wwlog.Debug("checking if kernel '%v' version '%v' from container '%v' matches override '%v'", kernel_, kernel_.Version(), containerName, this.Override)
wwlog.Debug("checking if kernel '%v' version '%v' from image '%v' matches override '%v'", kernel_, kernel_.Version(), imageName, this.Override)
if kernel_.Version() == version.String() {
upgraded.Version = kernel_.Path
wwlog.Info("kernel override %v -> version %v (container %v)", this.Override, upgraded.Version, containerName)
wwlog.Info("kernel override %v -> version %v (image %v)", this.Override, upgraded.Version, imageName)
}
}
} else if util.IsFile((&kernel.Kernel{ContainerName: containerName, Path: this.Override}).FullPath()) {
} else if util.IsFile((&kernel.Kernel{ImageName: imageName, Path: this.Override}).FullPath()) {
upgraded.Version = this.Override
}
if upgraded.Version == "" {
containerDisplay := "unknown"
if containerName != "" {
containerDisplay = containerName
imageDisplay := "unknown"
if imageName != "" {
imageDisplay = imageName
}
wwlog.Warn("unable to resolve kernel override %v (container %v)", this.Override, containerDisplay)
wwlog.Warn("unable to resolve kernel override %v (image %v)", this.Override, imageDisplay)
}
}
if upgraded.Version == "" {

View File

@@ -688,30 +688,30 @@ nodes:
addDefaults: false,
replaceOverlays: false,
files: map[string]string{
"/srv/warewulf/kernel/mykernel/version": "1.2.3",
"/var/lib/warewulf/chroots/mycontainer/rootfs/boot/vmlinuz-1.2.3": "",
"/srv/warewulf/kernel/mykernel/version": "1.2.3",
"/var/lib/warewulf/chroots/myimage/rootfs/boot/vmlinuz-1.2.3": "",
},
legacyYaml: `
nodeprofiles:
default:
container name: mycontainer
container name: myimage
kernel:
override: mykernel
nodes:
n1:
container name: mycontainer
container name: myimage
kernel:
override: mykernel
`,
upgradedYaml: `
nodeprofiles:
default:
container name: mycontainer
image name: myimage
kernel:
version: /boot/vmlinuz-1.2.3
nodes:
n1:
container name: mycontainer
image name: myimage
kernel:
version: /boot/vmlinuz-1.2.3
`,
@@ -721,30 +721,30 @@ nodes:
addDefaults: false,
replaceOverlays: false,
files: map[string]string{
"/srv/warewulf/kernel/mykernel/version": "1.2.3",
"/var/lib/warewulf/chroots/mycontainer/rootfs/boot/vmlinuz-1.2.3": "",
"/srv/warewulf/kernel/mykernel/version": "1.2.3",
"/var/lib/warewulf/chroots/myimage/rootfs/boot/vmlinuz-1.2.3": "",
},
legacyYaml: `
nodeprofiles:
default:
container name: mycontainer
container name: myimage
kernel:
override: /boot/vmlinuz-1.2.3
nodes:
n1:
container name: mycontainer
container name: myimage
kernel:
override: /boot/vmlinuz-1.2.3
`,
upgradedYaml: `
nodeprofiles:
default:
container name: mycontainer
image name: myimage
kernel:
version: /boot/vmlinuz-1.2.3
nodes:
n1:
container name: mycontainer
image name: myimage
kernel:
version: /boot/vmlinuz-1.2.3
`,

View File

@@ -8,7 +8,7 @@ import (
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/util"
)
@@ -20,7 +20,7 @@ to the tftp directory
func CopyShimGrub() (err error) {
conf := warewulfconf.Get()
wwlog.Debug("copy shim and grub binaries from host")
shimPath := container.ShimFind("")
shimPath := image.ShimFind("")
if shimPath == "" {
return fmt.Errorf("no shim found on the host os")
}
@@ -29,7 +29,7 @@ func CopyShimGrub() (err error) {
return err
}
_ = os.Chmod(path.Join(conf.TFTP.TftpRoot, "warewulf", "shim.efi"), 0o755)
grubPath := container.GrubFind("")
grubPath := image.GrubFind("")
if grubPath == "" {
return fmt.Errorf("no grub found on host os")
}

View File

@@ -63,8 +63,8 @@ func parseReq(req *http.Request) (parserInfo, error) {
ret.stage = "ipxe"
} else if stage == "kernel" {
ret.stage = "kernel"
} else if stage == "container" {
ret.stage = "container"
} else if stage == "image" {
ret.stage = "image"
} else if stage == "overlay-system" {
ret.stage = "system"
} else if stage == "overlay-runtime" {

View File

@@ -13,7 +13,7 @@ import (
"github.com/Masterminds/sprig/v3"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/container"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/kernel"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/overlay"
@@ -28,7 +28,7 @@ type templateVars struct {
Fqdn string
Id string
Cluster string
ContainerName string
ImageName string
Hwaddr string
Ipaddr string
Port string
@@ -106,7 +106,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
Port: strconv.Itoa(conf.Warewulf.Port),
Hostname: remoteNode.Id(),
Hwaddr: rinfo.hwaddr,
ContainerName: remoteNode.ContainerName,
ImageName: remoteNode.ImageName,
KernelArgs: remoteNode.Kernel.Args,
KernelVersion: remoteNode.Kernel.Version,
NetDevs: remoteNode.NetDevs,
@@ -122,11 +122,11 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
}
}
} else if rinfo.stage == "container" {
if remoteNode.ContainerName != "" {
stage_file = container.ImageFile(remoteNode.ContainerName)
} else if rinfo.stage == "image" {
if remoteNode.ImageName != "" {
stage_file = image.ImageFile(remoteNode.ImageName)
} else {
wwlog.Warn("No container set for node %s", remoteNode.Id())
wwlog.Warn("No image set for node %s", remoteNode.Id())
}
} else if rinfo.stage == "system" || rinfo.stage == "runtime" {
@@ -156,19 +156,19 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
}
} else if rinfo.stage == "efiboot" {
wwlog.Debug("requested method: %s", req.Method)
containerName := remoteNode.ContainerName
imageName := remoteNode.ImageName
switch rinfo.efifile {
case "shim.efi":
stage_file = container.ShimFind(containerName)
stage_file = image.ShimFind(imageName)
if stage_file == "" {
wwlog.Error("couldn't find shim.efi for %s", containerName)
wwlog.Error("couldn't find shim.efi for %s", imageName)
w.WriteHeader(http.StatusNotFound)
return
}
case "grub.efi", "grub-tpm.efi", "grubx64.efi", "grubia32.efi", "grubaa64.efi", "grubarm.efi":
stage_file = container.GrubFind(containerName)
stage_file = image.GrubFind(imageName)
if stage_file == "" {
wwlog.Error("could't find grub*.efi for %s", containerName)
wwlog.Error("could't find grub*.efi for %s", imageName)
w.WriteHeader(http.StatusNotFound)
return
}
@@ -188,13 +188,13 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
Port: strconv.Itoa(conf.Warewulf.Port),
Hostname: remoteNode.Id(),
Hwaddr: rinfo.hwaddr,
ContainerName: remoteNode.ContainerName,
ImageName: remoteNode.ImageName,
KernelArgs: kernelArgs,
KernelVersion: kernelVersion,
NetDevs: remoteNode.NetDevs,
Tags: remoteNode.Tags}
if stage_file == "" {
wwlog.Error("could't find grub.cfg template for %s", containerName)
wwlog.Error("could't find grub.cfg template for %s", imageName)
w.WriteHeader(http.StatusNotFound)
return
}
@@ -202,20 +202,20 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
wwlog.ErrorExc(fmt.Errorf("could't find efiboot file: %s", rinfo.efifile), "")
}
} else if rinfo.stage == "shim" {
if remoteNode.ContainerName != "" {
stage_file = container.ShimFind(remoteNode.ContainerName)
if remoteNode.ImageName != "" {
stage_file = image.ShimFind(remoteNode.ImageName)
if stage_file == "" {
wwlog.Error("No kernel found for container %s", remoteNode.ContainerName)
wwlog.Error("No kernel found for image %s", remoteNode.ImageName)
}
} else {
wwlog.Warn("No container set for this %s", remoteNode.Id())
wwlog.Warn("No image set for this %s", remoteNode.Id())
}
} else if rinfo.stage == "grub" {
if remoteNode.ContainerName != "" {
stage_file = container.GrubFind(remoteNode.ContainerName)
if remoteNode.ImageName != "" {
stage_file = image.GrubFind(remoteNode.ImageName)
if stage_file == "" {
wwlog.Error("No grub found for container %s", remoteNode.ContainerName)
wwlog.Error("No grub found for image %s", remoteNode.ImageName)
}
} else {
wwlog.Warn("No conainer set for node %s", remoteNode.Id())
@@ -223,10 +223,10 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
} else if rinfo.stage == "initramfs" {
if kernel_ := kernel.FromNode(&remoteNode); kernel_ != nil {
if kver := kernel_.Version(); kver != "" {
if initramfs := container.FindInitramfs(remoteNode.ContainerName, kver); initramfs != nil {
if initramfs := image.FindInitramfs(remoteNode.ImageName, kver); initramfs != nil {
stage_file = initramfs.FullPath()
} else {
wwlog.Error("No initramfs found for kernel %s in container %s", kver, remoteNode.ContainerName)
wwlog.Error("No initramfs found for kernel %s in image %s", kver, remoteNode.ImageName)
}
} else {
wwlog.Error("No initramfs found: unable to determine kernel version for node %s", remoteNode.Id())

View File

@@ -40,7 +40,7 @@ func Test_ProvisionSend(t *testing.T) {
env.WriteFile("etc/warewulf/nodes.conf", `nodeprofiles:
default:
container name: suse
image name: suse
nodes:
n1:
network devices:
@@ -52,7 +52,7 @@ nodes:
network devices:
default:
hwaddr: 00:00:00:00:ff:ff
container name: none
image name: none
tags:
GrubMenuEntry: dracut
n3:

View File

@@ -70,7 +70,7 @@ func RunServer() error {
wwHandler.HandleFunc("/ipxe/", ProvisionSend)
wwHandler.HandleFunc("/efiboot/", ProvisionSend)
wwHandler.HandleFunc("/kernel/", ProvisionSend)
wwHandler.HandleFunc("/container/", ProvisionSend)
wwHandler.HandleFunc("/image/", ProvisionSend)
wwHandler.HandleFunc("/overlay-system/", ProvisionSend)
wwHandler.HandleFunc("/overlay-runtime/", ProvisionSend)
wwHandler.HandleFunc("/status", StatusSend)