Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Add table turbot_policy_value closes #14 #31

Merged
merged 11 commits into from
Jan 27, 2022
Merged

Add table turbot_policy_value closes #14 #31

merged 11 commits into from
Jan 27, 2022

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Jan 6, 2022

Example query results

Results
> select
  id,
  state,
  is_default,
  is_calculated,
  policy_type_id,
  policy_value_type_mod_uri
from
  turbot_policy_value
where
  policy_type_id = 190630193572596;
+-----------------+-------+------------+---------------+-----------------+---------------------------+
| id              | state | is_default | is_calculated | policy_type_id  | policy_value_type_mod_uri |
+-----------------+-------+------------+---------------+-----------------+---------------------------+
| 243392852690564 | ok    | true       | false         | 190630193572596 | tmod:@turbot/gcp-iam      |
| 243392852612714 | ok    | true       | false         | 190630193572596 | tmod:@turbot/gcp-iam      |
| 197439793364380 | ok    | true       | false         | 190630193572596 | tmod:@turbot/gcp-iam      |
+-----------------+-------+------------+---------------+-----------------+---------------------------+
> select
  id,
  state,
  is_default,
  is_calculated,
  resource_id,
  policy_value_type_mod_uri
from
  turbot_policy_value
where
  resource_id = 243392852451917;
+-----------------+-------+------------+---------------+-----------------+---------------------------+
| id              | state | is_default | is_calculated | resource_id     | policy_value_type_mod_uri |
+-----------------+-------+------------+---------------+-----------------+---------------------------+
| 243392852558428 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-iam      |
| 243392852610665 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-cisv1    |
| 243392852586083 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-iam      |
| 243392852612714 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-iam      |
| 243392852590180 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-iam      |
| 243392852597350 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-cisv1    |
| 243392852602472 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-cisv1    |
| 243392852576866 | ok    | true       | false         | 243392852451917 | tmod:@turbot/gcp-iam      |
+-----------------+-------+------------+---------------+-----------------+---------------------------+
> select
  id,
  state,
  is_default,
  is_calculated,
  resource_type_id,
  policy_value_type_mod_uri
from
  turbot_policy_value
where
  resource_type_id = 190630180698932;
+-----------------+-------+------------+---------------+------------------+---------------------------+
| id              | state | is_default | is_calculated | resource_type_id | policy_value_type_mod_uri |
+-----------------+-------+------------+---------------+------------------+---------------------------+
| 243392852686466 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852586083 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852690564 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852688515 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852576866 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852558428 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852610665 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852646514 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 197439793404331 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852612714 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852674176 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 197439793401256 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852665974 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852590180 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 197439793397157 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 243392852670072 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852602472 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 197439793357209 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852660851 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 243392852597350 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-cisv1    |
| 197439793364380 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 197439793371551 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 197439793393058 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
| 197439793345941 | ok    | true       | false         | 190630180698932  | tmod:@turbot/gcp-iam      |
+-----------------+-------+------------+---------------+------------------+---------------------------+

@ParthaI ParthaI self-assigned this Jan 6, 2022
@ParthaI ParthaI linked an issue Jan 6, 2022 that may be closed by this pull request
@rajlearner17 rajlearner17 requested review from rajlearner17 and removed request for misraved January 24, 2022 10:09
Copy link
Contributor

@cbruno10 cbruno10 left a comment

Choose a reason for hiding this comment

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

@ParthaI Please see comments, thanks!

@@ -0,0 +1,93 @@
# Table: turbot_resource
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
# Table: turbot_resource
# Table: turbot_policy_value

@@ -0,0 +1,93 @@
# Table: turbot_resource

Resources in Turbot represent cloud configuration items such as users,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the wrong description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the description.

Resources in Turbot represent cloud configuration items such as users,
networks, servers, etc.

It is recommended that queries to this table should include (usually in the `where` clause) at least one
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is relevant to this table?

It is recommended that queries to this table should include (usually in the `where` clause) at least one
of these columns: `id`, `resource_type_id`, `resource_type_uri` or `filter`.

A Policy Value is the effective policy setting on an instance of a resource type. Every resource that is targeted by a given policy setting will have its own value for that policy, which will be the resultant calculated policy for the "winning" policy in the hierarchy.
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
A Policy Value is the effective policy setting on an instance of a resource type. Every resource that is targeted by a given policy setting will have its own value for that policy, which will be the resultant calculated policy for the "winning" policy in the hierarchy.
A policy value is the effective policy setting on an instance of a resource type. Every resource that is targeted by a given policy setting will have its own value for that policy, which will be the resultant calculated policy for the "winning" policy in the hierarchy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


## Examples

### List policy values by policy type id
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
### List policy values by policy type id
### List policy values by policy type ID

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

filter = 'policyTypeId:123456789';
```

### Extract all policy values from Turbot
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe we should include this example - policy values are set for every policy type on every applicable resource. I find it extremely rare that I'd want to see all policy values (policy settings or resources make more sense).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this example

docs/tables/turbot_policy_value.md Show resolved Hide resolved
turbot/table_turbot_policy_value.go Show resolved Hide resolved
{Name: "policy_type_title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Type.Title"), Description: "Title of the policy type."},
{Name: "poliy_type_trunk_title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Type.Trunk.Title"), Description: "Title with full path of the policy type."},
{Name: "is_default", Type: proto.ColumnType_BOOL, Transform: transform.FromField("Default"), Description: "Defines the policy value is default or not."},
{Name: "is_calculated", Type: proto.ColumnType_BOOL, Description: "True if this is a policy setting will be calculated for each value."},
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to is_default, and other columns in this table, the description does not have correct grammar, what description does our GraphQL API have?

Copy link
Contributor Author

@ParthaI ParthaI Jan 27, 2022

Choose a reason for hiding this comment

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

The description for is_calculated is If true this value is derived from calculated setting inputs e.g. templateInput and template. in GraphQL API.

Similarly for is_default it is If true this value is derived from the default value of the type.

Copy link
Contributor

@cbruno10 cbruno10 Jan 27, 2022

Choose a reason for hiding this comment

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

@ParthaI Let's copy those descriptions, they read OK in a description context here, and being able to re-use them is an easy way to get accurate, grammatically correct descriptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the description for is_default and is_calculated columns

{Name: "id", Type: proto.ColumnType_INT, Transform: transform.FromField("Turbot.ID"), Description: "Unique identifier of the policy value."},
{Name: "policy_type_title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Type.Title"), Description: "Title of the policy type."},
{Name: "poliy_type_trunk_title", Type: proto.ColumnType_STRING, Transform: transform.FromField("Type.Trunk.Title"), Description: "Title with full path of the policy type."},
{Name: "is_default", Type: proto.ColumnType_BOOL, Transform: transform.FromField("Default"), Description: "Defines the policy value is default or not."},
Copy link
Contributor

Choose a reason for hiding this comment

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

This description does not have correct grammar, what description does our GraphQL API have?

@cbruno10 cbruno10 merged commit 7845880 into main Jan 27, 2022
@cbruno10 cbruno10 deleted the issue-14 branch January 27, 2022 13:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add table turbot_policy_value
2 participants