workspace

package
v0.16.17 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackupDir is the name of the folder where backup stack information is stored.
	BackupDir = "backups"
	// BookkeepingDir is the name of our bookeeping folder, we store state here (like .git for git).
	BookkeepingDir = ".pulumi"
	// ConfigDir is the name of the folder that holds local configuration information.
	ConfigDir = "config"
	// GitDir is the name of the folder git uses to store information.
	GitDir = ".git"
	// HistoryDir is the name of the directory that holds historical information for projects.
	HistoryDir = "history"
	// PluginDir is the name of the directory containing plugins.
	PluginDir = "plugins"
	// StackDir is the name of the directory that holds stack information for projects.
	StackDir = "stacks"
	// TemplateDir is the name of the directory containing templates.
	TemplateDir = "templates"
	// WorkspaceDir is the name of the directory that holds workspace information for projects.
	WorkspaceDir = "workspaces"

	// ProjectFile is the base name of a project file.
	ProjectFile = "Pulumi"
	// RepoFile is the name of the file that holds information specific to the entire repository.
	RepoFile = "settings.json"
	// WorkspaceFile is the name of the file that holds workspace information.
	WorkspaceFile = "workspace.json"
	// CachedVersionFile is the name of the file we use to store when we last checked if the CLI was out of date
	CachedVersionFile = ".cachedVersionInfo"
)
View Source
const PulumiCredentialsPathEnvVar = "PULUMI_CREDENTIALS_PATH"

PulumiCredentialsPathEnvVar is a path to the folder where credentials are stored. We use this in testing so that tests which log in and out do not impact the local developer's credentials or tests interacting with one another

Variables

This section is empty.

Functions

func DeleteAccessToken

func DeleteAccessToken(key string) error

DeleteAccessToken deletes an access token underneath the given key.

func DetectProjectPath

func DetectProjectPath() (string, error)

DetectProjectPath locates the closest project from the current working directory, or an error if not found.

func DetectProjectPathFrom

func DetectProjectPathFrom(path string) (string, error)

DetectProjectPathFrom locates the closest project from the given path, searching "upwards" in the directory hierarchy. If no project is found, an empty path is returned.

func DetectProjectStackPath

func DetectProjectStackPath(stackName tokens.QName) (string, error)

DetectProjectStackPath returns the name of the file to store stack specific project settings in. We place stack specific settings next to the Pulumi.yaml file, named like: Pulumi.<stack-name>.yaml

func GetAccessToken

func GetAccessToken(key string) (string, error)

GetAccessToken returns an access token underneath a given key.

func GetCachedVersionFilePath added in v0.15.0

func GetCachedVersionFilePath() (string, error)

GetCachedVersionFilePath returns the location where the CLI caches information from pulumi.com on the newest available version of the CLI

func GetCurrentCloudURL

func GetCurrentCloudURL() (string, error)

GetCurrentCloudURL returns the URL of the cloud we are currently connected to. This may be empty if we have not logged in.

func GetPluginDir

func GetPluginDir() (string, error)

GetPluginDir returns the directory in which plugins on the current machine are managed.

func GetPluginPath

func GetPluginPath(kind PluginKind, name string, version *semver.Version) (string, string, error)

GetPluginPath finds a plugin's path by its kind, name, and optional version. It will match the latest version that is >= the version specified. If no version is supplied, the latest plugin for that given kind/name pair is loaded, using standard semver sorting rules. A plugin may be overridden entirely by placing it on your $PATH.

func GetTemplateDir

func GetTemplateDir() (string, error)

GetTemplateDir returns the directory in which templates on the current machine are stored.

func HasPlugin

func HasPlugin(plug PluginInfo) bool

HasPlugin returns true if the given plugin exists.

func HasPluginGTE

func HasPluginGTE(plug PluginInfo) (bool, error)

HasPluginGTE returns true if the given plugin exists at the given version number or greater.

func IsPluginKind

func IsPluginKind(k string) bool

IsPluginKind returns true if k is a valid plugin kind, and false otherwise.

func IsTemplateURL added in v0.15.0

func IsTemplateURL(templateNameOrURL string) bool

IsTemplateURL returns true if templateNameOrURL starts with "https://".

func RetrieveTemplate added in v0.15.0

func RetrieveTemplate(rawurl string, path string) (string, error)

RetrieveTemplate downloads the repo to path and returns the full path on disk.

func SaveProject

func SaveProject(proj *Project) error

