github.com/juju/charm/v11@v11.2.0/charmbase.go (about)

     1  // Copyright 2021 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package charm
     5  
     6  // charmBase implements the Charm interface with commonality between
     7  // a charm archive and directory.
     8  type charmBase struct {
     9  	meta       *Meta
    10  	config     *Config
    11  	metrics    *Metrics
    12  	actions    *Actions
    13  	lxdProfile *LXDProfile
    14  	manifest   *Manifest
    15  	revision   int
    16  	version    string
    17  }
    18  
    19  // Revision returns the revision number for the charm
    20  // expanded in dir.
    21  func (c *charmBase) Revision() int {
    22  	return c.revision
    23  }
    24  
    25  // Version returns the VCS version representing the version file from archive.
    26  func (c *charmBase) Version() string {
    27  	return c.version
    28  }
    29  
    30  // Meta returns the Meta representing the metadata.yaml file
    31  // for the charm expanded in dir.
    32  func (c *charmBase) Meta() *Meta {
    33  	return c.meta
    34  }
    35  
    36  // Config returns the Config representing the config.yaml file
    37  // for the charm expanded in dir.
    38  func (c *charmBase) Config() *Config {
    39  	return c.config
    40  }
    41  
    42  // Metrics returns the Metrics representing the metrics.yaml file
    43  // for the charm expanded in dir.
    44  func (c *charmBase) Metrics() *Metrics {
    45  	return c.metrics
    46  }
    47  
    48  // Actions returns the Actions representing the actions.yaml file
    49  // for the charm expanded in dir.
    50  func (c *charmBase) Actions() *Actions {
    51  	return c.actions
    52  }
    53  
    54  // LXDProfile returns the LXDProfile representing the lxd-profile.yaml file
    55  // for the charm expanded in dir.
    56  func (c *charmBase) LXDProfile() *LXDProfile {
    57  	return c.lxdProfile
    58  }
    59  
    60  // Manifest returns the Manifest representing the manifest.yaml file
    61  // for the charm expanded in dir.
    62  func (c *charmBase) Manifest() *Manifest {
    63  	return c.manifest
    64  }
    65  
    66  // SetRevision changes the charm revision number. This affects
    67  // the revision reported by Revision and the revision of the
    68  // charm created.
    69  // The revision file in the charm directory is not modified.
    70  func (c *charmBase) SetRevision(revision int) {
    71  	c.revision = revision
    72  }