// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package common

import (
	"fmt"

	"github.com/juju/names"

	"github.com/juju/juju/environs"
)

// EnvFullName returns a string based on the provided environment
// that is suitable for identifying the env on a provider. The resuling
// string clearly associates the value with juju, whereas the
// environment's UUID alone isn't very distinctive for humans. This
// benefits users by helping them quickly identify in their hosting
// management tools which instances are juju related.
func EnvFullName(env environs.Environ) string {
	envUUID, _ := env.Config().UUID() // Env should have validated this.
	return fmt.Sprintf("juju-%s", envUUID)
}

// MachineFullName returns a string based on the provided environment
// and machine ID that is suitable for identifying instances on a
// provider. See EnvFullName for an explanation on how this function
// helps juju users.
func MachineFullName(env environs.Environ, machineId string) string {
	envstr := EnvFullName(env)
	machineTag := names.NewMachineTag(machineId)
	return fmt.Sprintf("%s-%s", envstr, machineTag)
}

// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package common

import (
	"fmt"

	"github.com/juju/names"

	"github.com/juju/juju/environs"
)

// EnvFullName returns a string based on the provided environment
// that is suitable for identifying the env on a provider.
func EnvFullName(env environs.Environ) string {
	envUUID, _ := env.Config().UUID() // Env should have validated this.
	return fmt.Sprintf("juju-%s", envUUID)
}

// MachineFullName returns a string based on the provided environment
// and machine ID that is suitable for identifying instances on a
// provider.
func MachineFullName(env environs.Environ, machineId string) string {
	envstr := EnvFullName(env)
	machineTag := names.NewMachineTag(machineId)
	return fmt.Sprintf("%s-%s", envstr, machineTag)
}

--- 
+++ 
@@ -12,7 +12,11 @@
 )
 
 // EnvFullName returns a string based on the provided environment
-// that is suitable for identifying the env on a provider.
+// that is suitable for identifying the env on a provider. The resuling
+// string clearly associates the value with juju, whereas the
+// environment's UUID alone isn't very distinctive for humans. This
+// benefits users by helping them quickly identify in their hosting
+// management tools which instances are juju related.
 func EnvFullName(env environs.Environ) string {
 	envUUID, _ := env.Config().UUID() // Env should have validated this.
 	return fmt.Sprintf("juju-%s", envUUID)
@@ -20,7 +24,8 @@
 
 // MachineFullName returns a string based on the provided environment
 // and machine ID that is suitable for identifying instances on a
-// provider.
+// provider. See EnvFullName for an explanation on how this function
+// helps juju users.
 func MachineFullName(env environs.Environ, machineId string) string {
 	envstr := EnvFullName(env)
 	machineTag := names.NewMachineTag(machineId)
provider/common: Add more rationale to the doc comments for EnvFullName and MachineFullName.