SaveProject saves the project file on top of the existing one, using the standard location.

func SaveProjectStack

func SaveProjectStack(stackName tokens.QName, stack *ProjectStack) error

func StoreAccessToken

func StoreAccessToken(key string, token string, current bool) error

StoreAccessToken saves the given access token underneath the given key.

func StoreCredentials

func StoreCredentials(creds Credentials) error

StoreCredentials updates the stored credentials on the machine, replacing the existing set. If the credentials are empty, the auth file will be deleted rather than just serializing an empty map.

func ValidateProjectDescription added in v0.16.12

func ValidateProjectDescription(s string) error

ValidateProjectDescription ensures a project description name is valid, if it is not it returns an error with a message suitable for display to an end user.

func ValidateProjectName added in v0.16.12

func ValidateProjectName(s string) error

ValidateProjectName ensures a project name is valid, if it is not it returns an error with a message suitable for display to an end user.

func ValidateStackName added in v0.16.12

func ValidateStackName(s string) error

ValidateStackName ensures a stack name is valid, if it is not it returns an error with a message suitable for display to an end user.

func ValueOrDefaultProjectDescription

func ValueOrDefaultProjectDescription(
	description string, projectDescription string, defaultDescription string) string

ValueOrDefaultProjectDescription returns the value or defaultDescription.

func ValueOrSanitizedDefaultProjectName

func ValueOrSanitizedDefaultProjectName(name string, projectName string, defaultNameToSanitize string) string

ValueOrSanitizedDefaultProjectName returns the value or a sanitized valid project name based on defaultNameToSanitize.

Types

type Analyzers

type Analyzers []tokens.QName

Analyzers is a list of analyzers to run on this project.

type Credentials

type Credentials struct {
	Current      string            `json:"current,omitempty"`      // the currently selected key.
	AccessTokens map[string]string `json:"accessTokens,omitempty"` // a map of arbitrary key strings to tokens.
}

Credentials hold the information necessary for authenticating Pulumi Cloud API requests. It contains a map from the cloud API URL to the associated access token.

func GetStoredCredentials

func GetStoredCredentials() (Credentials, error)

GetStoredCredentials returns any credentials stored on the local machine.

type PluginInfo

type PluginInfo struct {
	Name         string          // the simple name of the plugin.
	Path         string          // the path that a plugin was loaded from.
	Kind         PluginKind      // the kind of the plugin (language, resource, etc).
	Version      *semver.Version // the plugin's semantic version, if present.
	Size         int64           // the size of the plugin, in bytes.
	InstallTime  time.Time       // the time the plugin was installed.
	LastUsedTime time.Time       // the last time the plugin was used.
}

PluginInfo provides basic information about a plugin. Each plugin gets installed into a system-wide location, by default `~/.pulumi/plugins/<kind>-<name>-<version>/`. A plugin may contain multiple files, however the primary loadable executable must be named `pulumi-<kind>-<name>`.

func GetPlugins

func GetPlugins() ([]PluginInfo, error)

GetPlugins returns a list of installed plugins.

func (PluginInfo) Delete

func (info PluginInfo) Delete() error

Delete removes the plugin from the cache. It also deletes any supporting files in the cache, which includes any files that contain the same prefix as the plugin itself.

func (PluginInfo) Dir

func (info PluginInfo) Dir() string

Dir gets the expected plugin directory for this plugin.

func (PluginInfo) DirPath

func (info PluginInfo) DirPath() (string, error)

DirPath returns the directory where this plugin should be installed.

func (PluginInfo) File

func (info PluginInfo) File() string

File gets the expected filename for this plugin.

func (PluginInfo) FilePath

func (info PluginInfo) FilePath() (string, error)

FilePath returns the full path where this plugin's primary executable should be installed.

func (PluginInfo) FilePrefix

func (info PluginInfo) FilePrefix() string

FilePrefix gets the expected default file prefix for the plugin.

func (PluginInfo) FileSuffix

func (info PluginInfo) FileSuffix() string

FileSuffix returns the suffix for the plugin (if any).

func (PluginInfo) Install

func (info PluginInfo) Install(tarball io.ReadCloser) error

Install installs a plugin's tarball into the cache. It validates that plugin names are in the expected format.

func (*PluginInfo) SetFileMetadata

func (info *PluginInfo) SetFileMetadata(path string) error

SetFileMetadata adds extra metadata from the given file, representing this plugin's directory.

