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 command and brand name #370

Merged
merged 6 commits into from
Mar 6, 2023
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
97 changes: 45 additions & 52 deletions README.md

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions 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 aztfy"
displayName: "Build"
jobs:
- job: build
displayName: "Build Binaries"
Expand Down Expand Up @@ -54,9 +54,9 @@ stages:
set -e
REVISION=`git rev-parse --short HEAD`
mkdir build
name=aztfy
name=aztfexport
if [[ $OS = windows ]]; then
name=aztfy.exe
name=aztfexport.exe
fi
GOOS="${OS}" GOARCH="${ARCH}" CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X 'main.version=${VERSION}' -X 'main.revision=${REVISION}'" -o build/$name
displayName: "Go Build"
Expand Down Expand Up @@ -123,7 +123,7 @@ stages:
ARCH: amd64
steps:
- task: DownloadPipelineArtifact@2
displayName: "Download aztfy binary"
displayName: "Download binary"
inputs:
artifact: windows-$(ARCH)
path: $(system.defaultWorkingDirectory)/dist/bin
Expand All @@ -147,10 +147,10 @@ stages:
cd $workdir/scripts/package/windows/build
declare -A map=( [386]=x86 [amd64]=x64 )
export VERSION=${VERSION:1}
cp $workdir/dist/bin/aztfy.exe .
cp $workdir/dist/bin/aztfexport.exe .
candle.exe -arch ${map[$ARCH]} -o setup.wxobj ./setup.wxs
mkdir $workdir/dist/output
light.exe -out $workdir/dist/output/aztfy.msi ./setup.wxobj
light.exe -out $workdir/dist/output/aztfexport.msi ./setup.wxobj
env:
workdir: $(system.defaultWorkingDirectory)
VERSION: ${{ parameters.version }}
Expand Down Expand Up @@ -230,52 +230,52 @@ stages:
- script: |
set -e

chmod +x $WORKDIR/dist/source/aztfy
chmod +x $WORKDIR/dist/source/aztfexport

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 aztfybuild .
docker build -t aztfexportbuild .

# Build deb package
docker run -t --rm \
-v $WORKDIR/dist/source:/build/source \
-v $WORKDIR/dist/output:/build/output \
aztfybuild \
aztfexportbuild \
fpm \
--name aztfy \
--name aztfexport \
--license MPL-2.0 \
--version $version \
--description "A tool to bring existing Azure resources under Terraform's management" \
--url "https://github.com/Azure/aztfy" \
--url "https://github.com/Azure/aztfexport" \
--maintainer "magodo <wztdyl@sina.com>" \
--input-type dir \
--output-type deb \
--architecture ${deb_arch_map[$ARCH]} \
--package /build/output/aztfy-$version-1-${deb_arch_map[$ARCH]}.deb \
/build/source/aztfy=/usr/bin/aztfy
--package /build/output/aztfexport-$version-1-${deb_arch_map[$ARCH]}.deb \
/build/source/aztfexport=/usr/bin/aztfexport

