-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ee5cef
commit 6ac7f91
Showing
7 changed files
with
81 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,83 @@ | ||
package google | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
|
||
func (t *Provider) Identifier() (string, error) { | ||
switch t.ResourceType() { | ||
"go.mondoo.com/cnquery/motor/platform" | ||
"go.mondoo.com/cnquery/motor/providers" | ||
) | ||
|
||
func (p *Provider) Identifier() (string, error) { | ||
switch p.resourceType { | ||
case Project: | ||
return "//platformid.api.mondoo.app/runtime/gcp/projects/" + t.id, nil | ||
return "//platformid.api.mondoo.app/runtime/gcp/projects/" + p.id, nil | ||
case Workspace: | ||
return "//platformid.api.mondoo.app/runtime/googleworkspace/customer/" + t.id, nil | ||
return "//platformid.api.mondoo.app/runtime/googleworkspace/customer/" + p.id, nil | ||
default: | ||
return "", errors.New("unsupported resource type") | ||
} | ||
} | ||
|
||
func (t *Provider) ResourceType() ResourceType { | ||
return t.resourceType | ||
func (p *Provider) ResourceType() ResourceType { | ||
return p.resourceType | ||
} | ||
|
||
func (p *Provider) ResourceID() string { | ||
return p.id | ||
} | ||
|
||
func (p *Provider) PlatformInfo() (*platform.Platform, error) { | ||
// TODO: this is a hack and we need to find a better way to do this | ||
if p.platformOverride != "" && p.platformOverride != "gcp" && p.platformOverride != "google-workspace" { | ||
return &platform.Platform{ | ||
Name: p.platformOverride, | ||
Title: getTitleForPlatformName(p.platformOverride), | ||
Family: []string{"google"}, | ||
Kind: providers.Kind_KIND_GCP_OBJECT, | ||
Runtime: providers.RUNTIME_GCP, | ||
}, nil | ||
} | ||
|
||
switch p.resourceType { | ||
case Project: | ||
return &platform.Platform{ | ||
Name: "gcp", | ||
Title: "Google Cloud Platform", | ||
Family: []string{"google"}, | ||
Kind: providers.Kind_KIND_GCP_OBJECT, | ||
Runtime: p.Runtime(), | ||
}, nil | ||
case Workspace: | ||
return &platform.Platform{ | ||
Name: "google-workspace", | ||
Title: "Google Workspace", | ||
Family: []string{"google"}, | ||
Kind: providers.Kind_KIND_API, | ||
Runtime: p.Runtime(), | ||
}, nil | ||
} | ||
|
||
return nil, errors.New("unsupported resource type") | ||
} | ||
|
||
func (t *Provider) ResourceID() string { | ||
return t.id | ||
func getTitleForPlatformName(name string) string { | ||
switch name { | ||
case "gcp-project": | ||
return "GCP Project" | ||
case "gcp-compute-image": | ||
return "GCP Compute Image" | ||
case "gcp-compute-network": | ||
return "GCP Compute Network" | ||
case "gcp-compute-subnetwork": | ||
return "GCP Compute Subnetwork" | ||
case "gcp-compute-firewall": | ||
return "GCP Compute Firewall" | ||
case "gcp-gke-cluster": | ||
return "GCP GKE Cluster" | ||
case "gcp-storage-bucket": | ||
return "GCP Storage Bucket" | ||
case "gcp-bigquery-dataset": | ||
return "GCP BigQuery Dataset" | ||
} | ||
return "Google Cloud Platform" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters