github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/configuration/global/configuration.go (about)

     1  package global
     2  
     3  import (
     4  	"github.com/mutagen-io/mutagen/pkg/api/models/forwarding"
     5  	"github.com/mutagen-io/mutagen/pkg/api/models/synchronization"
     6  	"github.com/mutagen-io/mutagen/pkg/encoding"
     7  )
     8  
     9  // Configuration is the global YAML configuration object type.
    10  type Configuration struct {
    11  	// Forwarding is the global forwarding configuration.
    12  	Forwarding struct {
    13  		// Defaults are the global forwarding configuration defaults.
    14  		Defaults forwarding.Configuration `yaml:"defaults"`
    15  	} `yaml:"forward"`
    16  	// Synchronization is the global synchronization configuration.
    17  	Synchronization struct {
    18  		// Defaults are the global synchronization configuration defaults.
    19  		Defaults synchronization.Configuration `yaml:"defaults"`
    20  	} `yaml:"sync"`
    21  }
    22  
    23  // LoadConfiguration attempts to load a YAML-based Mutagen global configuration
    24  // file from the specified path.
    25  func LoadConfiguration(path string) (*Configuration, error) {
    26  	// Create the target configuration object.
    27  	result := &Configuration{}
    28  
    29  	// Attempt to load. We pass-through os.IsNotExist errors.
    30  	if err := encoding.LoadAndUnmarshalYAML(path, result); err != nil {
    31  		return nil, err
    32  	}
    33  
    34  	// Success.
    35  	return result, nil
    36  }