func (PluginInfo) String

func (info PluginInfo) String() string

type PluginKind

type PluginKind string

PluginKind represents a kind of a plugin that may be dynamically loaded and used by Pulumi.

const (
	// AnalyzerPlugin is a plugin that can be used as a resource analyzer.
	AnalyzerPlugin PluginKind = "analyzer"
	// LanguagePlugin is a plugin that can be used as a language host.
	LanguagePlugin PluginKind = "language"
	// ResourcePlugin is a plugin that can be used as a resource provider for custom CRUD operations.
	ResourcePlugin PluginKind = "resource"
)

type Project

type Project struct {
	// Name is a required fully qualified name.
	Name tokens.PackageName `json:"name" yaml:"name"`
	// Runtime is a required runtime that executes code.
	Runtime ProjectRuntimeInfo `json:"runtime" yaml:"runtime"`
	// Main is an optional override for the program's main entry-point location.
	Main string `json:"main,omitempty" yaml:"main,omitempty"`

	// Description is an optional informational description.
	Description *string `json:"description,omitempty" yaml:"description,omitempty"`
	// Author is an optional author that created this project.
	Author *string `json:"author,omitempty" yaml:"author,omitempty"`
	// Website is an optional website for additional info about this project.
	Website *string `json:"website,omitempty" yaml:"website,omitempty"`
	// License is the optional license governing this project's usage.
	License *string `json:"license,omitempty" yaml:"license,omitempty"`

	// Analyzers is an optional list of analyzers that are enabled for this project.
	Analyzers *Analyzers `json:"analyzers,omitempty" yaml:"analyzers,omitempty"`

	// Config indicates where to store the Pulumi.<stack-name>.yaml files, combined with the folder Pulumi.yaml is in.
	Config string `json:"config,omitempty" yaml:"config,omitempty"`

	// Template is an optional template manifest, if this project is a template.
	Template *ProjectTemplate `json:"template,omitempty" yaml:"template,omitempty"`
}

Project is a Pulumi project manifest.

