utils

package
v0.0.0-...-298751d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFile

func CheckFile(name, path string, fs modelcmd.Filesystem) error

func CombinedConfig

func CombinedConfig(ctx *cmd.Context, filesystem modelcmd.Filesystem, configOptions configFlag, appName string) (string, error)

CombinedConfig takes the config key/value pairs and config.yaml file and combines into a yaml string. The key/value pairs representing charm settings overrides anything in the YAML file. If more than one file is specified, that is an error.

func GetFlags

func GetFlags(flagSet *gnuflag.FlagSet, flagNames []string) []string

GetFlags returns the flags with the given names. Only flags that are set and whose name is included in flagNames are included.

func GetMetaResources

func GetMetaResources(charmURL string, client CharmClient) (map[string]charmresource.Meta, error)

GetMetaResources retrieves metadata resources for the given charmURL.

func GetUpgradeResources

func GetUpgradeResources(
	newCharmID application.CharmID,
	repositoryResourceLister CharmClient,
	resourceLister ResourceLister,
	applicationID string,
	providedResources map[string]string,
	meta map[string]charmresource.Meta,
) (map[string]charmresource.Meta, error)

GetUpgradeResources returns a map of resources which require refresh.

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal checks if the file descriptor is a terminal.

func MakeOrigin

func MakeOrigin(schema charm.Schema, revision int, channel charm.Channel, platform corecharm.Platform) (commoncharm.Origin, error)

MakeOrigin creates an origin from a schema, revision, channel and a platform. Depending on what the schema is, will then construct the correct origin for that application.

func MakePlatform

func MakePlatform(cons constraints.Value, base corebase.Base, modelCons constraints.Value) corecharm.Platform

MakePlatform creates a Platform (architecture, os and base) from a set of constraints and a base.

func ParsePlacement

func ParsePlacement(spec string) (*instance.Placement, error)

ParsePlacement validates provided placement of a unit and returns instance.Placement.

func ProcessConfig

func ProcessConfig(ctx *cmd.Context, filesystem modelcmd.Filesystem, configOptions configFlag, trust *bool) (map[string]string, string, error)

ProcessConfig processes the config defined by the config flag and returns the map of config values and any YAML file content. We may have a single file arg specified, in which case it points to a YAML file keyed on the charm name and containing values for any charm settings. We may also have key/value pairs representing charm settings which overrides anything in the YAML file. If more than one file is specified, that is an error.

func ReadValue

func ReadValue(ctx *cmd.Context, filesystem modelcmd.Filesystem, filename string) (string, error)

ReadValue reads the value of an option out of the named file. An empty content is valid, like in parsing the options. The upper size is 5M.

Types

type CharmClient

type CharmClient interface {
	CharmInfo(string) (*charms.CharmInfo, error)
	ListCharmResources(curl string, origin apicharm.Origin) ([]charmresource.Resource, error)
}

CharmClient defines a subset of the charms facade, as required by the upgrade-charm command and to GetMetaResources.

type ResourceLister

type ResourceLister interface {
	ListResources([]string) ([]resources.ApplicationResources, error)
}

ResourceLister defines a subset of the resources facade, as required by the upgrade-charm command and to deploy bundles.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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