|
|
@@ -25,6 +25,9 @@ type GCPIntegration struct {
|
|
|
// The GCP project id where the service account for this auth mechanism persists
|
|
|
GCPProjectID string `json:"gcp_project_id"`
|
|
|
|
|
|
+ // The GCP service account email for this credential
|
|
|
+ GCPSAEmail string `json:"gcp_sa_email"`
|
|
|
+
|
|
|
// The GCP user email that linked this service account
|
|
|
GCPUserEmail string `json:"gcp-user-email"`
|
|
|
|
|
|
@@ -41,12 +44,11 @@ type GCPIntegration struct {
|
|
|
|
|
|
func (g *GCPIntegration) ToGCPIntegrationType() *types.GCPIntegration {
|
|
|
return &types.GCPIntegration{
|
|
|
- CreatedAt: g.CreatedAt,
|
|
|
ID: g.ID,
|
|
|
UserID: g.UserID,
|
|
|
ProjectID: g.ProjectID,
|
|
|
GCPProjectID: g.GCPProjectID,
|
|
|
- GCPUserEmail: g.GCPUserEmail,
|
|
|
+ GCPSAEmail: g.GCPSAEmail,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -126,3 +128,16 @@ func GCPProjectIDFromJSON(jsonData []byte) (string, error) {
|
|
|
|
|
|
return f.ProjectID, nil
|
|
|
}
|
|
|
+
|
|
|
+// PopulateGCPMetadata uses the credentials file to get the GCP SA name and
|
|
|
+// project ID, and attaches it to the GCP credential
|
|
|
+func (g *GCPIntegration) PopulateGCPMetadata() {
|
|
|
+ var f credentialsFile
|
|
|
+
|
|
|
+ if err := json.Unmarshal(g.GCPKeyData, &f); err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ g.GCPProjectID = f.ProjectID
|
|
|
+ g.GCPSAEmail = f.ClientEmail
|
|
|
+}
|