Documentation
¶
Index ¶
- Constants
- Variables
- func BuildHTTPTransport(r *types.RegistryConfig) (*http.Transport, error)
- func BytesString(s string) (string, error)
- func CPUString(s string, targetIsDocker bool) (string, error)
- func CreateOrUpdateSecret(ctx context.Context, cs *kubernetes.Clientset, ns, name string, ...) error
- func DelegateHandler(w http.ResponseWriter, r *http.Request, config *types.ServerConfig, ...)
- func GenerateDockerConfigJSON(r *types.RegistryConfig) ([]byte, error)
- func GetDockerConfig(ctx context.Context, imageRef string, registryConfig *types.RegistryConfig) (name.Reference, []remote.Option, error)
- func ImageExists(ctx context.Context, logger *types.Logger, imageRef string, ...) (bool, error)
- func KanikoJob(ctx context.Context, logger *types.Logger, cs *kubernetes.Clientset, ...) error
- func LookupContainerCommand(checkKubernetes bool) string
- func TrimLabelValue(input string) string
- type CommandCM
- func (c *CommandCM) BuildImage(ctx context.Context, imgName ImageName, sourceUrl, containerFile string, ...) error
- func (c *CommandCM) ExecTailN(ctx context.Context, command string, args []string, n int) ([]string, error)
- func (c *CommandCM) GetContainerLogs(ctx context.Context, name ContainerName, linesToShow int) (string, error)
- func (c *CommandCM) GetContainerState(ctx context.Context, name ContainerName, expectHash string) (string, bool, error)
- func (c *CommandCM) ImageExists(ctx context.Context, name ImageName) (bool, error)
- func (c *CommandCM) RemoveContainer(ctx context.Context, name ContainerName) error
- func (c *CommandCM) RemoveImage(ctx context.Context, name ImageName) error
- func (c *CommandCM) RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, ...) error
- func (c *CommandCM) StartContainer(ctx context.Context, name ContainerName) error
- func (c *CommandCM) StopContainer(ctx context.Context, name ContainerName) error
- func (k *CommandCM) SupportsInPlaceUpdate() bool
- func (c CommandCM) VolumeCreate(ctx context.Context, name VolumeName) error
- func (c CommandCM) VolumeExists(ctx context.Context, name VolumeName) bool
- type CommandOptions
- type Container
- type ContainerManager
- type ContainerName
- type DelegateRequest
- type DevContainerManager
- type ExistsResult
- type ImageName
- type KanikoBuild
- type KubernetesCM
- func (k *KubernetesCM) BuildImage(ctx context.Context, imgName ImageName, sourceUrl, containerFile string, ...) error
- func (k *KubernetesCM) GetContainerLogs(ctx context.Context, name ContainerName, linesToShow int) (string, error)
- func (k *KubernetesCM) GetContainerState(ctx context.Context, name ContainerName, expectHash string) (string, bool, error)
- func (k *KubernetesCM) ImageExists(ctx context.Context, name ImageName) (bool, error)
- func (k *KubernetesCM) RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, ...) error
- func (k *KubernetesCM) StartContainer(ctx context.Context, name ContainerName) error
- func (k *KubernetesCM) StopContainer(ctx context.Context, name ContainerName) error
- func (k *KubernetesCM) SupportsInPlaceUpdate() bool
- func (k *KubernetesCM) VolumeCreate(ctx context.Context, name VolumeName) error
- func (k *KubernetesCM) VolumeExists(ctx context.Context, name VolumeName) bool
- type KubernetesOptions
- type VolumeInfo
- type VolumeName
Constants ¶
const ( DOCKER_COMMAND = "docker" PODMAN_COMMAND = "podman" )
const IMAGE_NAME_PREFIX = "cli-"
const LABEL_PREFIX = "dev.openrun."
const (
OPENRUN_FIELD_MANAGER = "openrun"
)
const UNNAMED_VOLUME = "<UNNAMED>"
const VERSION_HASH_LABEL = LABEL_PREFIX + "version.hash"
Variables ¶
var (
KNOWN_OPTIONS = []string{"cpus", "memory", "min_replicas", "max_replicas"}
)
Functions ¶
func BuildHTTPTransport ¶
func BuildHTTPTransport(r *types.RegistryConfig) (*http.Transport, error)
func BytesString ¶ added in v0.16.0
BytesString parses s and returns bytes as a base-10 integer string.
Rules: 1) If already an integer string (bytes), return as-is. 2) If docker-like (e.g., 512m, 1g), parse via Docker and return bytes. 3) Otherwise parse as k8s Quantity (e.g., 512Mi, 1Gi, 500M) and return bytes.
func CPUString ¶ added in v0.16.0
CPUString converts CPU from either docker-like ("0.5", "2") or k8s-like ("500m", "1") into a string that "makes sense" for the target.
- targetIsDocker=true => return cores as decimal string (e.g. "0.5", "2")
- targetIsDocker=false => return millicores as integer string (e.g. "500", "2000")
Notes:
- Bare "1" is treated as 1 core (not 1 millicore).
- For millicores input, use "m" suffix: "500m".
func CreateOrUpdateSecret ¶
func CreateOrUpdateSecret(ctx context.Context, cs *kubernetes.Clientset, ns, name string, data map[string][]byte, typ corev1.SecretType) error
func DelegateHandler ¶
func DelegateHandler(w http.ResponseWriter, r *http.Request, config *types.ServerConfig, logger *types.Logger)
DelegateHandler is the handler for the delegated build API
func GenerateDockerConfigJSON ¶
func GenerateDockerConfigJSON(r *types.RegistryConfig) ([]byte, error)
func GetDockerConfig ¶
func ImageExists ¶
func KanikoJob ¶
func KanikoJob(ctx context.Context, logger *types.Logger, cs *kubernetes.Clientset, cfg *rest.Config, r *types.RegistryConfig, dockerCfgJSON []byte, kb KanikoBuild) error
func LookupContainerCommand ¶
func TrimLabelValue ¶ added in v0.16.0
TrimLabelValue trims the input string to 63 characters so that it can be used as a Kubernetes label value
Types ¶
type CommandCM ¶ added in v0.16.0
func NewCommandCM ¶ added in v0.16.0
func (*CommandCM) BuildImage ¶ added in v0.16.0
func (*CommandCM) ExecTailN ¶ added in v0.16.0
func (c *CommandCM) ExecTailN(ctx context.Context, command string, args []string, n int) ([]string, error)
ExecTailN executes a command and returns the last n lines of output
func (*CommandCM) GetContainerLogs ¶ added in v0.16.0
func (*CommandCM) GetContainerState ¶ added in v0.16.0
func (c *CommandCM) GetContainerState(ctx context.Context, name ContainerName, expectHash string) (string, bool, error)
GetContainerState returns the host:port of the running container, "" if not running. running is true if the container is running.
func (*CommandCM) ImageExists ¶ added in v0.16.0
func (*CommandCM) RemoveContainer ¶ added in v0.16.0
func (c *CommandCM) RemoveContainer(ctx context.Context, name ContainerName) error
func (*CommandCM) RemoveImage ¶ added in v0.16.0
func (*CommandCM) RunContainer ¶ added in v0.16.0
func (*CommandCM) StartContainer ¶ added in v0.16.0
func (c *CommandCM) StartContainer(ctx context.Context, name ContainerName) error
func (*CommandCM) StopContainer ¶ added in v0.16.0
func (c *CommandCM) StopContainer(ctx context.Context, name ContainerName) error
func (*CommandCM) SupportsInPlaceUpdate ¶ added in v0.16.0
func (CommandCM) VolumeCreate ¶ added in v0.16.0
func (c CommandCM) VolumeCreate(ctx context.Context, name VolumeName) error
func (CommandCM) VolumeExists ¶ added in v0.16.0
func (c CommandCM) VolumeExists(ctx context.Context, name VolumeName) bool
type CommandOptions ¶ added in v0.16.0
type ContainerManager ¶
type ContainerManager interface {
BuildImage(ctx context.Context, name ImageName, sourceUrl, containerFile string, containerArgs map[string]string) error
ImageExists(ctx context.Context, name ImageName) (bool, error)
GetContainerState(ctx context.Context, name ContainerName, expectHash string) (hostPort string, running bool, err error)
StartContainer(ctx context.Context, name ContainerName) error
StopContainer(ctx context.Context, name ContainerName) error
RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, containerName ContainerName,
imageName ImageName, port int64, envMap map[string]string, volumes []*VolumeInfo,
containerOptions map[string]string, paramMap map[string]string, versionHash string) error
GetContainerLogs(ctx context.Context, name ContainerName, linesToShow int) (string, error)
VolumeExists(ctx context.Context, name VolumeName) bool
VolumeCreate(ctx context.Context, name VolumeName) error
SupportsInPlaceUpdate() bool
}
ContainerManager is the interface for managing containers
type ContainerName ¶
type ContainerName string
func GenContainerName ¶
func GenContainerName(appId types.AppId, cm ContainerManager, contentHash string, supportsInPlaceUpdate bool) ContainerName
type DelegateRequest ¶
type DevContainerManager ¶
type DevContainerManager interface {
ContainerManager
RemoveImage(ctx context.Context, name ImageName) error
RemoveContainer(ctx context.Context, name ContainerName) error
}
DevContainerManager is the interface for managing containers in dev mode
type ExistsResult ¶
func CheckImagesExists ¶
func CheckImagesExists(ctx context.Context, logger *types.Logger, imageRef string, registryConfig *types.RegistryConfig) (ExistsResult, error)
type KanikoBuild ¶
type KubernetesCM ¶ added in v0.16.0
func NewKubernetesCM ¶ added in v0.16.0
func (*KubernetesCM) BuildImage ¶ added in v0.16.0
func (*KubernetesCM) GetContainerLogs ¶ added in v0.16.0
func (k *KubernetesCM) GetContainerLogs(ctx context.Context, name ContainerName, linesToShow int) (string, error)
func (*KubernetesCM) GetContainerState ¶ added in v0.16.0
func (k *KubernetesCM) GetContainerState(ctx context.Context, name ContainerName, expectHash string) (string, bool, error)
func (*KubernetesCM) ImageExists ¶ added in v0.16.0
func (*KubernetesCM) RunContainer ¶ added in v0.16.0
func (k *KubernetesCM) RunContainer(ctx context.Context, appEntry *types.AppEntry, sourceDir string, containerName ContainerName, imageName ImageName, port int64, envMap map[string]string, volumes []*VolumeInfo, containerOptions map[string]string, paramMap map[string]string, versionHash string) error
func (*KubernetesCM) StartContainer ¶ added in v0.16.0
func (k *KubernetesCM) StartContainer(ctx context.Context, name ContainerName) error
func (*KubernetesCM) StopContainer ¶ added in v0.16.0
func (k *KubernetesCM) StopContainer(ctx context.Context, name ContainerName) error
func (*KubernetesCM) SupportsInPlaceUpdate ¶ added in v0.16.0
func (k *KubernetesCM) SupportsInPlaceUpdate() bool
func (*KubernetesCM) VolumeCreate ¶ added in v0.16.0
func (k *KubernetesCM) VolumeCreate(ctx context.Context, name VolumeName) error
func (*KubernetesCM) VolumeExists ¶ added in v0.16.0
func (k *KubernetesCM) VolumeExists(ctx context.Context, name VolumeName) bool
type KubernetesOptions ¶ added in v0.16.0
type KubernetesOptions struct {
Cpus string `mapstructure:"cpus"`
Memory string `mapstructure:"memory"`
MinReplicas int32 `mapstructure:"min_replicas"` // min number of replicas to run the app on
MaxReplicas int32 `mapstructure:"max_replicas"` // max number of replicas to run the app on
Other map[string]any `mapstructure:",remain"`
}
type VolumeInfo ¶
type VolumeName ¶
type VolumeName string
func GenVolumeName ¶
func GenVolumeName(appId types.AppId, dirName string) VolumeName