github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/builder/googlecompute/account.go (about) 1 package googlecompute 2 3 import ( 4 "encoding/json" 5 "os" 6 ) 7 8 // accountFile represents the structure of the account file JSON file. 9 type accountFile struct { 10 PrivateKeyId string `json:"private_key_id"` 11 PrivateKey string `json:"private_key"` 12 ClientEmail string `json:"client_email"` 13 ClientId string `json:"client_id"` 14 } 15 16 // clientSecretsFile represents the structure of the client secrets JSON file. 17 type clientSecretsFile struct { 18 Web struct { 19 AuthURI string `json:"auth_uri"` 20 ClientEmail string `json:"client_email"` 21 ClientId string `json:"client_id"` 22 TokenURI string `json:"token_uri"` 23 } 24 } 25 26 func loadJSON(result interface{}, path string) error { 27 f, err := os.Open(path) 28 if err != nil { 29 return err 30 } 31 defer f.Close() 32 33 dec := json.NewDecoder(f) 34 return dec.Decode(result) 35 }