cloudprovider: add the ProviderName method

This patch adds the ProviderName method used to identify the cloud
provider.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
Federico Simoncelli
2015-05-05 10:10:24 -04:00
parent 9b67435cf3
commit 194343267d
9 changed files with 64 additions and 8 deletions

View File

@@ -42,6 +42,8 @@ import (
"google.golang.org/cloud/compute/metadata"
)
const ProviderName = "gce"
const EXTERNAL_IP_METADATA_URL = "http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip"
// GCECloud is an implementation of Interface, TCPLoadBalancer and Instances for Google Compute Engine.
@@ -67,7 +69,7 @@ type Config struct {
}
func init() {
cloudprovider.RegisterCloudProvider("gce", func(config io.Reader) (cloudprovider.Interface, error) { return newGCECloud(config) })
cloudprovider.RegisterCloudProvider(ProviderName, func(config io.Reader) (cloudprovider.Interface, error) { return newGCECloud(config) })
}
func getMetadata(url string) (string, error) {
@@ -182,6 +184,11 @@ func (gce *GCECloud) Clusters() (cloudprovider.Clusters, bool) {
return gce, true
}
// ProviderName returns the cloud provider ID.
func (gce *GCECloud) ProviderName() string {
return ProviderName
}
// TCPLoadBalancer returns an implementation of TCPLoadBalancer for Google Compute Engine.
func (gce *GCECloud) TCPLoadBalancer() (cloudprovider.TCPLoadBalancer, bool) {
return gce, true