Skip to content

Commit

Permalink
🐛 set kind and runtime for gcp assets platform (#1715)
Browse files Browse the repository at this point in the history
- set platform kind and runtime for gcp assets
- make sure platform name and title for gcp gke clusters matches v8
values

---------

Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Sep 13, 2023
1 parent bcc58df commit a529ccf
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions providers/gcp/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func Discover(runtime *plugin.Runtime) (*inventory.Inventory, error) {
},
Name: gcpProject.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-project",
Title: "GCP Project " + gcpProject.Name.Data,
Name: "gcp-project",
Title: "GCP Project " + gcpProject.Name.Data,
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)},
Expand All @@ -83,6 +85,9 @@ func Discover(runtime *plugin.Runtime) (*inventory.Inventory, error) {
if err != nil {
return nil, err
}
if len(in.Spec.Assets) > 0 {
in.Spec.Assets[0].RelatedAssets = list
}
in.Spec.Assets = append(in.Spec.Assets, list...)
} else if conn.ResourceType() == connection.Gcr {
conf := conn.Conf
Expand Down Expand Up @@ -133,8 +138,10 @@ func discoverOrganization(conn *connection.GcpConnection, gcpOrg *mqlGcpOrganiza
},
Name: project.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-project",
Title: "GCP Project " + project.Name.Data,
Name: "gcp-project",
Title: "GCP Project " + project.Name.Data,
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{projectConf}, // pass-in the parent connection config
Expand Down Expand Up @@ -181,8 +188,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: instance.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-compute-instance",
Title: "GCP Compute Instance",
Name: "gcp-compute-instance",
Title: "GCP Compute Instance",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: labels,
// TODO: the current connection handling does not work well for instances
Expand Down Expand Up @@ -212,8 +221,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: image.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-compute-image",
Title: "GCP Compute Image",
Name: "gcp-compute-image",
Title: "GCP Compute Image",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: labels,
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand All @@ -237,8 +248,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: network.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-compute-network",
Title: "GCP Compute Network",
Name: "gcp-compute-network",
Title: "GCP Compute Network",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand Down Expand Up @@ -266,8 +279,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: network.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-compute-subnetwork",
Title: "GCP Compute Subnetwork",
Name: "gcp-compute-subnetwork",
Title: "GCP Compute Subnetwork",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand All @@ -291,8 +306,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: firewall.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-compute-firewall",
Title: "GCP Compute Firewall",
Name: "gcp-compute-firewall",
Title: "GCP Compute Firewall",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand All @@ -316,8 +333,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: cluster.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-container-cluster",
Title: "GCP Container Cluster",
Name: "gcp-gke-cluster",
Title: "GCP GKE Cluster",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand All @@ -341,8 +360,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: bucket.Name.Data,
Platform: &inventory.Platform{
Name: "gcp-storage-bucket",
Title: "GCP Storage Bucket",
Name: "gcp-storage-bucket",
Title: "GCP Storage Bucket",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand All @@ -366,8 +387,10 @@ func discoverProject(conn *connection.GcpConnection, gcpProject *mqlGcpProject)
},
Name: dataset.Id.Data,
Platform: &inventory.Platform{
Name: "gcp-bigquery-dataset",
Title: "GCP BigQuery Dataset",
Name: "gcp-bigquery-dataset",
Title: "GCP BigQuery Dataset",
Runtime: "gcp",
Kind: "gcp-object",
},
Labels: map[string]string{},
Connections: []*inventory.Config{cloneConfig(conn.Conf)}, // pass-in the parent connection config
Expand Down

0 comments on commit a529ccf

Please sign in to comment.