Skip to content

Commit

Permalink
Add CreateContainer to the Runtime interface
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeHat committed Feb 20, 2022
1 parent 743ddbf commit d756a6b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ func (c *ContainerdRuntime) PullImageIfRequired(ctx context.Context, imagename s
return nil
}

func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.NodeConfig) (interface{}, error) {
// this is a no-op
return "", nil
}

func (c *ContainerdRuntime) CreateAndStartContainer(ctx context.Context, node *types.NodeConfig) (interface{}, error) {
ctx = namespaces.WithNamespace(ctx, containerdNamespace)

Expand Down
5 changes: 5 additions & 0 deletions runtime/ignite/ignite.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ func (c *IgniteRuntime) CreateAndStartContainer(ctx context.Context, node *types
return vmChans, utils.LinkContainerNS(node.NSPath, node.LongName)
}

func (*IgniteRuntime) CreateContainer(_ context.Context, _ *types.NodeConfig) (string, error) {
// this is a no-op
return "", nil
}

func (*IgniteRuntime) StartContainer(_ context.Context, _ string) error {
// this is a no-op
return nil
Expand Down
2 changes: 1 addition & 1 deletion runtime/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (r *PodmanRuntime) PullImageIfRequired(ctx context.Context, image string) e
return err
}

// CreateContainer creates a container but does not start it
// CreateContainer creates a container, but does not start it
func (r *PodmanRuntime) CreateContainer(ctx context.Context, cfg *types.NodeConfig) (string, error) {
sg, err := r.createContainerSpec(ctx, cfg)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type ContainerRuntime interface {
DeleteNet(context.Context) error
// Pull container image if not present
PullImageIfRequired(context.Context, string) error
// CreateContainer creates a container, but does not start it
CreateContainer(context.Context, *types.NodeConfig) (string, error)
// Create container returns an extra interface that can be used to receive signals
// about the container life-cycle after it was created, e.g. for post-deploy tasks
CreateAndStartContainer(context.Context, *types.NodeConfig) (interface{}, error)
Expand Down

0 comments on commit d756a6b

Please sign in to comment.