Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename azapi2azurerm to aztfmigrate #130

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions .azdo/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ stages:
- stage: build
pool:
name: pool-ubuntu-2004
displayName: "Build azapi2azurerm"
displayName: "Build aztfmigrate"
jobs:
- job: build
displayName: "Build Binaries"
Expand Down Expand Up @@ -60,9 +60,9 @@ stages:
- script: |
set -e
mkdir build
name=azapi2azurerm
name=aztfmigrate
if [[ $OS = windows ]]; then
name=azapi2azurerm.exe
name=aztfmigrate.exe
fi
GOOS="${OS}" GOARCH="${ARCH}" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X 'main.version=${VERSION}'" -o build/$name
displayName: "Go Build"
Expand Down Expand Up @@ -128,7 +128,7 @@ stages:
ARCH: amd64
steps:
- task: DownloadPipelineArtifact@2
displayName: "Download azapi2azurerm binary"
displayName: "Download aztfmigrate binary"
inputs:
artifact: windows-$(ARCH)
path: $(system.defaultWorkingDirectory)/dist/bin
Expand All @@ -152,10 +152,10 @@ stages:
cd $workdir/scripts/package/windows/build
declare -A map=( [386]=x86 [amd64]=x64 )
export VERSION=${VERSION:1}
cp $workdir/dist/bin/azapi2azurerm.exe .
cp $workdir/dist/bin/aztfmigrate.exe .
candle.exe -arch ${map[$ARCH]} -o setup.wxobj ./setup.wxs
mkdir $workdir/dist/output
light.exe -out $workdir/dist/output/azapi2azurerm.msi ./setup.wxobj
light.exe -out $workdir/dist/output/aztfmigrate.msi ./setup.wxobj
env:
workdir: $(system.defaultWorkingDirectory)
VERSION: ${{ parameters.version }}
Expand Down Expand Up @@ -235,52 +235,52 @@ stages:
- script: |
set -e

chmod +x $WORKDIR/dist/source/azapi2azurerm
chmod +x $WORKDIR/dist/source/aztfmigrate

declare -A deb_arch_map=( [386]=i386 [amd64]=amd64 [arm]=armhf [arm64]=arm64 )
declare -A rpm_arch_map=( [386]=i686 [amd64]=x86_64 [arm]=armv7hl [arm64]=aarch64 )
version=${VERSION:1}

# Build the image
cd $WORKDIR/scripts/package/linux/build
docker build -t azapi2azurermbuild .
docker build -t aztfmigratebuild .

# Build deb package
docker run -t --rm \
-v $WORKDIR/dist/source:/build/source \
-v $WORKDIR/dist/output:/build/output \
azapi2azurermbuild \
aztfmigratebuild \
fpm \
--name azapi2azurerm \
--name aztfmigrate \
--license MPL-2.0 \
--version $version \
--description "A tool to migrate terraform resources from azapi to azurerm" \
--url "https://github.com/Azure/azapi2azurerm" \
--url "https://github.com/Azure/aztfmigrate" \
--maintainer "henglu <[email protected]>" \
--input-type dir \
--output-type deb \
--architecture ${deb_arch_map[$ARCH]} \
--package /build/output/azapi2azurerm-$version-1-${deb_arch_map[$ARCH]}.deb \
/build/source/azapi2azurerm=/usr/bin/azapi2azurerm
--package /build/output/aztfmigrate-$version-1-${deb_arch_map[$ARCH]}.deb \
/build/source/aztfmigrate=/usr/bin/aztfmigrate

