File: instance_info.go

package info (click to toggle)
golang-github-google-go-tpm-tools 0.4.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,644 kB
  • sloc: ansic: 51,865; sh: 862; makefile: 25
file content (19 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package server

import (
	"fmt"
	"net/url"

	pb "github.com/google/go-tpm-tools/proto/attest"
)

// GCEInstanceURL returns a Google API URL to the specified instance. This URL
// can then be used with GCE instance APIs.
func GCEInstanceURL(i *pb.GCEInstanceInfo) string {
	return fmt.Sprintf(
		"https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances/%s",
		url.PathEscape(i.GetProjectId()),
		url.PathEscape(i.GetZone()),
		url.PathEscape(i.GetInstanceName()), // Can use either the name or id here
	)
}