Skip to content

Commit

Permalink
make prepare updates project url and org name
Browse files Browse the repository at this point in the history
  • Loading branch information
gpduck committed Dec 1, 2022
1 parent 2f2b03c commit fef7d69
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ PROJECT_NAME := xyz Package

SHELL := /bin/bash
PACK := xyz
ORG := pulumi
PROJECT := github.com/${ORG}/pulumi-${PACK}
NODE_MODULE_NAME := @pulumi/${PACK}
PROJECT := github.com/pulumi/pulumi-xyz
NODE_MODULE_NAME := @abc/${PACK}
TF_NAME := ${PACK}
PROVIDER_PATH := provider
VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version
Expand All @@ -18,25 +17,28 @@ TESTPARALLELISM := 4
WORKING_DIR := $(shell pwd)

OS := $(shell uname)
EMPTY_TO_AVOID_SED := ""
EMPTY_TO_AVOID_SED :=

prepare::
@if test -z "${NAME}"; then echo "NAME not set"; exit 1; fi
@if test -z "${REPOSITORY}"; then echo "REPOSITORY not set"; exit 1; fi
@if test -z "${ORG}"; then echo "ORG not set"; exit 1; fi
@if test ! -d "provider/cmd/pulumi-tfgen-x${EMPTY_TO_AVOID_SED}yz"; then "Project already prepared"; exit 1; fi

mv "provider/cmd/pulumi-tfgen-x${EMPTY_TO_AVOID_SED}yz" provider/cmd/pulumi-tfgen-${NAME}
mv "provider/cmd/pulumi-resource-x${EMPTY_TO_AVOID_SED}yz" provider/cmd/pulumi-resource-${NAME}

if [[ "${OS}" != "Darwin" ]]; then \
sed -i 's,github.com/pulumi/pulumi-xyz,${REPOSITORY},g' provider/go.mod; \
find ./ ! -path './.git/*' -type f -exec sed -i 's,github.com/pulumi/pulumi-[x]yz,${REPOSITORY},g' {} \; &> /dev/null; \
find ./ ! -path './.git/*' -type f -exec sed -i 's/[x]yz/${NAME}/g' {} \; &> /dev/null; \
find ./ ! -path './.git/*' -type f -exec sed -i 's/[a]bc/${ORG}/g' {} \; &> /dev/null; \
fi

# In MacOS the -i parameter needs an empty string to execute in place.
if [[ "${OS}" == "Darwin" ]]; then \
sed -i '' 's,github.com/pulumi/pulumi-xyz,${REPOSITORY},g' provider/go.mod; \
find ./ ! -path './.git/*' -type f -exec sed -i '' 's,github.com/pulumi/pulumi-[x]yz,${REPOSITORY},g' {} \; &> /dev/null; \
find ./ ! -path './.git/*' -type f -exec sed -i '' 's/[x]yz/${NAME}/g' {} \; &> /dev/null; \
find ./ ! -path './.git/*' -type f -exec sed -i '' 's/[a]bc/${ORG}/g' {} \; &> /dev/null; \
fi

.PHONY: development provider build_sdks build_nodejs build_dotnet build_go build_python cleanup
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,19 @@ From the templated repository:
1. Run the following command to update files to use the name of your provider (third-party: use your GitHub organization/username):

```bash
make prepare NAME=foo REPOSITORY=github.com/pulumi/pulumi-foo
make prepare NAME=foo REPOSITORY=github.com/pulumi/pulumi-foo ORG=myorg
```

This will do the following:
- rename folders in `provider/cmd` to `pulumi-resource-foo` and `pulumi-tfgen-foo`
- replace dependencies in `provider/go.mod` to reflect your repository name
- find and replace all instances of the boilerplate `xyz` with the `NAME` of your provider.
- find and replace all instances of the boilerplate `abc` with the `ORG` of your provider.
- replace all instances of the `github.com/pulumi/pulumi-xyz` repository with the `REPOSITORY` location

Note for third-party providers:
- Make sure to set the correct GitHub organization/username in all files referencing your provider as a dependency:
- `examples/go.mod`
- `provider/resources.go`
- `sdk/go.mod`
- `provider/cmd/pulumi-resource-foo/main.go`
- `provider/cmd/pulumi-tfgen-foo/main.go`
- If you intend to publish on the Pulumi registry you will want to update the `DisplayName`, `Publisher`, and `Homepage` values in `provider/resources.go` to use your desired casing.


2. Modify `README-PROVIDER.md` to include the following (we'll rename it to `README.md` toward the end of this guide):
- Any desired build status badges.
Expand Down
2 changes: 1 addition & 1 deletion deployment-templates/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builds:
- linux
ldflags:
# The line below MUST align with the module in current provider/go.mod
- -X github.com/your-org-name/pulumi-xyz/provider/pkg/version.Version={{.Tag }}
- -X github.com/pulumi/pulumi-xyz/provider/pkg/version.Version={{.Tag }}
main: ./cmd/pulumi-resource-xyz/
changelog:
skip: true
Expand Down
7 changes: 3 additions & 4 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package xyz

import (
"fmt"
"path/filepath"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
Expand Down Expand Up @@ -59,7 +58,7 @@ func Provider() tfbridge.ProviderInfo {
// Change this to your personal name (or a company name) that you
// would like to be shown in the Pulumi Registry if this package is published
// there.
Publisher: "Pulumi",
Publisher: "abc",
// LogoURL is optional but useful to help identify your package in the Pulumi Registry
// if this package is published there.
//
Expand All @@ -74,7 +73,7 @@ func Provider() tfbridge.ProviderInfo {
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
// For all available categories, see `Keywords` in
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
Keywords: []string{"pulumi", "xyz", "category/cloud"},
Keywords: []string{"abc", "xyz", "category/cloud"},
License: "Apache-2.0",
Homepage: "https://www.pulumi.com",
Repository: "https://github.com/pulumi/pulumi-xyz",
Expand Down Expand Up @@ -133,7 +132,7 @@ func Provider() tfbridge.ProviderInfo {
},
Golang: &tfbridge.GolangInfo{
ImportBasePath: filepath.Join(
fmt.Sprintf("github.com/pulumi/pulumi-%[1]s/sdk/", mainPkg),
"github.com/pulumi/pulumi-xyz/sdk/",
tfbridge.GetModuleMajorVersion(version.Version),
"go",
mainPkg,
Expand Down

0 comments on commit fef7d69

Please sign in to comment.