We explicitly add yaml tags (instead of using the default behavior from https://github.com/ghodss/yaml which works in terms of the JSON tags) so we can directly marshall and unmarshall this struct using go-yaml an have the fields in the serialized object match the order they are defined in this struct.

TODO[pulumi/pulumi#423]: use DOM based marshalling so we can roundtrip the seralized structure perfectly.

func DetectProject

func DetectProject() (*Project, error)

DetectProject loads the closest project from the current working directory, or an error if not found.

func DetectProjectAndPath

func DetectProjectAndPath() (*Project, string, error)

DetectProjectAndPath loads the closest package from the current working directory, or an error if not found. It also returns the path where the package was found.

func LoadProject

func LoadProject(path string) (*Project, error)

LoadProject reads a project definition from a file.

func (*Project) Save

func (proj *Project) Save(path string) error

Save writes a project definition to a file.

func (*Project) TrustResourceDependencies added in v0.16.0

func (proj *Project) TrustResourceDependencies() bool

TrustResourceDependencies returns whether or not this project's runtime can be trusted to accurately report dependencies. All languages supported by Pulumi today do this correctly. This option remains useful when bringing up new Pulumi languages.

func (*Project) Validate

func (proj *Project) Validate() error

type ProjectRuntimeInfo added in v0.15.0

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

func NewProjectRuntimeInfo added in v0.15.0

func NewProjectRuntimeInfo(name string, options map[string]interface{}) ProjectRuntimeInfo

func (ProjectRuntimeInfo) MarshalJSON added in v0.15.0

func (info ProjectRuntimeInfo) MarshalJSON() ([]byte, error)

func (ProjectRuntimeInfo) MarshalYAML added in v0.15.0

func (info ProjectRuntimeInfo) MarshalYAML() (interface{}, error)

func (*ProjectRuntimeInfo) Name added in v0.15.0

func (info *ProjectRuntimeInfo) Name() string

func (*ProjectRuntimeInfo) Options added in v0.15.0

func (info *ProjectRuntimeInfo) Options() map[string]interface{}

func (*ProjectRuntimeInfo) UnmarshalJSON added in v0.15.0

func (info *ProjectRuntimeInfo) UnmarshalJSON(data []byte) error

func (*ProjectRuntimeInfo) UnmarshalYAML added in v0.15.0

func (info *ProjectRuntimeInfo) UnmarshalYAML(unmarshal func(interface{}) error) error

type ProjectStack

type ProjectStack struct {
	// EncryptionSalt is this stack's base64 encoded encryption salt.
	EncryptionSalt string `json:"encryptionsalt,omitempty" yaml:"encryptionsalt,omitempty"`
	// Config is an optional config bag.
	Config config.Map `json:"config,omitempty" yaml:"config,omitempty"`
}

ProjectStack holds stack specific information about a project.

func DetectProjectStack

func DetectProjectStack(stackName tokens.QName) (*ProjectStack, error)

func LoadProjectStack

func LoadProjectStack(path string) (*ProjectStack, error)

LoadProjectStack reads a stack definition from a file.

func (*ProjectStack) Save

func (ps *ProjectStack) Save(path string) error

Save writes a project definition to a file.

type ProjectTemplate added in v0.15.0

type ProjectTemplate struct {
	// Description is an optional description of the template.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Quickstart contains optional text to be displayed after template creation.
	Quickstart string `json:"quickstart,omitempty" yaml:"quickstart,omitempty"`
	// Config is an optional template config.
	Config map[string]ProjectTemplateConfigValue `json:"config,omitempty" yaml:"config,omitempty"`
}

ProjectTemplate is a Pulumi project template manifest.

type ProjectTemplateConfigValue added in v0.15.0

type ProjectTemplateConfigValue struct {
	// Description is an optional description for the config value.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Default is an optional default value for the config value.
	Default string `json:"default,omitempty" yaml:"default,omitempty"`
	// Secret may be set to true to indicate that the config value should be encrypted.
	Secret bool `json:"secret,omitempty" yaml:"secret,omitempty"`
}

ProjectTemplateConfigValue is a config value included in the project template manifest.

type Settings

type Settings struct {
	// Stack is an optional default stack to use.
	Stack string `json:"stack,omitempty" yaml:"env,omitempty"`
}

Settings defines workspace settings shared amongst many related projects.

func (*Settings) IsEmpty

func (s *Settings) IsEmpty() bool

IsEmpty returns true when the settings object is logically empty (no selected stack and nothing in the deprecated configuration bag).

type Template

type Template struct {
	Dir         string                                // The directory containing Pulumi.yaml.
	Name        string                                // The name of the template.
	Description string                                // Description of the template.
	Quickstart  string                                // Optional text to be displayed after template creation.
	Config      map[string]ProjectTemplateConfigValue // Optional template config.

	ProjectName        string // Name of the project.
	ProjectDescription string // Optional description of the project.
}

Template represents a project template.

func LoadTemplate added in v0.15.0

func LoadTemplate(path string) (Template, error)

LoadTemplate returns a template from a path.

func (Template) CopyTemplateFiles

func (template Template) CopyTemplateFiles(
	destDir string, force bool, projectName string, projectDescription string) error

CopyTemplateFiles does the actual copy operation to a destination directory.

func (Template) CopyTemplateFilesDryRun

func (template Template) CopyTemplateFilesDryRun(destDir string) error

CopyTemplateFilesDryRun does a dry run of copying a template to a destination directory, to ensure it won't overwrite any files.

type TemplateRepository added in v0.15.0

type TemplateRepository struct {
	Root         string // The full path to the root directory of the repository.
	SubDirectory string // The full path to the sub directory within the repository.
	ShouldDelete bool   // Whether the root directory should be deleted.
}

TemplateRepository represents a repository of templates.

func RetrieveTemplates added in v0.15.0

func RetrieveTemplates(templateNameOrURL string, offline bool) (TemplateRepository, error)

RetrieveTemplates retrieves a "template repository" based on the specified name or URL.

func (TemplateRepository) Delete added in v0.15.0

func (repo TemplateRepository) Delete() error

Delete deletes the template repository.

func (TemplateRepository) Templates added in v0.15.0

func (repo TemplateRepository) Templates() ([]Template, error)

Templates lists the templates in the repository.

type W

type W interface {
	Settings() *Settings // returns a mutable pointer to the optional workspace settings info.
	Save() error         // saves any modifications to the workspace.
}

W offers functionality for interacting with Pulumi workspaces.

func New

func New() (W, error)

New creates a new workspace using the current working directory.

func NewFrom

func NewFrom(dir string) (W, error)

NewFrom creates a new Pulumi workspace in the given directory. Requires a Pulumi.yaml file be present in the folder hierarchy between dir and the .pulumi folder.

Jump to

Keyboard shortcuts

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