workdir

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequiredFiles list of required files in a directory to treat it as a working directory
	RequiredFiles = []string{".env", "docker-compose.yml"}

	// OptionalFiles list of optional files that could be deleted when pruning
	OptionalFiles = []string{"docker-compose.override.yml"}

	// ErrMalformed is the returned error when the workdir is wrong
	ErrMalformed = goerrors.NewKind("workdir %s is not valid")

	// ErrInitFailed is an error returned on workdir initialization for custom cases
	ErrInitFailed = goerrors.NewKind("initialization failed")
)

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides a way to interact with all the workdirs by exposing the following operations:

  • read/set/unset active workdir,
  • remove/validate a workdir,
  • list workdirs.

func NewHandler

func NewHandler() (*Handler, error)

NewHandler creates a handler that manages workdirs in the path returned by the `workdirsPath` function

func (*Handler) Active

func (h *Handler) Active() (*Workdir, error)

Active returns active working directory

func (*Handler) List

func (h *Handler) List() ([]*Workdir, error)

List returns array of working directories

func (*Handler) Remove

func (h *Handler) Remove(w *Workdir) error

Remove removes working directory by removing required and optional files, and recursively removes directories up to the workdirs root as long as they are empty

func (*Handler) SetActive

func (h *Handler) SetActive(w *Workdir) error

SetActive creates a symlink from the fixed active workdir path to the prodived workdir

func (*Handler) UnsetActive

func (h *Handler) UnsetActive() error

UnsetActive removes symlink for active workdir

func (*Handler) Validate

func (h *Handler) Validate(w *Workdir) error

Validate validates that the passed working directoy is valid It's path must be a directory (or a symlink) containing docker-compose.yml and .env files

type Type

type Type int

Type defines the type of the workdir

const (
	// None refers to a failure in identifying the type of the workdir
	None Type = iota
	// Local refers to a workdir that has been initialized for local repos
	Local
	// Orgs refers to a workdir that has been initialized for organizations
	Orgs
)

type Workdir

type Workdir struct {
	// Type is the type of working directory
	Type Type
	// Name is a human-friendly string to identify the workdir
	Name string
	// Path is the absolute path corresponding to the workdir
	Path string
}

Workdir represents a workdir associated with a local or an orgs initialization

func InitLocal

func InitLocal(reposdir string) (*Workdir, error)

InitLocal initializes the workdir for local path and returns the Workdir instance

func InitOrgs

func InitOrgs(orgs []string, token string, withForks bool) (*Workdir, error)

InitOrgs initializes the workdir for organizations and returns the Workdir instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL