Skip to content

Commit

Permalink
chore(): refactor resource docs
Browse files Browse the repository at this point in the history
  • Loading branch information
newtonnthiga committed Apr 26, 2024
1 parent bd0e4e5 commit 6eb9fbc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 52 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.1-alpha3 (Unreleased)

CHANGES:
- Update resources documentation

## 0.0.1-alpha1 (Unreleased)

FEATURES:
Expand Down
6 changes: 4 additions & 2 deletions internal/bigtable/google_bigtable_table_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ func (r *tableResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
Description: "The name of the Bigtable instance.",
},
"deletion_protection": schema.BoolAttribute{
Required: true,
Description: "A field to make the table protected against data loss i.e. when set to PROTECTED, deleting the table, the column families in the table, and the instance containing the table would be prohibited. If not provided, currently deletion protection will be set to UNPROTECTED as it is the API default value.",
Required: true,
Description: "A field to make the table protected against data loss i.e. when set to `PROTECTED`, deleting the table,\n" +
"the column families in the table, and the instance containing the table would be prohibited.\n" +
"If not provided, currently deletion protection will be set to `UNPROTECTED` as it is the API default value.",
},
"change_stream_retention": schema.StringAttribute{
Optional: true,
Expand Down
31 changes: 14 additions & 17 deletions internal/spanner/google_spanner_database_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ func (r *spannerDatabaseResource) Schema(_ context.Context, _ resource.SchemaReq
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile(`^[a-z][a-z0-9_\-]*[a-z0-9]$`), "Name must be a valid Spanner Database ID"),
},
Description: `A unique identifier for the database, which cannot be changed after
the instance is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].`,
Description: "A unique identifier for the database, which cannot be changed after\n" +
"the instance is created. Values are of the form `[a-z][-a-z0-9]*[a-z0-9]`.",
},
"project": schema.StringAttribute{
Required: true,
Description: `The Google Cloud project ID.`,
Description: "The Google Cloud project ID.",
},
"instance": schema.StringAttribute{
Required: true,
Description: `The Spanner instance ID.`,
Description: "The Spanner instance ID.",
},
"dialect": schema.StringAttribute{
Optional: true,
Expand All @@ -108,23 +108,23 @@ func (r *spannerDatabaseResource) Schema(_ context.Context, _ resource.SchemaReq
stringplanmodifier.RequiresReplace(),
stringplanmodifier.UseStateForUnknown(),
},
Description: `The dialect of the Cloud Spanner Database.
If it is not provided, "GOOGLE_STANDARD_SQL" will be used. Possible values: ["GOOGLE_STANDARD_SQL", "POSTGRESQL"]`,
Description: "The dialect of the Cloud Spanner Database.\n" +
"If it is not provided, `GOOGLE_STANDARD_SQL` will be used. Possible values: [`GOOGLE_STANDARD_SQL`, `POSTGRESQL`]",
},
"enable_drop_protection": schema.BoolAttribute{
Optional: true,
Description: `Whether drop protection is enabled for this database. Defaults to false.`,
Description: "Whether drop protection is enabled for this database. Defaults to false.",
},
"encryption_config": schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"kms_key_name": schema.StringAttribute{
Required: true,
Description: `Fully qualified name of the KMS key to use to encrypt this database. This key must exist
in the same location as the Spanner Database.`,
Description: "Fully qualified name of the KMS key to use to encrypt this database. This key must exist\n" +
"in the same location as the Spanner Database.",
},
},
Description: `Encryption configuration for the database`,
Description: "Encryption configuration for the database",
},
"version_retention_period": schema.StringAttribute{
Optional: true,
Expand All @@ -136,22 +136,19 @@ func (r *spannerDatabaseResource) Schema(_ context.Context, _ resource.SchemaReq
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
Description: `The retention period for the database. The retention period must be between 1 hour
and 7 days, and can be specified in days, hours, minutes, or seconds. For example,
the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h.
If this property is used, you must avoid adding new DDL statements to 'ddl' that
update the database's version_retention_period.`,
Description: "The retention period for the database. The retention period must be between 1 hour\n" +
"and 7 days, and must be specified in seconds. For example, 86400s is equivalent to 1 day.",
},
"state": schema.StringAttribute{
Computed: true,
Description: `An explanation of the status of the database.`,
Description: "An explanation of the status of the database.",
},
"create_time": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Description: `The time at which the database was created.`,
Description: "The time at which the database was created.",
},
"earliest_version_time": schema.StringAttribute{
Computed: true,
Expand Down
66 changes: 33 additions & 33 deletions internal/spanner/google_spanner_table_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ func (r *spannerTableResource) Schema(_ context.Context, _ resource.SchemaReques
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Required: true,
Description: `The name of the table.
The name must satisfy the expression ^[a-zA-Z0-9_-]{1,50}$`,
Description: "The name of the table.\n" +
"The name must satisfy the expression `^[a-zA-Z0-9_-]{1,50}$`",
},
"project": schema.StringAttribute{
Required: true,
Description: `The Google Cloud project ID in which the table belongs.`,
Description: "The Google Cloud project ID in which the table belongs.",
},
"instance": schema.StringAttribute{
Required: true,
Description: "The name of the Spanner instance.",
},
"database": schema.StringAttribute{
Required: true,
Description: `The name of the parent database.`,
Description: "The name of the parent database.",
},
"schema": schema.SingleNestedAttribute{
Required: true,
Expand All @@ -130,61 +130,61 @@ func (r *spannerTableResource) Schema(_ context.Context, _ resource.SchemaReques
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Required: true,
Description: `The name of the column.
The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter and not end in an underscore.
The maximum length is 128 characters.`,
Description: "The name of the column.\n" +
"The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter and not end in an underscore.\n" +
"The maximum length is 128 characters.",
},
"is_primary_key": schema.BoolAttribute{
Optional: true,
Description: `Indicates if the column is part of the primary key.
Multiple columns can be specified as primary keys to create a composite primary key.
Primary key columns must be non-null.`,
Description: "Indicates if the column is part of the primary key.\n" +
"Multiple columns can be specified as primary keys to create a composite primary key.\n" +
"Primary key columns must be non-null.",
},
"auto_increment": schema.BoolAttribute{
Optional: true,
Description: `Indicates if the column is auto-incrementing.
The column must be of type INT64 or FLOAT64.`,
Description: "Indicates if the column is auto-incrementing.\n" +
"The column must be of type `INT64` or `FLOAT64`.",
},
"unique": schema.BoolAttribute{
Optional: true,
Description: `Indicates if the column is unique.`,
Description: "Indicates if the column is unique.",
},
"type": schema.StringAttribute{
Required: true,
Validators: []validator.String{
stringvalidator.OneOf(services.SpannerTableDataTypes...),
},
Description: `The data type of the column.
Valid types are: BOOL, INT64, FLOAT64, STRING, BYTES, DATE, TIMESTAMP, JSON.`,
Description: "The data type of the column.\n" +
"Valid types are: `BOOL`, `INT64`, `FLOAT64`, `STRING`, `BYTES`, `DATE`, `TIMESTAMP`, `JSON`.",
},
"size": schema.Int64Attribute{
Optional: true,
Description: `The maximum size of the column.`,
Description: "The maximum size of the column.",
},
"precision": schema.Int64Attribute{
Optional: true,
Description: `The maximum number of digits in the column.
This is only applicable to columns of type FLOAT64.
The maximum is 17`,
Description: "The maximum number of digits in the column.\n" +
"This is only applicable to columns of type `FLOAT64`.\n" +
"The maximum is 17",
},
"scale": schema.Int64Attribute{
Optional: true,
Description: `The maximum number of digits after the decimal point in the column.
This is only applicable to columns of type FLOAT64.`,
Description: "The maximum number of digits after the decimal point in the column.\n" +
"This is only applicable to columns of type `FLOAT64`.",
},
"required": schema.BoolAttribute{
Optional: true,
Description: `Indicates if the column is required.`,
Description: "Indicates if the column is required.",
},
"default_value": schema.StringAttribute{
Optional: true,
Description: `The default value of the column.
The default value must be compatible with the column type.
For example, a default value of "true" is valid for a BOOL or STRING column, but not for an INT64 column.`,
Description: "The default value of the column.\n" +
"The default value must be compatible with the column type.\n" +
"For example, a default value of \"true\" is valid for a `BOOL` or `STRING` column, but not for an `INT64` column.",
},
},
},
Description: `The columns of the table.`,
Description: "The columns of the table.",
},
"indices": schema.ListNestedAttribute{
Optional: true,
Expand All @@ -197,25 +197,25 @@ func (r *spannerTableResource) Schema(_ context.Context, _ resource.SchemaReques
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Required: true,
Description: `The name of the index.
The name must contain only letters (a-z, A-Z), numbers (0-9), or hyphens (-), and must start with a letter and not end in a hyphen.`,
Description: "The name of the index.\n" +
"The name must contain only letters (a-z, A-Z), numbers (0-9), or hyphens (-), and must start with a letter and not end in a hyphen.",
},
"columns": schema.SetAttribute{
Required: true,
ElementType: types.StringType,
Description: `The columns that make up the index.
The order of the columns is significant.`,
Description: "The columns that make up the index.\n" +
"The order of the columns is significant.",
},
"unique": schema.BoolAttribute{
Optional: true,
Description: `Indicates if the index is unique.`,
Description: "Indicates if the index is unique.",
},
},
},
Description: `The indices/indexes of the table.`,
Description: "The indices/indexes of the table.",
},
},
Description: `The schema of the table.`,
Description: "The schema of the table.",
},
},
}
Expand Down

0 comments on commit 6eb9fbc

Please sign in to comment.