cmd: Prefix packet.net host name with username
If a packet account is shared between users, this makes it
clearer who created the machine.
Also, switch "moby" to "linuxkit"
@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
+ "os/user"
"path/filepath"
"github.com/bzub/packngo" // TODO(rn): Update to official once iPXE is merged
@@ -15,7 +16,6 @@ import (
const (
packetDefaultZone = "ams1"
packetDefaultMachine = "baremetal_0"
- packetDefaultHostname = "moby"
packetBaseURL = "PACKET_BASE_URL"
packetZoneVar = "PACKET_ZONE"
packetMachineVar = "PACKET_MACHINE"
@@ -25,6 +25,17 @@ const (
packetNameVar = "PACKET_NAME"
)
+var (
+ packetDefaultHostname = "linuxkit"
+)
+
+func init() {
+ // Prefix host name with username
+ if u, err := user.Current(); err == nil {
+ packetDefaultHostname = u.Username + "-" + packetDefaultHostname
+ }
+}
+
// ValidateHTTPURL does a sanity check that a URL returns a 200 or 300 response
func ValidateHTTPURL(url string) {
log.Printf("Validating URL: %s", url)
