Skip to content

Commit

Permalink
add . to end of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
l0n3star committed Sep 25, 2024
1 parent 7d7a78a commit 6b32b38
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion internal/api/gsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type IndexDDLRequest struct {

// QueryError is the error message returned by query service.
type QueryError struct {
// Msg The error message
// Msg The error message.
Msg string `json:"msg"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/datasources/gsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (g *GsiDefinitions) Read(ctx context.Context, req datasource.ReadRequest, r
return
}

// data sources don't support Default
// https://github.com/hashicorp/terraform-plugin-framework/issues/751
// data sources don't support Default.
// https://github.com/hashicorp/terraform-plugin-framework/issues/751 .
var scope, collection string
if config.ScopeName.IsNull() {
scope = "_default"
Expand Down
8 changes: 4 additions & 4 deletions internal/datasources/gsi_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func (g *GsiMonitor) Read(ctx context.Context, req datasource.ReadRequest, resp
return
}

// data sources don't support Default
// https://github.com/hashicorp/terraform-plugin-framework/issues/751
// data sources don't support Default.
// https://github.com/hashicorp/terraform-plugin-framework/issues/751 .
var scope, collection string
if config.ScopeName.IsNull() {
scope = "_default"
Expand All @@ -112,7 +112,7 @@ func (g *GsiMonitor) Read(ctx context.Context, req datasource.ReadRequest, resp

cfg := api.EndpointCfg{Url: uri, Method: http.MethodGet, SuccessStatus: http.StatusOK}

// 60 min is arbitrary
// 60 min is arbitrary.
const timeout = time.Minute * 60

var cancel context.CancelFunc
Expand Down Expand Up @@ -186,7 +186,7 @@ func (g *GsiMonitor) Read(ctx context.Context, req datasource.ReadRequest, resp
}

attempt++
// exponential backoff upto a max of 20 min
// exponential backoff upto a max of 20 min.
d := min(20, 1<<attempt)
timer.Reset(time.Duration(d) * time.Minute)
}
Expand Down
16 changes: 8 additions & 8 deletions internal/resources/gsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (g *GSI) Create(ctx context.Context, req resource.CreateRequest, resp *reso

var ddl string

// create build index statement
// create build index statement.
if !plan.BuildIndexes.IsNull() {
ddl = fmt.Sprintf(
"BUILD INDEX ON `%s`.`%s`.`%s`(%s)",
Expand All @@ -65,7 +65,7 @@ func (g *GSI) Create(ctx context.Context, req resource.CreateRequest, resp *reso
listStringValues(plan.BuildIndexes),
)
} else {
// create primary index statement
// create primary index statement.
if plan.IsPrimary.ValueBool() {
var indexName string
if !plan.IndexName.IsNull() {
Expand All @@ -83,7 +83,7 @@ func (g *GSI) Create(ctx context.Context, req resource.CreateRequest, resp *reso
plan.With.NumReplica.ValueInt64(),
)
} else {
// create secondary index statement
// create secondary index statement.
ddl = fmt.Sprintf(
"CREATE INDEX `%s` ON `%s`.`%s`.`%s`(%s) ",
plan.IndexName.ValueString(),
Expand Down Expand Up @@ -111,7 +111,7 @@ func (g *GSI) Create(ctx context.Context, req resource.CreateRequest, resp *reso

ddl += withClause
} else {
// should not set num_partition for non-partitioned index
// should not set num_partition for non-partitioned index.
withClause := fmt.Sprintf(
" WITH { \"defer_build\": %t, \"num_replica\": %d} ",
plan.With.DeferBuild.ValueBool(),
Expand Down Expand Up @@ -187,11 +187,11 @@ func (g *GSI) Read(ctx context.Context, req resource.ReadRequest, resp *resource
}

if !state.OrganizationId.IsNull() {
// when reading an index, only update number of replicas
// when reading an index, only update number of replicas.
state.With.NumReplica = types.Int64Value(int64(index.NumReplica))

} else {
// when importing index, set all attributes
// when importing index, set all attributes.
state.OrganizationId = types.StringValue(organizationID)
state.ProjectId = types.StringValue(projectID)
state.ClusterId = types.StringValue(clusterID)
Expand All @@ -216,7 +216,7 @@ func (g *GSI) Read(ctx context.Context, req resource.ReadRequest, resp *resource
}

state.IndexKeys = keyList
// TODO: set partition by
// TODO: set partition by.
state.Where = types.StringValue(index.Where)
if state.With != nil {
state.With.NumReplica = types.Int64Value(int64(index.NumReplica))
Expand Down Expand Up @@ -470,7 +470,7 @@ func (g *GSI) getQueryIndex(
return &index, nil
}

// joins a list of strings
// joins a list of strings.
func listStringValues(s types.List) string {
elements := s.Elements()
var str string
Expand Down
8 changes: 4 additions & 4 deletions internal/schema/gsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type GsiData struct {
// IndexName is the name of the index.
IndexName types.String `tfsdk:"index_name"`

// Definition is the index definition
// Definition is the index definition.
Definition types.String `tfsdk:"definition"`
}

Expand Down Expand Up @@ -114,7 +114,7 @@ type GsiBuildStatus struct {
}

func (g *GsiDefinition) GetAttributeValues() (map[Attr]string, error) {
// handle terraform import
// handle terraform import.
if g.OrganizationId.IsNull() {
attrs, err := splitImportString(
g.IndexName.ValueString(),
Expand All @@ -132,7 +132,7 @@ func (g *GsiDefinition) GetAttributeValues() (map[Attr]string, error) {
return attrs, nil
}

// handle Read()
// handle Read().
attrs := map[Attr]string{
OrganizationId: g.OrganizationId.ValueString(),
ProjectId: g.ProjectId.ValueString(),
Expand All @@ -143,7 +143,7 @@ func (g *GsiDefinition) GetAttributeValues() (map[Attr]string, error) {
IndexName: "",
}
// if a primary index was created without a name,
// indexer uses name #primary
// indexer uses name #primary.
if !g.IsPrimary.IsNull() && g.IndexName.IsNull() {
attrs[IndexName] = "#primary"
} else {
Expand Down

0 comments on commit 6b32b38

Please sign in to comment.