...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package credsfile
16
17 import (
18 "encoding/json"
19 )
20
21
22 func ParseServiceAccount(b []byte) (*ServiceAccountFile, error) {
23 var f *ServiceAccountFile
24 if err := json.Unmarshal(b, &f); err != nil {
25 return nil, err
26 }
27 return f, nil
28 }
29
30
31
32 func ParseClientCredentials(b []byte) (*ClientCredentialsFile, error) {
33 var f *ClientCredentialsFile
34 if err := json.Unmarshal(b, &f); err != nil {
35 return nil, err
36 }
37 return f, nil
38 }
39
40
41 func ParseUserCredentials(b []byte) (*UserCredentialsFile, error) {
42 var f *UserCredentialsFile
43 if err := json.Unmarshal(b, &f); err != nil {
44 return nil, err
45 }
46 return f, nil
47 }
48
49
50 func ParseExternalAccount(b []byte) (*ExternalAccountFile, error) {
51 var f *ExternalAccountFile
52 if err := json.Unmarshal(b, &f); err != nil {
53 return nil, err
54 }
55 return f, nil
56 }
57
58
59
60 func ParseExternalAccountAuthorizedUser(b []byte) (*ExternalAccountAuthorizedUserFile, error) {
61 var f *ExternalAccountAuthorizedUserFile
62 if err := json.Unmarshal(b, &f); err != nil {
63 return nil, err
64 }
65 return f, nil
66 }
67
68
69
70 func ParseImpersonatedServiceAccount(b []byte) (*ImpersonatedServiceAccountFile, error) {
71 var f *ImpersonatedServiceAccountFile
72 if err := json.Unmarshal(b, &f); err != nil {
73 return nil, err
74 }
75 return f, nil
76 }
77
78
79 func ParseGDCHServiceAccount(b []byte) (*GDCHServiceAccountFile, error) {
80 var f *GDCHServiceAccountFile
81 if err := json.Unmarshal(b, &f); err != nil {
82 return nil, err
83 }
84 return f, nil
85 }
86
87 type fileTypeChecker struct {
88 Type string `json:"type"`
89 }
90
91
92 func ParseFileType(b []byte) (CredentialType, error) {
93 var f fileTypeChecker
94 if err := json.Unmarshal(b, &f); err != nil {
95 return 0, err
96 }
97 return parseCredentialType(f.Type), nil
98 }
99
View as plain text