github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/systemd/container.go (about)

     1  package systemd
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  
     7  	"github.com/projecteru2/core/engine/docker"
     8  	enginetypes "github.com/projecteru2/core/engine/types"
     9  )
    10  
    11  // VirtualizationCreate create a workload
    12  func (e *Engine) VirtualizationCreate(ctx context.Context, opts *enginetypes.VirtualizationCreateOptions) (*enginetypes.VirtualizationCreated, error) { //nolint
    13  	rArgs := &docker.RawArgs{StorageOpt: map[string]string{}}
    14  	if len(opts.RawArgs) > 0 {
    15  		if err := json.Unmarshal(opts.RawArgs, rArgs); err != nil {
    16  			return nil, err
    17  		}
    18  	}
    19  	rArgs.Runtime = e.config.Systemd.Runtime
    20  	b, err := json.Marshal(rArgs)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	opts.RawArgs = b
    25  	return e.API.VirtualizationCreate(ctx, opts)
    26  }