Skip to content

Commit

Permalink
use new plugin download url format
Browse files Browse the repository at this point in the history
  • Loading branch information
henriiik committed Jul 7, 2022
1 parent 177cc67 commit 45b3305
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 142 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ build_nodejs:: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs:: install_plugins tfgen # build the node sdk
$(WORKING_DIR)/bin/$(TFGEN) nodejs --overlays provider/overlays/nodejs --out sdk/nodejs/
cd sdk/nodejs/ && \
sed -i '' -e 's/download\/$${VERSION}/download\/v$${VERSION}/g' ./scripts/install-pulumi-plugin.js # Remove this hotfix when issue is resolved https://github.com/pulumi/pulumi/issues/9606 && \
yarn install && \
yarn install && \
yarn run tsc && \
cp -R scripts/ bin && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ It is based on the sentry terraform provider https://registry.terraform.io/provi
If you get an error like this:

```
error: could not load plugin for sentry provider 'urn:pulumi:bcx-dev::sandbox::pulumi:providers:sentry::sentry': no resource plugin 'pulumi-resource-sentry' found in the workspace at version vX.Y.Z or on your $PATH, install the plugin using `pulumi plugin install resource sentry vX.Y.Z`
error: could not load plugin for sentry provider 'urn:pulumi:my-stack::my-project::pulumi:providers:sentry::my-provider': no resource plugin 'pulumi-resource-sentry' found in the workspace at version vX.Y.Z or on your $PATH, install the plugin using `pulumi plugin install resource sentry vX.Y.Z`
```

You can use this command to install the missing version:

```
VERSION=vX.Y.Z; pulumi plugin install resource sentry $VERSION --server https://github.com/pulumiverse/pulumi-sentry/releases/download/$VERSION
pulumi plugin install resource sentry vX.Y.Z --server github://api.github.com/pulumiverse
```

