Documentation ¶
Overview ¶
Package workspace contains functionality to manage a user's local workspace. This includes creating an application directory, reading and writing a summary file to associate the workspace with the application, and managing infrastructure-as-code files. The typical workspace will be structured like:
. ├── copilot (application directory) │ ├── .workspace (workspace summary) │ ├── my-service │ │ └── manifest.yml (service manifest) | | environments | | └── test │ │ └── manifest.yml (environment manifest for the environment test) │ ├── buildspec.yml (legacy buildspec for the pipeline's build stage) │ ├── pipeline.yml (legacy pipeline manifest) │ ├── pipelines │ │ ├── pipeline-app-beta │ │ │ ├── buildspec.yml (buildspec for the pipeline 'pipeline-app-beta') │ ┴ ┴ └── manifest.yml (pipeline manifest for the pipeline 'pipeline-app-beta') └── my-service-src (customer service code)
Index ¶
- Constants
- Variables
- func IsInGitRepository(fs FileStat) bool
- type EnvironmentManifest
- type ErrFileExists
- type ErrFileNotExists
- type ErrWorkspaceNotFound
- type FileStat
- type PipelineManifest
- type Summary
- type WorkloadManifest
- type Workspace
- func (ws *Workspace) Create(appName string) error
- func (ws *Workspace) DeleteWorkspaceFile() error
- func (ws *Workspace) ListDockerfiles() ([]string, error)
- func (ws *Workspace) ListEnvironments() ([]string, error)
- func (ws *Workspace) ListJobs() ([]string, error)
- func (ws *Workspace) ListPipelines() ([]PipelineManifest, error)
- func (ws *Workspace) ListServices() ([]string, error)
- func (ws *Workspace) ListWorkloads() ([]string, error)
- func (ws *Workspace) Path() (string, error)
- func (ws *Workspace) ReadAddon(svc, fname string) ([]byte, error)
- func (ws *Workspace) ReadAddonsDir(svcName string) ([]string, error)
- func (ws *Workspace) ReadEnvironmentManifest(mftDirName string) (EnvironmentManifest, error)
- func (ws *Workspace) ReadPipelineManifest(path string) (*manifest.Pipeline, error)
- func (ws *Workspace) ReadWorkloadManifest(mftDirName string) (WorkloadManifest, error)
- func (ws *Workspace) Rel(path string) (string, error)
- func (ws *Workspace) Summary() (*Summary, error)
- func (ws *Workspace) WriteAddon(content encoding.BinaryMarshaler, svc, name string) (string, error)
- func (ws *Workspace) WriteEnvironmentManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
- func (ws *Workspace) WriteJobManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
- func (ws *Workspace) WritePipelineBuildspec(marshaler encoding.BinaryMarshaler, name string) (string, error)
- func (ws *Workspace) WritePipelineManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
- func (ws *Workspace) WriteServiceManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
Constants ¶
const ( // CopilotDirName is the name of the directory where generated infrastructure code for an application will be stored. CopilotDirName = "copilot" // SummaryFileName is the name of the file that is associated with the application. SummaryFileName = ".workspace" )
Variables ¶
var ErrNoPipelineInWorkspace = errors.New("no pipeline manifest found in the workspace")
ErrNoPipelineInWorkspace means there was no pipeline manifest in the workspace dir.
Functions ¶
func IsInGitRepository ¶ added in v0.3.0
IsInGitRepository returns true if the current working directory is a git repository.
Types ¶
type EnvironmentManifest ¶ added in v1.19.0
type EnvironmentManifest []byte
EnvironmentManifest represents raw local environment manifest.
type ErrFileExists ¶
type ErrFileExists struct {
FileName string
}
ErrFileExists means we tried to create an existing file.
func (*ErrFileExists) Error ¶
func (e *ErrFileExists) Error() string
type ErrFileNotExists ¶ added in v1.13.0
type ErrFileNotExists struct {
FileName string
}
ErrFileNotExists means we tried to read a non-existing file.
func (*ErrFileNotExists) Error ¶ added in v1.13.0
func (e *ErrFileNotExists) Error() string
type ErrWorkspaceNotFound ¶ added in v1.13.0
type ErrWorkspaceNotFound struct { CurrentDirectory string ManifestDirectoryName string NumberOfLevelsChecked int }
ErrWorkspaceNotFound means we couldn't locate a workspace root.
func (*ErrWorkspaceNotFound) Error ¶ added in v1.13.0
func (e *ErrWorkspaceNotFound) Error() string
type PipelineManifest ¶ added in v1.16.0
type PipelineManifest struct { Name string // Name of the pipeline inside the manifest file. Path string // Absolute path to the manifest file for the pipeline. }
PipelineManifest holds identifying information about a pipeline manifest file.
type Summary ¶
type Summary struct { Application string `yaml:"application"` // Name of the application. Path string // absolute path to the summary file. }
Summary is a description of what's associated with this workspace.
type WorkloadManifest ¶ added in v1.13.0
type WorkloadManifest []byte
WorkloadManifest represents raw local workload manifest.
func (WorkloadManifest) WorkloadType ¶ added in v1.13.0
func (w WorkloadManifest) WorkloadType() (string, error)
WorkloadType returns the workload type of the manifest.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace typically represents a Git repository where the user has its infrastructure-as-code files as well as source files.
func (*Workspace) Create ¶
Create creates the copilot directory (if it doesn't already exist) in the current working directory, and saves a summary with the application name.
func (*Workspace) DeleteWorkspaceFile ¶
DeleteWorkspaceFile removes the .workspace file under copilot/ directory. This will be called during app delete, we do not want to delete any other generated files.
func (*Workspace) ListDockerfiles ¶ added in v0.5.0
ListDockerfiles returns the list of Dockerfiles within the current working directory and a sub-directory level below. If an error occurs while reading directories, or no Dockerfiles found returns the error.
func (*Workspace) ListEnvironments ¶ added in v1.19.0
ListEnvironments returns the name of the environments in the workspace.
func (*Workspace) ListJobs ¶ added in v1.13.0
ListJobs returns the names of all jobs in the workspace.
func (*Workspace) ListPipelines ¶ added in v1.16.0
func (ws *Workspace) ListPipelines() ([]PipelineManifest, error)
ListPipelines returns all pipelines in the workspace.
func (*Workspace) ListServices ¶ added in v1.13.0
ListServices returns the names of the services in the workspace.
func (*Workspace) ListWorkloads ¶ added in v1.13.0
ListWorkloads returns the name of all the workloads in the workspace (could be unregistered in SSM).
func (*Workspace) ReadAddon ¶
ReadAddon returns the contents of a file under the service's "addons/" directory.
func (*Workspace) ReadAddonsDir ¶
ReadAddonsDir returns a list of file names under a service's "addons/" directory.
func (*Workspace) ReadEnvironmentManifest ¶ added in v1.19.0
func (ws *Workspace) ReadEnvironmentManifest(mftDirName string) (EnvironmentManifest, error)
ReadEnvironmentManifest returns the contents of the environment's manifest under copilot/environments/{name}/manifest.yml.
func (*Workspace) ReadPipelineManifest ¶
ReadPipelineManifest returns the contents of the pipeline manifest under the given path.
func (*Workspace) ReadWorkloadManifest ¶ added in v0.4.0
func (ws *Workspace) ReadWorkloadManifest(mftDirName string) (WorkloadManifest, error)
ReadWorkloadManifest returns the contents of the workload's manifest under copilot/{name}/manifest.yml.
func (*Workspace) Summary ¶
Summary returns a summary of the workspace - including the application name.
func (*Workspace) WriteAddon ¶
WriteAddon writes the content of an addon file under "{svc}/addons/{name}.yml". If successful returns the full path of the file, otherwise an empty string and an error.
func (*Workspace) WriteEnvironmentManifest ¶ added in v1.20.0
func (ws *Workspace) WriteEnvironmentManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
WriteEnvironmentManifest writes the environment manifest under the copilot/environments/{name}/ directory. If successful returns the full path of the file, otherwise returns an empty string and the error.
func (*Workspace) WriteJobManifest ¶ added in v0.5.0
func (ws *Workspace) WriteJobManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
WriteJobManifest writes the job's manifest under the copilot/{name}/ directory.
func (*Workspace) WritePipelineBuildspec ¶
func (ws *Workspace) WritePipelineBuildspec(marshaler encoding.BinaryMarshaler, name string) (string, error)
WritePipelineBuildspec writes the pipeline buildspec under the copilot/pipelines/{name}/ directory. If successful returns the full path of the file, otherwise returns an empty string and the error.
func (*Workspace) WritePipelineManifest ¶
func (ws *Workspace) WritePipelineManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
WritePipelineManifest writes the pipeline manifest under the copilot/pipelines/{name}/ directory. If successful returns the full path of the file, otherwise returns an empty string and the error.
func (*Workspace) WriteServiceManifest ¶
func (ws *Workspace) WriteServiceManifest(marshaler encoding.BinaryMarshaler, name string) (string, error)
WriteServiceManifest writes the service's manifest under the copilot/{name}/ directory.