Documentation ¶
Overview ¶
Package metadataemu provides a (limited) emulator for the Google Cloud Compute metadata servers.
Index ¶
- Constants
- func BadRequest(w http.ResponseWriter, s string)
- func GetGcloudOutput(gcloudPath string, params []string) ([]byte, error)
- func GetProjectID(gcloudPath string) (string, error)
- func InternalServerError(w http.ResponseWriter, bs []byte)
- func Ok(w http.ResponseWriter, contentType string, bs []byte)
- func OkJson(w http.ResponseWriter, bs []byte)
- func OkPlainText(w http.ResponseWriter, bs []byte)
- type AccessToken
- type Client
- type GcloudIdToken
- type Server
- type ServerConfig
Constants ¶
View Source
const ( ComputeMetadataPrefix = "/computeMetadata/v1" EndPointServiceAccounts = ComputeMetadataPrefix + "/instance/service-accounts" EndPointProjectId = ComputeMetadataPrefix + "/project/project-id" )
Use 'real' metadata paths Source: https://cloud.google.com/compute/docs/storing-retrieving-metadata
View Source
const ( HeaderMetadataFlavour = "metadata-flavor" HeaderValueMetadataFlavour = "Google" HeaderContentType = "content-type" HeaderValueTextPlain = "text/plain" HeaderValueApplicationJson = "application/json" )
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter, s string)
func GetProjectID ¶
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, bs []byte)
func OkJson ¶
func OkJson(w http.ResponseWriter, bs []byte)
func OkPlainText ¶
func OkPlainText(w http.ResponseWriter, bs []byte)
Types ¶
type AccessToken ¶
type AccessToken struct { AccessToken string `json:"access_token"` ExpiresInSec int `json:"expires_in"` TokenType string `json:"token_type"` }
func GetGcloudAccessToken ¶
func GetGcloudAccessToken(gcloudPath, sa, audience string) (*AccessToken, error)
type Client ¶
type GcloudIdToken ¶
type GcloudIdToken struct { AccessToken string `json:"access_token"` IdToken string `json:"id_token"` TokenExpiry time.Time `json:"token_expiry"` }
func GetGcloudIdToken ¶
func GetGcloudIdToken(gcloudPath, sa, audience string) (*GcloudIdToken, error)
type Server ¶
type Server interface {
Run() error
}
func NewServerFromConfig ¶
func NewServerFromConfig(conf *ServerConfig) Server
NewServerFromConfig creates a new metadata server from a ServerConfig.
func NewServerFromConfigFile ¶
NewServerFromConfigFile creates a new metadata server from a ServerConfig.
type ServerConfig ¶
type ServerConfig struct { Port string `json:"port"` GcloudPath string `json:"gcloudPath,omitempty"` NoKey bool `json:"noKey,omitempty"` ProjectId string `json:"projectId,omitempty"` ServiceAccount string `json:"serviceAccount,omitempty"` ServiceAccountId string `json:"serviceAccountId,omitempty"` }
Click to show internal directories.
Click to hide internal directories.