Skip to content

Commit

Permalink
less files
Browse files Browse the repository at this point in the history
  • Loading branch information
frantjc committed Feb 5, 2025
1 parent b43997f commit c6118a6
Show file tree
Hide file tree
Showing 20 changed files with 593 additions and 695 deletions.
20 changes: 0 additions & 20 deletions container.go

This file was deleted.

13 changes: 0 additions & 13 deletions container_config.go

This file was deleted.

58 changes: 57 additions & 1 deletion container_runtime.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
package forge

import "context"
import (
"context"
"io"

xslice "github.com/frantjc/x/slice"
"github.com/opencontainers/go-digest"
imagespecsv1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type Mount struct {
Source string `json:"source,omitempty"`
Destination string `json:"destination,omitempty"`
}

func overrideMounts(oldMounts []Mount, newMounts ...Mount) []Mount {
return append(xslice.Filter(oldMounts, func(m Mount, _ int) bool {
return !xslice.Some(newMounts, func(n Mount, _ int) bool {
return m.Destination == n.Destination
})
}), newMounts...)
}

// ContainerConfig is the configuration that is used to
// create a container or an exec in a running container.
type ContainerConfig struct {
Entrypoint []string
Cmd []string
WorkingDir string
Env []string
User string
Privileged bool
Mounts []Mount
}

// Container represents a container created by a ContainerRuntime.
type Container interface {
GetID() string
CopyTo(context.Context, string, io.Reader) error
CopyFrom(context.Context, string) (io.ReadCloser, error)
Run(context.Context, *Streams) (int, error)
Start(context.Context) error
Restart(context.Context) error
Exec(context.Context, *ContainerConfig, *Streams) (int, error)
Stop(context.Context) error
Remove(context.Context) error
Kill(context.Context) error
}

// Image represents a image pulled by a ContainerRuntime.
// Used to create Containers from.
type Image interface {
Manifest() (*imagespecsv1.Manifest, error)
Config() (*imagespecsv1.ImageConfig, error)
Digest() (digest.Digest, error)
Blob() io.Reader
Name() string
}

// ContainerRuntime represents the functionality needed by Runnables
// to pull OCI images and run containers when being processed.
Expand Down
17 changes: 0 additions & 17 deletions image.go → image_refs.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
package forge

import (
"io"

"github.com/opencontainers/go-digest"
imagespecsv1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// Image represents a image pulled by a ContainerRuntime.
// Used to create Containers from.
type Image interface {
Manifest() (*imagespecsv1.Manifest, error)
Config() (*imagespecsv1.ImageConfig, error)
Digest() (digest.Digest, error)
Blob() io.Reader
Name() string
}

const (
DefaultNode10ImageReference = "docker.io/library/node:10"
DefaultNode12ImageReference = "docker.io/library/node:12"
Expand Down
18 changes: 0 additions & 18 deletions mount.go

This file was deleted.

78 changes: 0 additions & 78 deletions runtime/docker/build_image.go

This file was deleted.

Loading

0 comments on commit c6118a6

Please sign in to comment.