Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add table gcp_project_organization_policy. closes #186 #204

Merged
merged 8 commits into from
Jun 21, 2021
Merged

Conversation

Priyanka585464
Copy link
Contributor

Integration test logs

Logs
SETUP: tests/gcp_projects_organization_policy []

PRETEST: tests/gcp_projects_organization_policy

TEST: tests/gcp_projects_organization_policy
Running terraform
data.google_client_config.current: Refreshing state...
data.null_data_source.resource: Refreshing state...
google_project_organization_policy.named_test_resource: Creating...
google_project_organization_policy.named_test_resource: Creation complete after 3s [id=pikachu-aaa:serviceuser.services]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

project_aka = gcp://cloudresourcemanager.googleapis.com/projects/pikachu-aaa
project_id = pikachu-aaa
resource_id = serviceuser.services
resource_name = turbottest73472
resource_title = constraints/serviceuser.services

Running SQL query: test-get-query.sql
[
  {
    "akas": [
      "gcp://cloudresourcemanager.googleapis.com/projects/pikachu-aaa"
    ],
    "project": "pikachu-aaa",
    "title": "constraints/serviceuser.services"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "akas": [
      "gcp://cloudresourcemanager.googleapis.com/projects/pikachu-aaa"
    ],
    "location": "global",
    "project": "pikachu-aaa",
    "title": "constraints/serviceuser.services"
  }
]
✔ PASSED

Running SQL query: test-notfound-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "gcp://cloudresourcemanager.googleapis.com/projects/pikachu-aaa"
    ],
    "title": "constraints/serviceuser.services"
  }
]
✔ PASSED

POSTTEST: tests/gcp_projects_organization_policy

TEARDOWN: tests/gcp_projects_organization_policy

SUMMARY:

1/1 passed.

Example query results

Results
### Basic info

```sql
select
  *
from
  gcp_projects_organization_policy;
+----------------------------------------+---------------------+---------+--------------+-----------------------+----------------+-----------------+----------------------------------------------------+---
| id                                     | update_time         | version | etag         | list_policy           | boolean_policy | restore_default | title                                              | ak
+----------------------------------------+---------------------+---------+--------------+-----------------------+----------------+-----------------+----------------------------------------------------+---
| run.allowedBinaryAuthorizationPolicies | 2021-05-13 06:25:19 | 0       | BwXCMDD86pE= | {"allValues":"ALLOW"} | <null>         | <null>          | constraints/run.allowedBinaryAuthorizationPolicies | ["
+----------------------------------------+---------------------+---------+--------------+-----------------------+----------------+-----------------+----------------------------------------------------+---

Check policy's previously updated time by server

select
  id,
  version,
  update_time
from
  gcp_projects_organization_policy,
+----------------------------------------+---------+---------------------+
| id                                     | version | update_time         |
+----------------------------------------+---------+---------------------+
| run.allowedBinaryAuthorizationPolicies | 0       | 2021-05-13 06:25:19 |
+----------------------------------------+---------+---------------------+

Check the policy values given to constraint.

select
  id,
  version,
  list_policy ->> 'allValues' as policy_value
from
  gcp_projects_organization_policy;
+----------------------------------------+---------+--------------+
| id                                     | version | policy_value |
+----------------------------------------+---------+--------------+
| run.allowedBinaryAuthorizationPolicies | 0       | ALLOW        |
+----------------------------------------+---------+--------------+

@Priyanka585464 Priyanka585464 self-assigned this May 14, 2021
@Priyanka585464 Priyanka585464 linked an issue May 14, 2021 that may be closed by this pull request
@cbruno10 cbruno10 requested a review from Subhajit97 May 19, 2021 21:05
gcp/plugin.go Outdated Show resolved Hide resolved

```sql
select
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we query specific columns, instead of *?


//// TABLE DEFINITION

func tableGcpProjectsOrganizationPolicy(ctx context.Context) *plugin.Table {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func tableGcpProjectsOrganizationPolicy(ctx context.Context) *plugin.Table {
func tableGcpProjectOrganizationPolicy(ctx context.Context) *plugin.Table {

return nil, err
}
project := projectData.Project
plugin.Logger(ctx).Trace("listGcpProjectOrganizationPolicies", "GCP_PROJECT: ", project)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
plugin.Logger(ctx).Trace("listGcpProjectOrganizationPolicies", "GCP_PROJECT: ", project)

project := projectData.Project

// Get the resource title
title := strings.ToUpper(project) + " Org Policy"
Copy link
Contributor

@Subhajit97 Subhajit97 May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Priyanka585464 Is this title required?
You are not using this title value anywhere.
Currently the title is using constraint value
https://github.com/turbot/steampipe-plugin-gcp/pull/204/files#diff-90f64bc506bbef72770fec8f8ca390942b03e818c0b89357a21e3517f02b28b8R70


variable "gcp_project" {
type = string
default = "pikachu-aaa"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default = "pikachu-aaa"
default = "niteowl-aaa"

Copy link
Contributor

@Subhajit97 Subhajit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Priyanka585464 There are few more changes required. Please see comments, thanks!

Copy link
Contributor

@Subhajit97 Subhajit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@rajlearner17 rajlearner17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbruno10 cbruno10 merged commit 0fd3693 into main Jun 21, 2021
@cbruno10 cbruno10 deleted the issue-186 branch June 21, 2021 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add table gcp_project_organization_policy
4 participants