Skip to content

Commit

Permalink
feat: Fix lint check for subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarl committed Sep 1, 2022
1 parent 3c0c3a1 commit 7faa84d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions postgresql/resource_postgresql_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func resourcePostgreSQLSubscriptionReadImpl(db *DBConnection, d *schema.Resource
var subExists bool
queryExists := "SELECT TRUE FROM pg_catalog.pg_stat_subscription WHERE subname = $1"
err = txn.QueryRow(queryExists, pqQuoteLiteral(subName)).Scan(&subExists)
if err != nil {
return fmt.Errorf("Failed to check subscription: %w", err)
}

if !subExists {
log.Printf("[WARN] PostgreSQL Subscription (%s) not found for database %s", subName, databaseName)
Expand Down Expand Up @@ -170,7 +173,7 @@ func resourcePostgreSQLSubscriptionReadImpl(db *DBConnection, d *schema.Resource
d.Set("database", databaseName)
d.SetId(generateSubscriptionID(d, databaseName))

createSlot, okCreate := d.GetOkExists("create_slot")
createSlot, okCreate := d.GetOkExists("create_slot") //nolint:staticcheck
if okCreate {
d.Set("create_slot", createSlot.(bool))
}
Expand Down Expand Up @@ -285,7 +288,7 @@ func getPublicationsForSubscription(d *schema.ResourceData) (string, error) {
return publicationsString, fmt.Errorf("'%s' is duplicated for attribute publications", elem.(string))
}
for _, p := range publications {
plist = append(plist, fmt.Sprintf(pq.QuoteIdentifier(p.(string))))
plist = append(plist, pq.QuoteIdentifier(p.(string)))
}

return strings.Join(plist, ", "), nil
Expand Down Expand Up @@ -337,8 +340,8 @@ func getOptionalParameters(d *schema.ResourceData) string {
parameterSQLTemplate := "WITH (%s)"
returnValue := ""

createSlot, okCreate := d.GetOkExists("create_slot")
slotName, okName := d.GetOkExists("slot_name")
createSlot, okCreate := d.GetOkExists("create_slot") //nolint:staticcheck
slotName, okName := d.GetOk("slot_name")

if !okCreate && !okName {
// use default behavior, no WITH statement
Expand Down

0 comments on commit 7faa84d

Please sign in to comment.