Documentation
¶
Overview ¶
jujusvg generates SVG representations of various Juju artifacts, such as charm bundles or live environments.
For more information, please refer to the README file in this directory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas holds the parsed form of a bundle or environment.
func NewFromBundle ¶
func NewFromBundle(b *charm.BundleData, iconURL func(*charm.Reference) string, fetcher IconFetcher) (*Canvas, error)
NewFromBundle returns a new Canvas that can be used to generate a graphical representation of the given bundle data. The iconURL function is used to generate a URL that refers to an SVG for the supplied charm URL. If fetcher is non-nil, it will be used to fetch icon contents for any icons embedded within the charm, allowing the generated bundle to be self-contained. If fetcher is nil, a default fetcher which refers to icons by their URLs as svg <image> tags will be used.
type HTTPFetcher ¶
type HTTPFetcher struct { // Concurrency specifies the number of GoRoutines to use when fetching // icons. If it is not positive, 10 will be used. Setting this to 1 // makes this method nominally synchronous. Concurrency int // IconURL returns the URL from which to fetch the given entity's icon SVG. IconURL func(*charm.Reference) string // Client specifies what HTTP client to use; if it is not provided, // http.DefaultClient will be used. Client *http.Client }
HTTPFetcher is an implementation of IconFetcher which retrieves charm icons from the web using the URL generated by IconURL on that charm. The HTTP Client used may be overridden by an instance of http.Client. The icons may optionally be fetched concurrently.
func (*HTTPFetcher) FetchIcons ¶
func (h *HTTPFetcher) FetchIcons(b *charm.BundleData) (map[string][]byte, error)
FetchIcons retrieves icon SVGs over HTTP. If specified in the struct, icons will be fetched concurrently.
type IconFetcher ¶
An IconFetcher provides functionality for retrieving icons for the charms within a given bundle. The FetchIcons function accepts a bundle, and returns a map from charm paths to icon data.
type LinkFetcher ¶
type LinkFetcher struct { // IconURL returns the URL of the entity for embedding IconURL func(*charm.Reference) string }
LinkFetcher fetches icons as links so that they are included within the SVG as remote resources using SVG <image> tags.
func (*LinkFetcher) FetchIcons ¶
func (l *LinkFetcher) FetchIcons(b *charm.BundleData) (map[string][]byte, error)
FetchIcons generates the svg image tags given an appropriate URL, generating tags only for unique icons.