# Build rpm package
echo $version
docker run -t --rm \
-v $WORKDIR/dist/source:/build/source \
-v $WORKDIR/dist/output:/build/output \
aztfybuild \
aztfexportbuild \
fpm \
--name aztfy \
--name aztfexport \
--license MPL-2.0 \
--version ${version} \
--description "A tool to bring existing Azure resources under Terraform's management" \
--url "https://github.com/Azure/aztfy" \
--url "https://github.com/Azure/aztfexport" \
--maintainer "magodo <wztdyl@sina.com>" \
--input-type dir \
--output-type rpm \
--architecture ${rpm_arch_map[$ARCH]} \
--package /build/output/aztfy-$version-1-${rpm_arch_map[$ARCH]}.rpm \
/build/source/aztfy=/usr/bin/aztfy
--package /build/output/aztfexport-$version-1-${rpm_arch_map[$ARCH]}.rpm \
/build/source/aztfexport=/usr/bin/aztfexport
displayName: "Build Packages"
env:
VERSION: ${{ parameters.version }}
Expand Down Expand Up @@ -334,7 +334,7 @@ stages:
runId: ${{ parameters.artifactBuildId }}
- script: |
set -e
NAME="aztfy"
NAME="aztfexport"
OS_ARCH=(
"windows:amd64"
"windows:386"
Expand All @@ -349,17 +349,17 @@ stages:
for os_arch in "${OS_ARCH[@]}" ; do
OS=${os_arch%%:*}
ARCH=${os_arch#*:}
name=aztfy
name=aztfexport
if [[ $OS = windows ]]; then
name=aztfy.exe
name=aztfexport.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/aztfy.msi release/${NAME}_${VERSION}_x86.msi
cp dist/windows-amd64-msi/aztfy.msi release/${NAME}_${VERSION}_x64.msi
cp dist/windows-386-msi/aztfexport.msi release/${NAME}_${VERSION}_x86.msi
cp dist/windows-amd64-msi/aztfexport.msi release/${NAME}_${VERSION}_x64.msi

cd release
shasum -a 256 *.zip *.msi > ${NAME}_SHA256SUMS
Expand Down Expand Up @@ -397,7 +397,7 @@ stages:
git config user.name "azure-terraform-bot"
git config user.email "azure-terraform@microsoft.com"
git tag -a "${VERSION}" -m "${VERSION}"
git push https://${PAT}@github.com/Azure/aztfy.git --tags
git push https://${PAT}@github.com/Azure/aztfexport.git --tags
displayName: "Create and Push a Git Release"
env:
VERSION: ${{ parameters.version }}
Expand Down Expand Up @@ -665,7 +665,7 @@ stages:
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
git clone https://github.com/microsoft/winget-pkgs.git
cd winget-pkgs
..\wingetcreate.exe update --urls https://github.com/Azure/aztfy/releases/download/$env:VERSION/aztfy_$($env:VERSION)_x64.msi https://github.com/Azure/aztfy/releases/download/$env:VERSION/aztfy_$($env:VERSION)_x86.msi --version $env:VERSION.Substring(1) --submit --token $env:PAT Microsoft.Azure.Aztfy
..\wingetcreate.exe update --urls https://github.com/Azure/aztfexport/releases/download/$env:VERSION/aztfexport_$($env:VERSION)_x64.msi https://github.com/Azure/aztfexport/releases/download/$env:VERSION/aztfexport_$($env:VERSION)_x86.msi --version $env:VERSION.Substring(1) --submit --token $env:PAT Microsoft.Azure.AztfExport
displayName: "Create PR"
env:
VERSION: ${{ parameters.version }}
Expand All @@ -692,7 +692,7 @@ stages:
cd "$(brew --repository homebrew/core)"
git config user.name "azure-terraform-bot"
git config user.email "azure-terraform@microsoft.com"
HOMEBREW_GITHUB_API_TOKEN=${PAT} brew bump-formula-pr --version=${VERSION:1} --no-browse --force aztfy
HOMEBREW_GITHUB_API_TOKEN=${PAT} brew bump-formula-pr --version=${VERSION:1} --no-browse --force aztfexport
displayName: "Create PR"
env:
VERSION: ${{ parameters.version }}
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/aztfy
module github.com/Azure/aztfexport

go 1.19

Expand Down
2 changes: 1 addition & 1 deletion internal/cfgfile/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/tidwall/sjson"
)

const CfgDirName = ".aztfy"
const CfgDirName = ".aztfexport"
const CfgFileName = "config.json"

type Configuration struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_interactive.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package config

import "github.com/Azure/aztfy/pkg/config"
import "github.com/Azure/aztfexport/pkg/config"

type InteractiveModeConfig struct {
config.Config
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_noninteractive.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package config

import "github.com/Azure/aztfy/pkg/config"
import "github.com/Azure/aztfexport/pkg/config"

type NonInteractiveModeConfig struct {
config.Config
Expand Down
30 changes: 15 additions & 15 deletions internal/meta/base_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"path/filepath"
"strings"

"github.com/Azure/aztfy/pkg/config"
"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/pkg/config"
"github.com/Azure/aztfexport/pkg/log"
"github.com/zclconf/go-cty/cty"

"github.com/Azure/aztfy/internal/client"
"github.com/Azure/aztfy/internal/resmap"
"github.com/Azure/aztfy/internal/utils"
"github.com/Azure/aztfy/pkg/telemetry"
"github.com/Azure/aztfexport/internal/client"
"github.com/Azure/aztfexport/internal/resmap"
"github.com/Azure/aztfexport/internal/utils"
"github.com/Azure/aztfexport/pkg/telemetry"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
Expand All @@ -33,15 +33,15 @@ import (
"github.com/magodo/workerpool"
)

const ResourceMappingFileName = "aztfyResourceMapping.json"
const SkippedResourcesFileName = "aztfySkippedResources.txt"
const ResourceMappingFileName = "aztfexportResourceMapping.json"
const SkippedResourcesFileName = "aztfexportSkippedResources.txt"

type TFConfigTransformer func(configs ConfigInfos) (ConfigInfos, error)

type BaseMeta interface {
// Init initializes aztfy, including initialize terraform, provider and soem runtime temporary resources.
// Init initializes the base meta, including initialize terraform, provider and soem runtime temporary resources.
Init(ctx context.Context) error
// DeInit deinitializes aztfy, including cleaning up runtime temporary resources.
// DeInit deinitializes the base meta, including cleaning up runtime temporary resources.
DeInit(ctx context.Context) error
// Workspace returns the path of the output directory.
Workspace() string
Expand All @@ -58,7 +58,7 @@ type BaseMeta interface {
ExportSkippedResources(ctx context.Context, l ImportList) error
// ExportResourceMapping writes a resource mapping file to the output directory.
ExportResourceMapping(ctx context.Context, l ImportList) error
// CleanUpWorkspace is a weired method that is only meant to be used internally by aztfy, which under the hood will remove everything in the output directory, except the generated TF config.
// CleanUpWorkspace is a weired method that is only meant to be used internally by aztfexport, which under the hood will remove everything in the output directory, except the generated TF config.
// This method does nothing if HCLOnly in the Config is not set.
CleanUpWorkspace(ctx context.Context) error
}
Expand Down Expand Up @@ -226,7 +226,7 @@ func (meta *baseMeta) Init(ctx context.Context) error {
}
}
for i := 0; i < meta.parallelism; i++ {
dir, err := os.MkdirTemp("", "aztfy-")
dir, err := os.MkdirTemp("", "aztfexport-")
if err != nil {
return fmt.Errorf("creating import directory: %v", err)
}
Expand Down Expand Up @@ -321,7 +321,7 @@ func (meta *baseMeta) ParallelImport(ctx context.Context, items []*ImportItem) e

// Performance improvement.
// In case there is no TF state in the target workspace (no matter local/remote backend), we can avoid using tfmerge (which takes care of terraform internals, like keeping the lineage, etc).
// As long as the user ensure there is no address conflicts in the import list (which is always the case by aztfy as the resource names are almost unique),
// As long as the user ensure there is no address conflicts in the import list (which is always the case as the resource names are almost unique),
// We are updating the local thisBaseStateJSON here, will update it to the meta.baseState at the end of this function.
if len(meta.originBaseState) == 0 {
log.Printf("[DEBUG] Merging terraform state file %s (simple)", stateFile)
Expand Down Expand Up @@ -406,7 +406,7 @@ func (meta baseMeta) PushState(ctx context.Context) error {
if baseState != string(meta.originBaseState) {
edits := myers.ComputeEdits(span.URIFromPath("origin.tfstate"), string(meta.originBaseState), baseState)
changes := fmt.Sprint(gotextdiff.ToUnified("origin.tfstate", "current.tfstate", string(meta.originBaseState), edits))
return fmt.Errorf("there is out-of-band changes on the state file during running aztfy:\n%s", changes)
return fmt.Errorf("there is out-of-band changes on the state file:\n%s", changes)
}

// Create a temporary state file to hold the merged states, then push the state to the output directory.
Expand Down Expand Up @@ -715,7 +715,7 @@ func (meta *baseMeta) importItem(ctx context.Context, item *ImportItem, importId
tf := meta.importTFs[importIdx]

// Construct the empty cfg file for importing
cfgFile := filepath.Join(moduleDir, "tmp.aztfy.tf")
cfgFile := filepath.Join(moduleDir, "tmp.aztfexport.tf")
tpl := fmt.Sprintf(`resource "%s" "%s" {}`, item.TFAddr.Type, item.TFAddr.Name)
// #nosec G306
if err := os.WriteFile(cfgFile, []byte(tpl), 0644); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/meta/importlist.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package meta

import (
"github.com/Azure/aztfy/internal/tfaddr"
"github.com/Azure/aztfexport/internal/tfaddr"
"github.com/magodo/armid"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/meta/meta_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"os"
"sort"

"github.com/Azure/aztfy/pkg/config"
"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/pkg/config"
"github.com/Azure/aztfexport/pkg/log"

"github.com/Azure/aztfy/internal/resmap"
"github.com/Azure/aztfy/internal/tfaddr"
"github.com/Azure/aztfexport/internal/resmap"
"github.com/Azure/aztfexport/internal/tfaddr"
"github.com/magodo/armid"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/meta/meta_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"

"github.com/Azure/aztfy/internal/resourceset"
"github.com/Azure/aztfy/internal/tfaddr"
"github.com/Azure/aztfy/pkg/config"
"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/internal/resourceset"
"github.com/Azure/aztfexport/internal/tfaddr"
"github.com/Azure/aztfexport/pkg/config"
"github.com/Azure/aztfexport/pkg/log"
"github.com/magodo/azlist/azlist"
)

Expand Down
10 changes: 5 additions & 5 deletions internal/meta/meta_res.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"

"github.com/Azure/aztfy/internal/resourceset"
"github.com/Azure/aztfy/internal/tfaddr"
"github.com/Azure/aztfy/pkg/config"
"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/internal/resourceset"
"github.com/Azure/aztfexport/internal/tfaddr"
"github.com/Azure/aztfexport/pkg/config"
"github.com/Azure/aztfexport/pkg/log"
"github.com/magodo/armid"
"github.com/magodo/aztft/aztft"
)
Expand Down Expand Up @@ -56,7 +56,7 @@ func (meta *MetaResource) ListResource(_ context.Context) (ImportList, error) {

// This is to record known resource types. In case there is a known resource type and there comes another same typed resource,
// then we need to modify the resource name. Otherwise, there will be a resource address conflict.
// See https://github.com/Azure/aztfy/issues/275 for an example.
// See https://github.com/Azure/aztfexport/issues/275 for an example.
rtCnt := map[string]int{}

var l ImportList
Expand Down
8 changes: 4 additions & 4 deletions internal/meta/meta_rg.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"

"github.com/Azure/aztfy/internal/resourceset"
"github.com/Azure/aztfy/internal/tfaddr"
"github.com/Azure/aztfy/pkg/config"
"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/internal/resourceset"
"github.com/Azure/aztfexport/internal/tfaddr"
"github.com/Azure/aztfexport/pkg/config"
"github.com/Azure/aztfexport/pkg/log"
"github.com/magodo/armid"
"github.com/magodo/azlist/azlist"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/resourceset/azure_resource_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package resourceset
import (
"sort"

"github.com/Azure/aztfy/pkg/log"
"github.com/Azure/aztfexport/pkg/log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"

Expand Down
8 changes: 4 additions & 4 deletions internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"os"
"strings"

internalmeta "github.com/Azure/aztfy/internal/meta"
internalmeta "github.com/Azure/aztfexport/internal/meta"

"github.com/Azure/aztfy/internal/config"
"github.com/Azure/aztfy/pkg/meta"
"github.com/Azure/aztfexport/internal/config"
"github.com/Azure/aztfexport/pkg/meta"

"github.com/Azure/aztfy/internal/ui/common"
"github.com/Azure/aztfexport/internal/ui/common"
bspinner "github.com/charmbracelet/bubbles/spinner"
"github.com/magodo/spinner"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/test/cases/case.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cases

import (
"github.com/Azure/aztfy/internal/resmap"
"github.com/Azure/aztfy/internal/test"
"github.com/Azure/aztfexport/internal/resmap"
"github.com/Azure/aztfexport/internal/test"
)

type SingleResourceContext struct {
Expand Down
Loading