Download your service account credentials file from Google Cloud and save it as googlecloudinfo.json
in your HOME/.gocloud directory.
You can also set the credentials as environment variables:
export PrivateKey = "xxxxxxxxxxxx"
export Type = "xxxxxxxxxxxx"
export ProjectID = "xxxxxxxxxxxx"
export PrivateKeyID = "xxxxxxxxxxxx"
export ClientEmail = "xxxxxxxxxxxx"
export ClientID = "xxxxxxxxxxxx"
export AuthURI = "xxxxxxxxxxxx"
export TokenURI = "xxxxxxxxxxxx"
export AuthProviderX509CertURL = "xxxxxxxxxxxx"
export ClientX509CertURL = "xxxxxxxxxxxx"
import "github.com/cloudlibz/gocloud/gocloud"
googlecloud, _ := gocloud.CloudProvider(gocloud.Googleprovider)
nodepools := []map[string]interface{}{
{
"name": "default-pool",
"initialNodeCount": 3,
},
}
createcluster := map[string]interface{}{
"Project": "sheltermap-1493101612061",
"Name" : "cluster-2",
"Zone" : "us-central1-a",
"nodePools" : nodepools,
}
resp, err := googlecloud.CreateCluster(createcluster)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
deletecluster := map[string]string{
"Project": "sheltermap-1493101612061",
"clusterId": "cluster-1",
"Zone": "us-central1-a",
}
resp , err := googlecloud.DeleteCluster(deletecluster)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
createservice := map[string]interface{}{
"Project" : "sheltermap-1493101612061",
"clusterId" : "cluster-2",
"Zone" : "us-central1-a",
"Name" : "nodepool",
}
resp, err := googlecloud.CreateService(createservice)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
deleteservice := map[string]string{
"Project": "sheltermap-1493101612061",
"clusterId": "cluster-2",
"Zone": "us-central1-a",
"nodePoolId": "nodepool",
}
resp, err := googlecloud.DeleteService(deleteservice)
response := resp.(map[string]interface{})
fmt.Println(response["body"])