-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration to remove explicit SDK dependencies for python and JS (#1092)
This adds a migration for providers to remove the explicit SDK dependencies for python and javascript. this should solve #1091 for tier 2+ providers I've tested this on pulumi-cloudflare and pulumi-random. I've also tested it doesn't do anything the second time around.
- Loading branch information
1 parent
1886199
commit 8a60afb
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,33 @@ function run(command: string): shell.ShellString { | |
// }; | ||
// } | ||
|
||
function removeExplicitSDKDependency(): SourceMigration { | ||
return { | ||
name: "Respect Schema Version", | ||
async execute(context) { | ||
const patchPath = fs.realpathSync("removeExplicitSDKdependency.patch"); | ||
shell.pushd(context.dir); | ||
try { | ||
// Apply patch | ||
run( | ||
`go run github.com/uber-go/[email protected] -p "${patchPath}" ./provider/resources.go` | ||
); | ||
// Format the code - twice to ensure that the code is formatted correctly | ||
run(`go install mvdan.cc/gofumpt@latest`); | ||
run(`gofumpt -w ./provider/resources.go`); | ||
run(`gofumpt -w ./provider/resources.go`); | ||
// Check if we've made changes | ||
const gitStatus = run(`git status --porcelain`).stdout; | ||
if (gitStatus.includes("provider/resources.go")) { | ||
run(`make tfgen build_sdks`); | ||
} | ||
} finally { | ||
shell.popd(); | ||
} | ||
}, | ||
}; | ||
} | ||
|
||
async function runMigrations( | ||
context: MigrateContext, | ||
migrations: SourceMigration[] | ||
|
@@ -110,7 +137,7 @@ async function runMigrations( | |
} | ||
|
||
function allMigrations(): SourceMigration[] { | ||
return []; | ||
return [removeExplicitSDKDependency()]; | ||
} | ||
|
||
async function main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@@ | ||
// JS: Remove explicit SDK dependency | ||
var tfbridge identifier | ||
@@ | ||
import tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" | ||
|
||
tfbridge.JavaScriptInfo{ | ||
..., | ||
Dependencies: map[string]string{ | ||
..., | ||
- "@pulumi/pulumi": "^3.0.0", | ||
..., | ||
}, | ||
..., | ||
} | ||
|
||
@@ | ||
// JS: Remove empty Dependencies | ||
var tfbridge identifier | ||
@@ | ||
import tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" | ||
|
||
tfbridge.JavaScriptInfo{ | ||
..., | ||
- Dependencies: map[string]string{}, | ||
..., | ||
} | ||
|
||
@@ | ||
// Py: Remove explicit SDK dependency | ||
var tfbridge identifier | ||
@@ | ||
import tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" | ||
|
||
tfbridge.PythonInfo{ | ||
..., | ||
Requires: map[string]string{ | ||
..., | ||
- "pulumi": ">=3.0.0,<4.0.0", | ||
..., | ||
}, | ||
..., | ||
} | ||
|
||
@@ | ||
// Py: Remove empty Requires | ||
var tfbridge identifier | ||
@@ | ||
import tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" | ||
|
||
tfbridge.PythonInfo{ | ||
..., | ||
- Requires: map[string]string{}, | ||
..., | ||
} |