Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions cmd/cnctl/cnctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func displayGCPCloudNetworkMetadata(links *network.Links, g *provider.GCPMetaDat
func fetchCloudNetworkMetadata(ip string, port string) error {
resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/network", nil)
if err != nil {
fmt.Printf("Failed to fetch instance metadata: '%+v'", err)
fmt.Printf("Failed to fetch instance metadata: '%v'", err)
return err
}

Expand Down Expand Up @@ -282,6 +282,7 @@ func displayGCPCloudProjectMetadata(g *provider.GCPMetaData) {
func fetchCloudSystemMetadata(ip string, port string) {
resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/system", nil)
if err != nil {
fmt.Printf("Failed to fetch instance metadata: '%v'", err)
return
}

Expand Down Expand Up @@ -344,6 +345,7 @@ func displayGCPCloudSSHKeysFromMetadata(g *provider.GCPMetaData) {
func fetchSSHKeysFromCloudMetadata(ip string, port string) {
resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/system", nil)
if err != nil {
fmt.Printf("Failed to fetch instance metadata: '%v'", err)
return
}

Expand Down Expand Up @@ -372,11 +374,6 @@ func fetchSSHKeysFromCloudMetadata(ip string, port string) {
}

func fetchGCPCloudProjectMetadata(ip string, port string) {
if cloud.DetectCloud() != cloud.GCP {
fmt.Println("unsupported cloud environment")
return
}

resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/system", nil)
if err != nil {
return
Expand All @@ -389,7 +386,7 @@ func fetchGCPCloudProjectMetadata(ip string, port string) {
}

func displayIdentityCredentialsFromMetadata(c *provider.EC2Credentials) {
fmt.Printf(" Accesskey Id: %+v\n", c.Accesskeyid)
fmt.Printf(" Access key Id: %+v\n", c.Accesskeyid)
fmt.Printf(" Type: %+v\n", c.Type)
fmt.Printf(" Expiration: %+v\n", c.Expiration)
fmt.Printf(" Code: %+v\n", c.Code)
Expand All @@ -398,13 +395,9 @@ func displayIdentityCredentialsFromMetadata(c *provider.EC2Credentials) {
}

func fetchIdentityCredentialsFromCloudMetadata(ip string, port string) {
if cloud.DetectCloud() != cloud.AWS {
fmt.Println("unsupported cloud environment")
return
}

resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/credentials", nil)
if err != nil {
fmt.Printf("Failed to fetch instance metadata: '%v'", err)
return
}
var c provider.EC2Credentials
Expand Down Expand Up @@ -440,13 +433,9 @@ func displayDynamicInstanceIdentityDocument(c *provider.EC2Document) {
}

func fetchDynamicInstanceIdentityFromCloudMetadata(s string, ip string, port string) {
if cloud.DetectCloud() != cloud.AWS {
fmt.Println("unsupported cloud environment")
return
}

resp, err := web.Dispatch("http://"+ip+":"+port+"/api/cloud/dynamicinstanceidentity/"+s, nil)
if err != nil {
fmt.Printf("Failed to fetch instance metadata: '%v'", err)
return
}
switch s {
Expand Down Expand Up @@ -485,7 +474,7 @@ func main() {

kind := cloud.DetectCloud()
if len(kind) <= 0 {
fmt.Printf("Failed to detect cloud environment, Aborting ...")
fmt.Println("Failed to detect cloud environment, Aborting ...")
os.Exit(1)
}

Expand Down
2 changes: 1 addition & 1 deletion provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func AcquireCloudMetadata(m *Environment) error {
}

if err != nil {
log.Errorf("Failed to retrieve cloud provider '%+v' instance metadata: %+v", m.Kind, err)
log.Errorf("Failed to retrieve cloud provider '%+v' instance metadata: %v", m.Kind, err)
return err
}

Expand Down