This package is available for several languages/platforms:
Expand Down
12 changes: 6 additions & 6 deletions provider/cmd/pulumi-resource-sentry/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"attribution": "This Pulumi package is based on the [`sentry` Terraform Provider](https://github.com/jianyuan/terraform-provider-sentry).",
"repository": "https://github.com/pulumiverse/pulumi-sentry",
"logoUrl": "https://raw.githubusercontent.com/pulumiverse/.github/main/assets/mascot.png",
"pluginDownloadURL": "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
"pluginDownloadURL": "github://api.github.com/pulumiverse",
"publisher": "Pulumiverse",
"meta": {
"moduleFormat": "(.*)(?:/[^/]*)"
Expand All @@ -32,19 +32,19 @@
"importBasePath": "github.com/pulumiverse/pulumi-sentry/sdk/go/sentry"
},
"nodejs": {
"packageName": "@pulumiverse/sentry",
"packageDescription": "A Pulumi package for creating and managing Sentry resources.",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/jianyuan/terraform-provider-sentry)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi/pulumi-sentry` repo](https://github.com/pulumi/pulumi-sentry/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`jianyuan/terraform-provider-sentry` repo](https://github.com/jianyuan/terraform-provider-sentry/issues).",
"compatibility": "tfbridge20",
"dependencies": {
"@pulumi/pulumi": "^3.0.0"
},
"devDependencies": {
"@types/mime": "^2.0.0",
"@types/node": "^10.0.0"
},
"compatibility": "tfbridge20",
"disableUnionOutputTypes": true,
"pluginName": "sentry"
"packageDescription": "A Pulumi package for creating and managing Sentry resources.",
"packageName": "@pulumiverse/sentry",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/jianyuan/terraform-provider-sentry)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi/pulumi-sentry` repo](https://github.com/pulumi/pulumi-sentry/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`jianyuan/terraform-provider-sentry` repo](https://github.com/jianyuan/terraform-provider-sentry/issues).",
"typescriptVersion": ""
},
"python": {
"compatibility": "tfbridge20",
Expand Down
107 changes: 1 addition & 106 deletions provider/cmd/pulumi-tfgen-sentry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,117 +15,12 @@
package main

import (
"encoding/json"
"errors"
"io/ioutil"
"log"
"os"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
"github.com/pulumi/pulumi/pkg/v3/codegen/nodejs"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
sentry "github.com/pulumiverse/pulumi-sentry/provider"
"github.com/pulumiverse/pulumi-sentry/provider/pkg/version"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
)

var pluginName = "sentry"

func main() {
// Modify the path to point to the new provider
tfgen.Main("sentry", version.Version, sentry.Provider())

fixSchemaFile()
fixPackageJson()
}

// fixSchemaFile adds the plugin name to the schema, should be called after tfgen.Main to modify the
// generated file. Remove this hotfix when issue is resolved https://github.com/pulumi/pulumi/issues/9606
func fixSchemaFile() {
filePath := "./provider/cmd/pulumi-resource-sentry/schema.json"
fileContents, err := ioutil.ReadFile(filePath)
if err != nil {
log.Fatal(err)
}

var packageSpec schema.PackageSpec
err = json.Unmarshal(fileContents, &packageSpec)
if err != nil {
log.Fatalf("cannot deserialize schema.PackageSpec: %v", err)
}

var info nodejs.NodePackageInfo
err = json.Unmarshal(packageSpec.Language["nodejs"], &info)
if err != nil {
log.Fatalf("cannot deserialize nodejs.NodePackageInfo: %v", err)
}

info.PluginName = pluginName

serializedInfo, err := json.Marshal(info)
if err != nil {
log.Fatalf("cannot serialize nodejs.NodePackageInfo: %v", err)
}

packageSpec.Language["nodejs"] = serializedInfo

fileContents, err = json.MarshalIndent(packageSpec, "", " ")
if err != nil {
log.Fatalf("cannot serialize schema.PackageSpec: %v", err)
}

err = ioutil.WriteFile(filePath, fileContents, 0600)
if err != nil {
log.Fatal(err)
}
}

// fixPackageJson adds the plugin name to package.json, should be called after tfgen.Main to modify the
// generated file. Remove this hotfix when issue is resolved https://github.com/pulumi/pulumi/issues/9606
func fixPackageJson() {
// stolen from https://github.com/pulumi/pulumi/blob/v3.34.1/pkg/codegen/nodejs/gen.go#L2093
// should be kept in sync or hopefully deleted in the future
type npmPackage struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Homepage string `json:"homepage,omitempty"`
Repository string `json:"repository,omitempty"`
License string `json:"license,omitempty"`
Scripts map[string]string `json:"scripts,omitempty"`
Dependencies map[string]string `json:"dependencies,omitempty"`
DevDependencies map[string]string `json:"devDependencies,omitempty"`
PeerDependencies map[string]string `json:"peerDependencies,omitempty"`
Resolutions map[string]string `json:"resolutions,omitempty"`
Pulumi plugin.PulumiPluginJSON `json:"pulumi,omitempty"`
}

filePath := "sdk/nodejs/package.json"
fileContents, err := ioutil.ReadFile(filePath)
if errors.Is(err, os.ErrNotExist) {
// package.json does not exist after running `make clean` and then `make tfgen`
return
}
if err != nil {
log.Fatal(err)
}

var packageJson npmPackage
err = json.Unmarshal(fileContents, &packageJson)
if err != nil {
log.Fatalf("cannot deserialize npmPackage: %v", err)
}

packageJson.Pulumi.Name = pluginName

fileContents, err = json.MarshalIndent(packageJson, "", " ")
if err != nil {
log.Fatalf("cannot serialize schema.packageJson: %v", err)
}

err = ioutil.WriteFile(filePath, fileContents, 0600)
if err != nil {
log.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func Provider() tfbridge.ProviderInfo {
// PluginDownloadURL is an optional URL used to download the Provider
// for use in Pulumi programs
// e.g https://github.com/org/pulumi-provider-name/releases/
PluginDownloadURL: "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL: "github://api.github.com/pulumiverse",
Description: "A Pulumi package for creating and managing Sentry resources.",
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
// For all available categories, see `Keywords` in
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
AdditionalSecretOutputs =
{
"token",
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryDefaultKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
AdditionalSecretOutputs =
{
"dsnSecret",
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
AdditionalSecretOutputs =
{
"dsnSecret",
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryOrganization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/SentryTeam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions?
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}",
PluginDownloadURL = "github://api.github.com/pulumiverse",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static class Utilities
{
var dst = src ?? new global::Pulumi.InvokeOptions{};
dst.Version = src?.Version ?? Version;
dst.PluginDownloadURL = src?.PluginDownloadURL ?? "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}";
dst.PluginDownloadURL = src?.PluginDownloadURL ?? "github://api.github.com/pulumiverse";
return dst;
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": true,
"name": "sentry",
"server": "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}"
"server": "github://api.github.com/pulumiverse"
}
4 changes: 2 additions & 2 deletions sdk/go/sentry/config/pulumiUtilities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/go/sentry/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": true,
"name": "sentry",
"server": "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}"
"server": "github://api.github.com/pulumiverse"
}
4 changes: 2 additions & 2 deletions sdk/go/sentry/pulumiUtilities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions sdk/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
},
"pulumi": {
"resource": true,
"name": "sentry",
"server": "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}"
"server": "github://api.github.com/pulumiverse"
}
}
}
2 changes: 1 addition & 1 deletion sdk/nodejs/scripts/install-pulumi-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (args.indexOf("${VERSION}") !== -1) {
process.exit(0);
}

var res = childProcess.spawnSync("pulumi", ["plugin", "install", "--server", "https://github.com/pulumiverse/pulumi-sentry/releases/download/v${VERSION}"].concat(args), {
var res = childProcess.spawnSync("pulumi", ["plugin", "install", "--server", "github://api.github.com/pulumiverse"].concat(args), {
stdio: ["ignore", "inherit", "inherit"]
});

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ export function getVersion(): string {

/** @internal */
export function resourceOptsDefaults(): any {
return { version: getVersion(), pluginDownloadURL: "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}" };
return { version: getVersion(), pluginDownloadURL: "github://api.github.com/pulumiverse" };
}
4 changes: 2 additions & 2 deletions sdk/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ It is based on the sentry terraform provider https://registry.terraform.io/provi
If you get an error like this:

```
error: could not load plugin for sentry provider 'urn:pulumi:bcx-dev::sandbox::pulumi:providers:sentry::sentry': no resource plugin 'pulumi-resource-sentry' found in the workspace at version vX.Y.Z or on your $PATH, install the plugin using `pulumi plugin install resource sentry vX.Y.Z`
error: could not load plugin for sentry provider 'urn:pulumi:my-stack::my-project::pulumi:providers:sentry::my-provider': no resource plugin 'pulumi-resource-sentry' found in the workspace at version vX.Y.Z or on your $PATH, install the plugin using `pulumi plugin install resource sentry vX.Y.Z`
```

You can use this command to install the missing version:

```
VERSION=vX.Y.Z; pulumi plugin install resource sentry $VERSION --server https://github.com/pulumiverse/pulumi-sentry/releases/download/$VERSION
pulumi plugin install resource sentry vX.Y.Z --server github://api.github.com/pulumiverse
```

This package is available for several languages/platforms:
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pulumiverse_sentry/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,4 @@ def lifted_func(*args, opts=None, **kwargs):
return (lambda _: lifted_func)

def get_plugin_download_url():
return "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}"
return "github://api.github.com/pulumiverse"
2 changes: 1 addition & 1 deletion sdk/python/pulumiverse_sentry/pulumi-plugin.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resource": true,
"name": "sentry",
"server": "https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}"
"server": "github://api.github.com/pulumiverse"
}
2 changes: 1 addition & 1 deletion sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class InstallPluginCommand(install):
def run(self):
install.run(self)
try:
check_call(['pulumi', 'plugin', 'install', 'resource', 'sentry', PLUGIN_VERSION, '--server', 'https://github.com/pulumiverse/pulumi-sentry/releases/download/${VERSION}'])
check_call(['pulumi', 'plugin', 'install', 'resource', 'sentry', PLUGIN_VERSION, '--server', 'github://api.github.com/pulumiverse'])
except OSError as error:
if error.errno == errno.ENOENT:
print(f"""
Expand Down

0 comments on commit 45b3305

Please sign in to comment.