Skip to content

Commit

Permalink
Renamed Database to table everywhere
Browse files Browse the repository at this point in the history
Renamed ApprovalItem to ReferenceItem
  • Loading branch information
Andrei-Predoiu committed Sep 26, 2022
1 parent b533d70 commit 4b95af6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func extractRowValue(rm json.RawMessage) (string, error) {
if err == nil {
return str, nil
} else {
var ai models.ApprovalItem
var ai models.ReferenceItem
err = json.Unmarshal(rm, &ai)
if err != nil {
return "", errors.New(fmt.Sprintf("Unmarshal exploded for result.%v", rm))
Expand Down
6 changes: 3 additions & 3 deletions internal/datasource/data_source_database_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
)

func DatabaseRowDatasource() *schema.Resource {
func TableRowDatasource() *schema.Resource {
return &schema.Resource{
Schema: *models.MergeSchema(models.DefaultSystemColumns, map[string]*schema.Schema{
"sys_id": {
Expand All @@ -27,13 +27,13 @@ func DatabaseRowDatasource() *schema.Resource {
Type: schema.TypeString},
},
}),
ReadContext: DatabaseRowRead,
ReadContext: TableRowRead,
Description: "A row in a SN table",
UseJSONNumber: false,
}
}

func DatabaseRowRead(_ context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics {
func TableRowRead(_ context.Context, data *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*client.Client)
var tableID, sysID string
var err error
Expand Down
2 changes: 1 addition & 1 deletion internal/models/sn_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var DefaultSystemColumns = map[string]*schema.Schema{"table_id": {
Computed: true,
}}

type ApprovalItem struct {
type ReferenceItem struct {
Link string `json:"link"`
Value string `json:"value"`
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func ServiceNowDataProvider() *schema.Provider {
},

ResourcesMap: map[string]*schema.Resource{
resource.DatabaseRowResourceName: resource.DatabaseRowResource(),
resource.TableRowResourceName: resource.TableRowResource(),
},
DataSourcesMap: map[string]*schema.Resource{
resource.DatabaseRowResourceName: datasource.DatabaseRowDatasource(),
resource.TableRowResourceName: datasource.TableRowDatasource(),
},
ConfigureContextFunc: providerConfigure,
}
Expand Down
18 changes: 9 additions & 9 deletions internal/resource/resource_database_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"time"
)

const DatabaseRowResourceName = "servicenow-data_table_row"
const TableRowResourceName = "servicenow-data_table_row"

func DatabaseRowResource() *schema.Resource {
func TableRowResource() *schema.Resource {
return &schema.Resource{
CreateContext: databaseRowCreate,
ReadContext: datasource.DatabaseRowRead,
UpdateContext: databaseRowUpdate,
DeleteContext: databaseRowDelete,
CreateContext: tableRowCreate,
ReadContext: datasource.TableRowRead,
UpdateContext: tableRowUpdate,
DeleteContext: tableRowDelete,
Schema: *models.MergeSchema(models.DefaultSystemColumns, map[string]*schema.Schema{
"sys_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -53,7 +53,7 @@ func DatabaseRowResource() *schema.Resource {
}
}

func databaseRowCreate(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
func tableRowCreate(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*client.Client)
// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
Expand Down Expand Up @@ -81,7 +81,7 @@ func databaseRowCreate(_ context.Context, d *schema.ResourceData, m interface{})
return diags
}

func databaseRowUpdate(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
func tableRowUpdate(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*client.Client)
var tableID, sysID string
// Warning or errors can be collected in a slice type
Expand Down Expand Up @@ -118,7 +118,7 @@ func databaseRowUpdate(_ context.Context, d *schema.ResourceData, m interface{})
return diags
}

func databaseRowDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
func tableRowDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*client.Client)
// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
Expand Down

0 comments on commit 4b95af6

Please sign in to comment.