Documentation
¶
Index ¶
- func CheckExpectedResources(filenames map[string]string, revisions map[string]int, ...) error
- func DeployResources(ctx context.Context, args DeployResourcesArgs) (ids map[string]string, err error)
- func FormatAppTabular(writer io.Writer, value interface{}) error
- func FormatCharmTabular(writer io.Writer, value interface{}) error
- func NewCharmResourcesCommand() modelcmd.ModelCommand
- func NewCharmResourcesCommandWithClient(client ResourceLister) modelcmd.ModelCommand
- func NewListCommand() modelcmd.ModelCommand
- func NewUploadCommand() modelcmd.ModelCommand
- func OpenResource(resValue string, resType charmresource.Type, osOpen osOpenFunc) (modelcmd.ReadSeekCloser, error)
- func ValidateResourceDetails(res map[string]string, resMeta map[string]charmresource.Meta, ...) error
- func ValidateResources(resources map[string]charmresource.Meta) error
- type APIRoot
- type CharmID
- type CharmResourceLister
- type CharmResourcesCommand
- type CharmhubResourceLister
- type CreateResourceListener
- type DeployClient
- type DeployResourcesArgs
- type FormattedAppResource
- type FormattedApplicationDetails
- type FormattedApplicationInfo
- type FormattedCharmResource
- type FormattedDetailResource
- type FormattedUnitDetails
- type ListClient
- type ListCommand
- type ResourceLister
- type ResourceListerDependencies
- type UploadClient
- type UploadCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckExpectedResources ¶
func CheckExpectedResources(filenames map[string]string, revisions map[string]int, resMeta map[string]charmresource.Meta) error
CheckExpectedResources compares the resources we expect to see (metadata) against what we see in the actual deployment arguments (the filenames and revisions), and identifies the resources that we weren't expecting. Note that this is different from checking if we see all the resources we expect to see, as the user can attach-resource post deploy.
func DeployResources ¶
func DeployResources(ctx context.Context, args DeployResourcesArgs) (ids map[string]string, err error)
DeployResources uploads the bytes for the given files to the server and creates pending resource metadata for the all resource mentioned in the metadata. It returns a map of resource name to pending resource IDs.
func FormatAppTabular ¶
FormatAppTabular returns a tabular summary of resources.
func FormatCharmTabular ¶
FormatCharmTabular returns a tabular summary of charm resources.
func NewCharmResourcesCommand ¶
func NewCharmResourcesCommand() modelcmd.ModelCommand
NewCharmResourcesCommand returns a new command that lists resources defined by a charm.
func NewCharmResourcesCommandWithClient ¶
func NewCharmResourcesCommandWithClient(client ResourceLister) modelcmd.ModelCommand
NewCharmResourcesCommandWithClient returns a new command that lists resources defined by a charm.
func NewListCommand ¶
func NewListCommand() modelcmd.ModelCommand
NewListCommand returns a new command that lists resources defined by a charm.
func NewUploadCommand ¶
func NewUploadCommand() modelcmd.ModelCommand
NewUploadCommand returns a new command that lists resources defined by a charm.
func OpenResource ¶
func OpenResource(resValue string, resType charmresource.Type, osOpen osOpenFunc) (modelcmd.ReadSeekCloser, error)
OpenResource returns a readable buffer for the given resource, which can be a local file or a docker image
func ValidateResourceDetails ¶
func ValidateResourceDetails(res map[string]string, resMeta map[string]charmresource.Meta, fs modelcmd.Filesystem) error
ValidateResourceDetails validates the resource path in detail depending on if it's a local file or a container image, either checks with the FS and stats the file or validate the docker registry path and makes sure the registry URL resolves into a fully qualified reference.
func ValidateResources ¶
func ValidateResources(resources map[string]charmresource.Meta) error
ValidateResources runs the validation checks for resource metadata for each resource. Errors are consolidated and reported in a single error.
Types ¶
type APIRoot ¶
type APIRoot = func(ctx context.Context) (api.Connection, error)
APIRoot defines a way to create a new API root.
type CharmID ¶
type CharmID struct { // URL is the url of the charm. URL *charm.URL // Channel is the channel in which the charm was published. Channel charm.Channel }
CharmID represents the charm identifier.
type CharmResourceLister ¶
type CharmResourceLister interface {
ListCharmResources(ctx context.Context, curl string, origin apicharm.Origin) ([]charmresource.Resource, error)
}
CharmResourceLister lists the resource of a charm.
type CharmResourcesCommand ¶
type CharmResourcesCommand struct {
// contains filtered or unexported fields
}
CharmResourcesCommand implements the "juju charm-resources" command.
func (*CharmResourcesCommand) Info ¶
func (c *CharmResourcesCommand) Info() *cmd.Info
Info implements cmd.Command.
func (*CharmResourcesCommand) Init ¶
func (c *CharmResourcesCommand) Init(args []string) error
Init implements cmd.Command.
func (*CharmResourcesCommand) Run ¶
func (c *CharmResourcesCommand) Run(ctx *cmd.Context) error
Run implements cmd.Command.
func (*CharmResourcesCommand) SetFlags ¶
func (c *CharmResourcesCommand) SetFlags(f *gnuflag.FlagSet)
SetFlags implements cmd.Command.
type CharmhubResourceLister ¶
type CharmhubResourceLister struct {
APIRootFn APIRoot
}
CharmhubResourceLister defines a charm hub resource lister.
func (*CharmhubResourceLister) ListResources ¶
func (c *CharmhubResourceLister) ListResources(ctx context.Context, ids []CharmID) ([][]charmresource.Resource, error)
ListResources implements CharmResourceLister.
type CreateResourceListener ¶
type CreateResourceListener = func(context.Context, string, ResourceListerDependencies) (ResourceLister, error)
CreateResourceListener defines a factory function to create a resource lister.
type DeployClient ¶
type DeployClient interface { // AddPendingResources adds pending metadata for store based resources // and returns the new resource id. AddPendingResources( ctx context.Context, applicationID string, chID apiresources.CharmID, resources []charmresource.Resource, ) (ids []string, err error) // UploadPendingResource sends the provided resource blob up to Juju // returns the new resource id. UploadPendingResource( ctx context.Context, args apiresources.UploadPendingResourceArgs, ) (pendingID string, err error) }
DeployClient exposes the functionality of the resources API needed for deploy.
type DeployResourcesArgs ¶
type DeployResourcesArgs struct { // ApplicationID identifies the application being deployed. ApplicationID string // CharmID identifies the application's charm. CharmID apiresources.CharmID // ResourceValues is the set of resources for which a value // was provided at the command-line. ResourceValues map[string]string // Revisions is the set of resources for which a revision // was provided at the command-line. Revisions map[string]int // ResourcesMeta holds the charm metadata for each of the resources // that should be added/updated on the controller. ResourcesMeta map[string]charmresource.Meta // Client is the resources API client to use during deploy. Client DeployClient // Filesystem provides access to the filesystem. Filesystem modelcmd.Filesystem }
DeployResourcesArgs holds the arguments to DeployResources().
type FormattedAppResource ¶
type FormattedAppResource struct { // These fields are exported for the sake of serialization. ID string `json:"resourceid,omitempty" yaml:"resourceid,omitempty"` ApplicationID string `json:"applicationId,omitempty" yaml:"applicationId,omitempty"` Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` Path string `json:"path" yaml:"path"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Revision string `json:"revision,omitempty" yaml:"revision,omitempty"` Fingerprint string `json:"fingerprint" yaml:"fingerprint"` Size int64 `json:"size" yaml:"size"` Origin string `json:"origin" yaml:"origin"` Used bool `json:"used" yaml:"used"` Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"` CombinedRevision string `json:"-"` UsedYesNo string `json:"-"` CombinedOrigin string `json:"-"` }
FormattedAppResource holds the formatted representation of a resource's info.
func FormatAppResource ¶
func FormatAppResource(res resource.Resource) FormattedAppResource
FormatAppResource converts the resource info into a FormattedAppResource.
type FormattedApplicationDetails ¶
type FormattedApplicationDetails struct { Resources []FormattedDetailResource `json:"resources,omitempty" yaml:"resources,omitempty"` Updates []FormattedCharmResource `json:"updates,omitempty" yaml:"updates,omitempty"` }
FormattedApplicationDetails is the data for the tabular output for juju resources <application> --details.
func FormatApplicationDetails ¶
func FormatApplicationDetails(sr resource.ApplicationResources) (FormattedApplicationDetails, error)
FormatApplicationDetails converts a ApplicationResources value into a formatted value for display on the command line.
type FormattedApplicationInfo ¶
type FormattedApplicationInfo struct { Resources []FormattedAppResource `json:"resources,omitempty" yaml:"resources,omitempty"` Updates []FormattedCharmResource `json:"updates,omitempty" yaml:"updates,omitempty"` }
FormattedApplicationInfo holds the formatted representation of the information about an application's resources.
type FormattedCharmResource ¶
type FormattedCharmResource struct { // These fields are exported for the sake of serialization. Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` Path string `json:"path" yaml:"path"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Revision int `json:"revision,omitempty" yaml:"revision,omitempty"` Fingerprint string `json:"fingerprint" yaml:"fingerprint"` Size int64 `json:"size" yaml:"size"` Origin string `json:"origin" yaml:"origin"` }
FormattedCharmResource holds the formatted representation of a resource's info.
func FormatCharmResource ¶
func FormatCharmResource(res charmresource.Resource) FormattedCharmResource
FormatCharmResource converts the resource info into a FormattedCharmResource.
type FormattedDetailResource ¶
type FormattedDetailResource struct { UnitID string `json:"unitID" yaml:"unitID"` Unit FormattedAppResource `json:"unit" yaml:"unit"` Expected FormattedAppResource `json:"expected" yaml:"expected"` Progress int64 `json:"progress,omitempty" yaml:"progress,omitempty"` UnitNumber int `json:"-"` RevProgress string `json:"-"` }
FormattedDetailResource is the data for a single line of tabular output for juju resources <application> --details.
func FormatDetailResource ¶
func FormatDetailResource(tag names.UnitTag, svc, unit resource.Resource, progress int64) FormattedDetailResource
FormatDetailResource converts the arguments into a FormattedApplicationResource.
type FormattedUnitDetails ¶
type FormattedUnitDetails []FormattedDetailResource
FormattedDetailResource is the data for the tabular output for juju resources <unit> --details.
type ListClient ¶
type ListClient interface { // ListResources returns info about resources for applications in the model. ListResources(ctx context.Context, applications []string) ([]coreresources.ApplicationResources, error) // Close closes the connection. Close() error }
ListClient has the API client methods needed by ListCommand.
type ListCommand ¶
type ListCommand struct { modelcmd.ModelCommandBase // contains filtered or unexported fields }
ListCommand discovers and lists application or unit resources.
func (*ListCommand) Init ¶
func (c *ListCommand) Init(args []string) error
Init implements cmd.Command.Init. It will return an error satisfying errors.BadRequest if you give it an incorrect number of arguments.
func (*ListCommand) Run ¶
func (c *ListCommand) Run(ctx *cmd.Context) error
Run implements cmd.Command.Run.
func (*ListCommand) SetFlags ¶
func (c *ListCommand) SetFlags(f *gnuflag.FlagSet)
SetFlags implements cmd.Command.SetFlags.
type ResourceLister ¶
type ResourceLister interface {
ListResources(ctx context.Context, ids []CharmID) ([][]charmresource.Resource, error)
}
ResourceLister lists resources for the given charm ids.
type ResourceListerDependencies ¶
type ResourceListerDependencies interface {
NewAPIRoot(ctx context.Context) (api.Connection, error)
}
ResourceListerDependencies defines the dependencies to create a store dependant resource lister.
type UploadClient ¶
type UploadClient interface { // Upload sends the resource to Juju. Upload(ctx context.Context, application, name, filename, pendingID string, resource io.ReadSeeker) error // ListResources returns info about resources for applications in the model. ListResources(ctx context.Context, applications []string) ([]coreresources.ApplicationResources, error) // Close closes the client. Close() error }
UploadClient has the API client methods needed by UploadCommand.
type UploadCommand ¶
type UploadCommand struct { modelcmd.ModelCommandBase // contains filtered or unexported fields }
UploadCommand implements the upload command.
func (*UploadCommand) Info ¶
func (c *UploadCommand) Info() *cmd.Info
Info implements cmd.Command.Info
func (*UploadCommand) Init ¶
func (c *UploadCommand) Init(args []string) error
Init implements cmd.Command.Init. It will return an error satisfying errors.BadRequest if you give it an incorrect number of arguments.