Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmichalak committed Nov 21, 2024
1 parent e2b6918 commit 0ad833a
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 645 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,6 @@ provider "snowflake" {
}
```

## Currently deprecated resources
<!-- Section of deprecated resources -->

## Currently deprecated datasources
<!-- Section of deprecated data sources -->
3 changes: 2 additions & 1 deletion examples/additional/deprecated_datasources.MD
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## Currently deprecated datasources
<!-- Section of deprecated data sources -->


3 changes: 2 additions & 1 deletion examples/additional/deprecated_resources.MD
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## Currently deprecated resources
<!-- Section of deprecated resources -->


16 changes: 6 additions & 10 deletions pkg/internal/tools/doc-gen-helper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ func main() {
}
}

if len(deprecatedResources) > 0 {
err := printTo(DeprecatedResourcesTemplate, DeprecatedResourcesContext{deprecatedResources}, filepath.Join(additionalExamplesPath, deprecatedResourcesFilename))
if err != nil {
log.Println(err)
}
err := printTo(DeprecatedResourcesTemplate, DeprecatedResourcesContext{deprecatedResources}, filepath.Join(additionalExamplesPath, deprecatedResourcesFilename))
if err != nil {
log.Fatal(err)
}

if len(deprecatedDatasources) > 0 {
err := printTo(DeprecatedDatasourcesTemplate, DeprecatedDatasourcesContext{deprecatedDatasources}, filepath.Join(additionalExamplesPath, deprecatedDatasourcesFilename))
if err != nil {
log.Println(err)
}
err = printTo(DeprecatedDatasourcesTemplate, DeprecatedDatasourcesContext{deprecatedDatasources}, filepath.Join(additionalExamplesPath, deprecatedDatasourcesFilename))
if err != nil {
log.Fatal(err)
}
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/internal/tools/doc-gen-helper/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package main
import "text/template"

var DeprecatedResourcesTemplate, _ = template.New("deprecatedResourcesTemplate").Parse(
`## Currently deprecated resources
`<!-- Section of deprecated resources -->
{{if gt (len .Resources) 0}} ## Currently deprecated resources {{end}}
{{ range .Resources -}}
- {{ .NameRelativeLink }}{{ if .ReplacementRelativeLink }} - use {{ .ReplacementRelativeLink }} instead{{ end }}
{{ end -}}`,
)

var DeprecatedDatasourcesTemplate, _ = template.New("deprecatedDatasourcesTemplate").Parse(
`## Currently deprecated datasources
`<!-- Section of deprecated data sources -->
{{if gt (len .Datasources) 0}} ## Currently deprecated data sources {{end}}
{{ range .Datasources -}}
- {{ .NameRelativeLink }}{{ if .ReplacementRelativeLink }} - use {{ .ReplacementRelativeLink }} instead{{ end }}
Expand Down
7 changes: 3 additions & 4 deletions pkg/resources/database_state_upgraders.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ func v092DatabaseStateUpgrader(ctx context.Context, rawState map[string]any, met
}

if v, ok := rawState["from_share"]; ok && v != nil && len(v.(map[string]any)) > 0 {
// TODO: modify here?
return nil, fmt.Errorf("failed to upgrade the state with database created from share, please use snowflake_shared_database or deprecated snowflake_database_old instead")
return nil, fmt.Errorf("failed to upgrade the state with database created from share, please use snowflake_shared_database instead")
}

if v, ok := rawState["from_replica"]; ok && v != nil && len(v.(string)) > 0 {
return nil, fmt.Errorf("failed to upgrade the state with database created from replica, please use snowflake_secondary_database or deprecated snowflake_database_old instead")
return nil, fmt.Errorf("failed to upgrade the state with database created from replica, please use snowflake_secondary_database instead")
}

if v, ok := rawState["from_database"]; ok && v != nil && len(v.(string)) > 0 {
return nil, fmt.Errorf("failed to upgrade the state with database created from database, please use snowflake_database or deprecated snowflake_database_old instead. Dislaimer: Right now, database cloning is not supported. They can be imported into mentioned resources, but any differetnce in behavior from standard database won't be handled (and can result in errors)")
return nil, fmt.Errorf("failed to upgrade the state with database created from database, please use snowflake_database instead. Dislaimer: Right now, database cloning is not supported. They can be imported into the mentioned resource, but any differetnce in behavior from standard database won't be handled (and can result in errors)")
}

if replicationConfigurations, ok := rawState["replication_configuration"]; ok && len(replicationConfigurations.([]any)) == 1 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/manual_tests/upgrade_cloned_database/step_2.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Commands to run
# - terraform init - upgrade
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from database, please use snowflake_database or deprecated snowflake_database_old instead...)
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from database, please use snowflake_database instead...)
# - terraform state rm snowflake_database.cloned (remove cloned database from the state)

terraform {
Expand All @@ -15,12 +15,12 @@ terraform {
provider "snowflake" {}

resource "snowflake_database" "test" {
name = "test"
name = "test"
data_retention_time_in_days = 0 # to avoid in-place update to -1
}

resource "snowflake_database" "cloned" {
name = "cloned"
from_database = snowflake_database.test.name
name = "cloned"
from_database = snowflake_database.test.name
data_retention_time_in_days = 0 # to avoid in-place update to -1
}
14 changes: 7 additions & 7 deletions pkg/resources/manual_tests/upgrade_secondary_database/step_2.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Commands to run
# - terraform init - upgrade
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from replica, please use snowflake_secondary_database or deprecated snowflake_database_old instead)
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from replica, please use snowflake_secondary_database instead)
# - terraform state rm snowflake_database.secondary (remove secondary database from the state)

terraform {
Expand All @@ -16,12 +16,12 @@ provider "snowflake" {}

provider "snowflake" {
profile = "secondary_test_account"
alias = second_account
alias = second_account
}

resource "snowflake_database" "primary" {
provider = snowflake.second_account
name = "test"
provider = snowflake.second_account
name = "test"
data_retention_time_in_days = 0 # to avoid in-place update to -1
replication_configuration {
accounts = ["<second_account_account_locator>"] # TODO: Replace
Expand All @@ -30,7 +30,7 @@ resource "snowflake_database" "primary" {
}

resource "snowflake_database" "secondary" {
name = "test"
data_retention_time_in_days = 0 # to avoid in-place update to -1
from_replica = "<second_account_account_locator>.\"${snowflake_database.primary.name}\"" # TODO: Replace
name = "test"
data_retention_time_in_days = 0 # to avoid in-place update to -1
from_replica = "<second_account_account_locator>.\"${snowflake_database.primary.name}\"" # TODO: Replace
}
3 changes: 1 addition & 2 deletions pkg/resources/manual_tests/upgrade_shared_database/step_2.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO: check if we can omit deprecated objects in migration upgraders
# Commands to run
# - terraform init - upgrade
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from share, please use snowflake_shared_database or deprecated snowflake_database_old instead)
# - terraform plan (should observe upgrader errors similar to: failed to upgrade the state with database created from share, please use snowflake_shared_database instead)
# - terraform state rm snowflake_database.from_share (remove shared database from the state)

terraform {
Expand Down
165 changes: 0 additions & 165 deletions pkg/snowflake/external_oauth_integration.go

This file was deleted.

Loading

0 comments on commit 0ad833a

Please sign in to comment.