# Build rpm package
echo $version
docker run -t --rm \
-v $WORKDIR/dist/source:/build/source \
-v $WORKDIR/dist/output:/build/output \
azapi2azurermbuild \
aztfmigratebuild \
fpm \
--name azapi2azurerm \
--name aztfmigrate \
--license MPL-2.0 \
--version ${version} \
--description "A tool to migrate terraform resources from azapi to azurerm" \
--url "https://github.com/Azure/azapi2azurerm" \
--url "https://github.com/Azure/aztfmigrate" \
--maintainer "henglu <[email protected]>" \
--input-type dir \
--output-type rpm \
--architecture ${rpm_arch_map[$ARCH]} \
--package /build/output/azapi2azurerm-$version-1-${rpm_arch_map[$ARCH]}.rpm \
/build/source/azapi2azurerm=/usr/bin/azapi2azurerm
--package /build/output/aztfmigrate-$version-1-${rpm_arch_map[$ARCH]}.rpm \
/build/source/aztfmigrate=/usr/bin/aztfmigrate
displayName: "Build Packages"
env:
VERSION: ${{ parameters.version }}
Expand Down Expand Up @@ -339,7 +339,7 @@ stages:
runId: ${{ parameters.artifactBuildId }}
- script: |
set -e
NAME="azapi2azurerm"
NAME="aztfmigrate"
OS_ARCH=(
"windows:amd64"
"windows:386"
Expand All @@ -354,17 +354,17 @@ stages:
for os_arch in "${OS_ARCH[@]}" ; do
OS=${os_arch%%:*}
ARCH=${os_arch#*:}
name=azapi2azurerm
name=aztfmigrate
if [[ $OS = windows ]]; then
name=azapi2azurerm.exe
name=aztfmigrate.exe
fi
chmod +x dist/${OS}-${ARCH}/${name}
zip -j release/${NAME}_${VERSION}_${OS}_${ARCH}.zip dist/${OS}-${ARCH}/${name}
done

# Copy MSI
cp dist/windows-386-msi/azapi2azurerm.msi release/${NAME}_${VERSION}_x86.msi
cp dist/windows-amd64-msi/azapi2azurerm.msi release/${NAME}_${VERSION}_x64.msi
cp dist/windows-386-msi/aztfmigrate.msi release/${NAME}_${VERSION}_x86.msi
cp dist/windows-amd64-msi/aztfmigrate.msi release/${NAME}_${VERSION}_x64.msi

cd release
shasum -a 256 *.zip *.msi > ${NAME}_SHA256SUMS
Expand Down Expand Up @@ -400,7 +400,7 @@ stages:
- task: GitHubRelease@1
displayName: "Draft Github Release"
inputs:
gitHubConnection: 'azapi2azurerm'
gitHubConnection: 'aztfmigrate'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
Expand Down
6 changes: 3 additions & 3 deletions .azdo/azurerm-schema-update-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ steps:
git config --global user.email "[email protected]"
git config --global user.name "Heng Lu"
git clone https://ms-henglu:[email protected]/ms-henglu/terraform-provider-azurerm.git
git clone https://ms-henglu:[email protected]/Azure/azapi2azurerm.git
git clone https://ms-henglu:[email protected]/Azure/aztfmigrate.git
cd terraform-provider-azurerm
git remote add hashi https://ms-henglu:[email protected]/hashicorp/terraform-provider-azurerm.git
git remote
Expand All @@ -55,7 +55,7 @@ steps:
- bash: |
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
cd azapi2azurerm/.tools/generate-provider-schema
cd aztfmigrate/.tools/generate-provider-schema
pwd
chmod -R +x ./run.sh
./run.sh /mnt/vss/_work/1/s/terraform-provider-azurerm ${{ parameters.branch }}
Expand All @@ -65,7 +65,7 @@ steps:
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
export TAG=$(step1.TAG)
cd azapi2azurerm
cd aztfmigrate
make fmt
git add .
git status
Expand Down
2 changes: 1 addition & 1 deletion azurerm/coverage/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/Azure/azapi2azurerm/azurerm/coverage"
"github.com/Azure/aztfmigrate/azurerm/coverage"
)

func Test_GetCoverage(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/hcl_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"sort"
"strings"

"github.com/Azure/azapi2azurerm/azurerm/schema"
"github.com/Azure/aztfmigrate/azurerm/schema"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/zclconf/go-cty/cty"
Expand Down Expand Up @@ -77,7 +77,7 @@
if schAttr.Default != nil {
dstr = fmt.Sprintf("%#v", schAttr.Default)
}
attrExpr, diags := hclwrite.ParseConfig(attrVal.BuildTokens(nil).Bytes(), "generate_attr", hcl.InitialPos)

Check failure on line 80 in azurerm/hcl_schema.go

View workflow job for this annotation

GitHub Actions / golint

undefined: hcl (typecheck)
if diags.HasErrors() {
return fmt.Errorf(`building attribute %q attribute: %s`, attrName, diags.Error())
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/migrate_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"path/filepath"
"strings"

"github.com/Azure/azapi2azurerm/tf"
"github.com/Azure/azapi2azurerm/types"
"github.com/Azure/aztfmigrate/tf"
"github.com/Azure/aztfmigrate/types"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/mitchellh/cli"
)
Expand Down Expand Up @@ -79,8 +79,8 @@ func (c *MigrateCommand) Run(args []string) int {

func (c *MigrateCommand) Help() string {
helpText := `
Usage: azapi2azurerm migrate
` + c.Synopsis() + "\nThe Terraform addresses listed in file `azapi2azurerm.ignore` will be ignored during migration.\n\n" + helpForFlags(c.flags())
Usage: aztfmigrate migrate
` + c.Synopsis() + "\nThe Terraform addresses listed in file `aztfmigrate.ignore` will be ignored during migration.\n\n" + helpForFlags(c.flags())

return strings.TrimSpace(helpText)
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/migrate_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"testing"
"time"

"github.com/Azure/azapi2azurerm/azurerm"
"github.com/Azure/azapi2azurerm/cmd"
"github.com/Azure/azapi2azurerm/tf"
"github.com/Azure/azapi2azurerm/types"
"github.com/Azure/aztfmigrate/azurerm"
"github.com/Azure/aztfmigrate/cmd"
"github.com/Azure/aztfmigrate/tf"
"github.com/Azure/aztfmigrate/types"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/mitchellh/cli"
Expand Down Expand Up @@ -199,7 +199,7 @@ func init() {
}

func tempDir(t *testing.T) string {
tmpDir := filepath.Join(os.TempDir(), "azapi2azurerm", t.Name())
tmpDir := filepath.Join(os.TempDir(), "aztfmigrate", t.Name())
err := os.MkdirAll(tmpDir, 0o755)
if err != nil && !os.IsExist(err) {
t.Fatal(err)
Expand Down
12 changes: 6 additions & 6 deletions cmd/plan_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"path"
"strings"

"github.com/Azure/azapi2azurerm/azurerm"
"github.com/Azure/azapi2azurerm/tf"
"github.com/Azure/azapi2azurerm/types"
"github.com/Azure/aztfmigrate/azurerm"
"github.com/Azure/aztfmigrate/tf"
"github.com/Azure/aztfmigrate/types"
"github.com/mitchellh/cli"
)

Expand Down Expand Up @@ -65,8 +65,8 @@ func (c *PlanCommand) Run(args []string) int {

func (c *PlanCommand) Help() string {
helpText := `
Usage: azapi2azurerm plan
` + c.Synopsis() + "\nThe Terraform addresses listed in file `azapi2azurerm.ignore` will be ignored during migration.\n\n" + helpForFlags(c.flags())
Usage: aztfmigrate plan
` + c.Synopsis() + "\nThe Terraform addresses listed in file `aztfmigrate.ignore` will be ignored during migration.\n\n" + helpForFlags(c.flags())

return strings.TrimSpace(helpText)
}
Expand All @@ -87,7 +87,7 @@ func (c *PlanCommand) Plan(terraform *tf.Terraform, isPlanOnly bool) []types.Azu
unsupportedMessage := "The following resources can't be migrated:\n"
ignoreMessage := "The following resources will be ignored in migration:\n"
ignoreSet := make(map[string]bool)
if file, err := os.ReadFile(path.Join(terraform.GetWorkingDirectory(), "azapi2azurerm.ignore")); err == nil {
if file, err := os.ReadFile(path.Join(terraform.GetWorkingDirectory(), "aztfmigrate.ignore")); err == nil {
lines := strings.Split(string(file), "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
Expand Down
4 changes: 2 additions & 2 deletions cmd/plan_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"
"time"

"github.com/Azure/azapi2azurerm/cmd"
"github.com/Azure/azapi2azurerm/tf"
"github.com/Azure/aztfmigrate/cmd"
"github.com/Azure/aztfmigrate/tf"
"github.com/mitchellh/cli"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/version_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"runtime"
"strings"

"github.com/Azure/azapi2azurerm/azurerm/schema"
"github.com/Azure/aztfmigrate/azurerm/schema"
"github.com/mitchellh/cli"
)

Expand Down Expand Up @@ -75,7 +75,7 @@ func (c *VersionCommand) Run(args []string) int {

func (c *VersionCommand) Help() string {
helpText := `
Usage: azapi2azurerm version [-json]
Usage: aztfmigrate version [-json]
` + c.Synopsis() + "\n\n" + helpForFlags(c.flags())

return strings.TrimSpace(helpText)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Azure/azapi2azurerm
module github.com/Azure/aztfmigrate

go 1.22.0

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package main
import (
"os"

"github.com/Azure/azapi2azurerm/cmd"
"github.com/Azure/aztfmigrate/cmd"
"github.com/mitchellh/cli"
)

func main() {
c := &cli.CLI{
Name: "azapi2azurerm",
Name: "aztfmigrate",
Version: version,
Args: os.Args[1:],
HelpWriter: os.Stdout,
Expand Down
Loading
Loading