juju: github.com/juju/juju/cmd/juju/resource Index | Files

package resource

import "github.com/juju/juju/cmd/juju/resource"

Index

Package Files

charmresources.go deploy.go formatted.go formatter.go list.go list_charm_resources.go output_tabular.go resource.go upload.go

Constants

const (
    Deprecated      = "DEPRECATED: "
    DeprecatedSince = "This command is DEPRECATED since Juju 2.3.x, please use 'juju charm-resources' instead.\n"
)

func DeployResources Uses

func DeployResources(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 Uses

func FormatAppTabular(writer io.Writer, value interface{}) error

FormatAppTabular returns a tabular summary of resources.

func FormatCharmTabular Uses

func FormatCharmTabular(writer io.Writer, value interface{}) error

FormatCharmTabular returns a tabular summary of charm resources.

func NewCharmResourcesCommand Uses

func NewCharmResourcesCommand(resourceLister ResourceLister) modelcmd.ModelCommand

NewCharmResourcesCommand returns a new command that lists resources defined by a charm.

func NewListCharmResourcesCommand Uses

func NewListCharmResourcesCommand(resourceLister ResourceLister) modelcmd.ModelCommand

NewListCharmResourcesCommand returns a new command that lists resources defined by a charm.

func NewListCommand Uses

func NewListCommand(deps ListDeps) modelcmd.ModelCommand

NewListCommand returns a new command that lists resources defined by a charm.

func NewUploadCommand Uses

func NewUploadCommand(deps UploadDeps) modelcmd.ModelCommand

NewUploadCommand returns a new command that lists resources defined by a charm.

type CharmResourcesCommand Uses

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

CharmResourcesCommand implements the "juju charm-resources" command.

func (*CharmResourcesCommand) Info Uses

func (c *CharmResourcesCommand) Info() *cmd.Info

Info implements cmd.Command.

func (*CharmResourcesCommand) Init Uses

func (c *CharmResourcesCommand) Init(args []string) error

Init implements cmd.Command.

func (*CharmResourcesCommand) ListResources Uses

func (c *CharmResourcesCommand) ListResources(ids []charmstore.CharmID) ([][]charmresource.Resource, error)

ListCharmResources implements CharmResourceLister by getting the charmstore client from the command's ModelCommandBase.

func (*CharmResourcesCommand) Run Uses

func (c *CharmResourcesCommand) Run(ctx *cmd.Context) error

Run implements cmd.Command.

func (*CharmResourcesCommand) SetFlags Uses

func (c *CharmResourcesCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements cmd.Command.

type DeployClient Uses

type DeployClient interface {
    // AddPendingResources adds pending metadata for store-based resources.
    AddPendingResources(applicationID string, chID charmstore.CharmID, csMac *macaroon.Macaroon, resources []charmresource.Resource) (ids []string, err error)

    // UploadPendingResource uploads data and metadata for a pending resource for the given application.
    UploadPendingResource(applicationID string, resource charmresource.Resource, filename string, r io.ReadSeeker) (id string, err error)
}

DeployClient exposes the functionality of the resources API needed for deploy.

type DeployResourcesArgs Uses

type DeployResourcesArgs struct {
    // ApplicationID identifies the application being deployed.
    ApplicationID string

    // CharmID identifies the application's charm.
    CharmID charmstore.CharmID

    // CharmStoreMacaroon is the macaroon to use for the charm when
    // interacting with the charm store.
    CharmStoreMacaroon *macaroon.Macaroon

    // 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
}

DeployResourcesArgs holds the arguments to DeployResources().

type FormattedAppResource Uses

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 Uses

func FormatAppResource(res resource.Resource) FormattedAppResource

FormatAppResource converts the resource info into a FormattedAppResource.

type FormattedApplicationDetails Uses

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 Uses

func FormatApplicationDetails(sr resource.ApplicationResources) (FormattedApplicationDetails, error)

FormatApplicationDetails converts a ApplicationResources value into a formatted value for display on the command line.

type FormattedApplicationInfo Uses

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 Uses

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 Uses

func FormatCharmResource(res charmresource.Resource) FormattedCharmResource

FormatCharmResource converts the resource info into a FormattedCharmResource.

type FormattedDetailResource Uses

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 Uses

func FormatDetailResource(tag names.UnitTag, svc, unit resource.Resource, progress int64) (FormattedDetailResource, error)

FormatDetailResource converts the arguments into a FormattedApplicationResource.

type FormattedUnitDetails Uses

type FormattedUnitDetails []FormattedDetailResource

FormattedDetailResource is the data for the tabular output for juju resources <unit> --details.

type ListCharmResourcesCommand Uses

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

ListCharmResourcesCommand implements the "juju charm resources" command.

func (*ListCharmResourcesCommand) Info Uses

func (c *ListCharmResourcesCommand) Info() *cmd.Info

Info implements cmd.Command.

func (*ListCharmResourcesCommand) Init Uses

func (c *ListCharmResourcesCommand) Init(args []string) error

Init implements cmd.Command.

func (*ListCharmResourcesCommand) ListResources Uses

func (c *ListCharmResourcesCommand) ListResources(ids []charmstore.CharmID) ([][]charmresource.Resource, error)

ListCharmResources implements CharmResourceLister by getting the charmstore client from the command's ModelCommandBase.

func (*ListCharmResourcesCommand) Run Uses

func (c *ListCharmResourcesCommand) Run(ctx *cmd.Context) error

Run implements cmd.Command.

func (*ListCharmResourcesCommand) SetFlags Uses

func (c *ListCharmResourcesCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements cmd.Command.

type ListClient Uses

type ListClient interface {
    // ListResources returns info about resources for applications in the model.
    ListResources(applications []string) ([]resource.ApplicationResources, error)
    // Close closes the connection.
    Close() error
}

ListClient has the API client methods needed by ListCommand.

type ListCommand Uses

type ListCommand struct {
    modelcmd.ModelCommandBase
    // contains filtered or unexported fields
}

ListCommand discovers and lists application or unit resources.

func (*ListCommand) Info Uses

func (c *ListCommand) Info() *cmd.Info

Info implements cmd.Command.Info.

func (*ListCommand) Init Uses

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 Uses

func (c *ListCommand) Run(ctx *cmd.Context) error

Run implements cmd.Command.Run.

func (*ListCommand) SetFlags Uses

func (c *ListCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements cmd.Command.SetFlags.

type ListDeps Uses

type ListDeps struct {
    // NewClient returns the value that wraps the API for showing
    // resources from the server.
    NewClient func(*ListCommand) (ListClient, error)
}

ListDeps is a type that contains external functions that List needs.

type ReadSeekCloser Uses

type ReadSeekCloser interface {
    io.ReadCloser
    io.Seeker
}

ReadSeekCloser combines 2 interfaces.

func OpenResource Uses

func OpenResource(resValue string, resType charmresource.Type, osOpen osOpenFunc) (ReadSeekCloser, error)

type ResourceLister Uses

type ResourceLister interface {
    ListResources(ids []charmstore.CharmID) ([][]charmresource.Resource, error)
}

CharmResourceLister lists resources for the given charm ids.

type UploadClient Uses

type UploadClient interface {
    // Upload sends the resource to Juju.
    Upload(application, name, filename string, resource io.ReadSeeker) error

    // ListResources returns info about resources for applications in the model.
    ListResources(applications []string) ([]resource.ApplicationResources, error)

    // Close closes the client.
    Close() error
}

UploadClient has the API client methods needed by UploadCommand.

type UploadCommand Uses

type UploadCommand struct {
    modelcmd.ModelCommandBase
    // contains filtered or unexported fields
}

UploadCommand implements the upload command.

func (*UploadCommand) Info Uses

func (c *UploadCommand) Info() *cmd.Info

Info implements cmd.Command.Info

func (*UploadCommand) Init Uses

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.

func (*UploadCommand) Run Uses

func (c *UploadCommand) Run(*cmd.Context) error

Run implements cmd.Command.Run.

type UploadDeps Uses

type UploadDeps struct {
    // NewClient returns the value that wraps the API for uploading to the server.
    NewClient func(*UploadCommand) (UploadClient, error)

    // OpenResource handles creating a reader from the resource path.
    OpenResource func(path string) (ReadSeekCloser, error)
}

UploadDeps is a type that contains external functions that Upload depends on to function.

Package resource imports 29 packages (graph) and is imported by 9 packages. Updated 2019-09-29. Refresh now. Tools for package owners.