github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/payload/state/payloads.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package state
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  
     9  	"github.com/juju/juju/payload"
    10  )
    11  
    12  // EnvPersistence provides the persistence functionality for the
    13  // Juju environment as a whole.
    14  type EnvPersistence interface {
    15  	// ListAll returns the list of all payloads in the environment.
    16  	ListAll() ([]payload.FullPayloadInfo, error)
    17  }
    18  
    19  // EnvPayloads provides the functionality related to an env's
    20  // payloads, as needed by state.
    21  type EnvPayloads struct {
    22  	Persist EnvPersistence
    23  }
    24  
    25  // ListAll builds the list of payload information that is registered in state.
    26  func (ps EnvPayloads) ListAll() ([]payload.FullPayloadInfo, error) {
    27  	logger.Tracef("listing all payloads")
    28  
    29  	payloads, err := ps.Persist.ListAll()
    30  	if err != nil {
    31  		return nil, errors.Trace(err)
    32  	}
    33  	return payloads, nil
    34  }