github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/provider/azure/init.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package azure
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	"github.com/juju/utils/clock"
     9  
    10  	"github.com/juju/juju/environs"
    11  	"github.com/juju/juju/provider/azure/internal/azureauth"
    12  	"github.com/juju/juju/provider/azure/internal/azurestorage"
    13  )
    14  
    15  const (
    16  	providerType = "azure"
    17  )
    18  
    19  // NewProvider instantiates and returns the Azure EnvironProvider using the
    20  // given configuration.
    21  func NewProvider(config ProviderConfig) (environs.EnvironProvider, error) {
    22  	environProvider, err := NewEnvironProvider(config)
    23  	if err != nil {
    24  		return nil, errors.Trace(err)
    25  	}
    26  	return environProvider, nil
    27  }
    28  
    29  func init() {
    30  	environProvider, err := NewProvider(ProviderConfig{
    31  		NewStorageClient:                  azurestorage.NewClient,
    32  		RetryClock:                        &clock.WallClock,
    33  		RandomWindowsAdminPassword:        randomAdminPassword,
    34  		InteractiveCreateServicePrincipal: azureauth.InteractiveCreateServicePrincipal,
    35  	})
    36  	if err != nil {
    37  		panic(err)
    38  	}
    39  
    40  	environs.RegisterProvider(providerType, environProvider)
    41  
    42  	// TODO(axw) register an image metadata data source that queries
    43  	// the Azure image registry, and introduce a way to disable the
    44  	// common simplestreams source.
    45  }