diff --git a/Makefile b/Makefile index ac03707..1c4d741 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,11 @@ smoke: build grep "Namespace to interact with" smoke2.log rm -rf build/import-multi - VARIANT_BUILD_VER=v0.0.0 VARIANT_BUILD_REPLACE=$(shell pwd) PATH=${PATH}:$(GOBIN) ./variant export binary examples/advanced/import-multi build/import-multi + VARIANT_BUILD_VER=v0.0.0 \ + VARIANT_BUILD_VARIANT_REPLACE=$(shell pwd) \ + VARIANT_BUILD_MOD_REPLACE="github.com/summerwind/whitebox-controller@v0.7.1=github.com/mumoshu/whitebox-controller@v0.5.1-0.20201028130131-ac7a0743254b" \ + PATH=${PATH}:$(GOBIN) \ + ./variant export binary examples/advanced/import-multi build/import-multi build/import-multi foo baz HELLO > build/import-multi.log bash -c 'diff <(echo HELLO) <(cat build/import-multi.log)' diff --git a/examples/advanced/import-multi/export.sh b/examples/advanced/import-multi/export.sh index d4ee0f4..80361c5 100755 --- a/examples/advanced/import-multi/export.sh +++ b/examples/advanced/import-multi/export.sh @@ -4,7 +4,8 @@ PROJECT_ROOT=../../.. VARIANT=${PROJECT_ROOT}/variant export VARIANT_BUILD_VER=v0.33.3 -export VARIANT_BUILD_REPLACE=$(pwd)/${PROJECT_ROOT} +export VARIANT_BUILD_VARIANT_REPLACE=$(pwd)/${PROJECT_ROOT} +export VARIANT_BUILD_MOD_REPLACE="github.com/summerwind/whitebox-controller@v0.7.1=github.com/mumoshu/whitebox-controller@v0.5.1-0.20201028130131-ac7a0743254b" rm -rf ../exported rm -rf ../compiled diff --git a/pkg/app/app_shim.go b/pkg/app/app_shim.go index ea719c5..6e876e1 100644 --- a/pkg/app/app_shim.go +++ b/pkg/app/app_shim.go @@ -160,7 +160,7 @@ func main() { } } - variantReplace := os.Getenv("VARIANT_BUILD_REPLACE") + variantReplace := os.Getenv("VARIANT_BUILD_VARIANT_REPLACE") if variantReplace != "" { _, err = app.execCmd( Command{ @@ -175,6 +175,21 @@ func main() { } } + modReplace := os.Getenv("VARIANT_BUILD_MOD_REPLACE") + if modReplace != "" { + _, err = app.execCmd( + Command{ + Name: "sh", + Args: []string{"-c", fmt.Sprintf("cd %s; go mod edit -replace %s", dstDir, modReplace)}, + Env: map[string]string{}, + }, + true, + ) + if err != nil { + return err + } + } + return nil }