Skip to content

Commit

Permalink
fix: misuse of env KUSION_PATH (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
healthjyk committed Dec 22, 2023
1 parent 1b178f6 commit 207ebeb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ RUN apt-get update -y && apt-get install python3 python3-pip -y
# KCL PATH
ENV PATH="/root/go/bin:${PATH}"
# KUSION_PATH
ENV KUSION_PATH="$HOME/.kusion"
ENV KUSION_HOME="$HOME/.kusion"
ENV KUSION_PATH="$KUSION_HOME/bin"
ENV LANG=en_US.utf8

FROM base AS goreleaser
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile_kusionctl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ COPY _build/bundles/kusion-linux/bin/kusion /kusion/bin/
RUN chmod +x /kusion/bin/kusion

ENV PATH="/kusion/bin:${PATH}"
ENV KUSION_PATH="/kusion"
ENV KUSION_HOME="/kusion"
ENV KUSION_PATH="$KUSION_HOME/bin"
ENV LANG=en_US.utf8
4 changes: 2 additions & 2 deletions pkg/util/kfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
EnvKusionPath = "KUSION_PATH"
EnvKusionHome = "KUSION_HOME"
// CachedVersionFile is the name of the file we use to store when we last checked if the CLI was out of date
CachedVersionFile = ".cached_version"
)
Expand Down Expand Up @@ -62,7 +62,7 @@ func FileExists(filename string) (bool, error) {
func KusionDataFolder() (string, error) {
var kusionDataFolder string

if kusionPath := os.Getenv(EnvKusionPath); kusionPath != "" {
if kusionPath := os.Getenv(EnvKusionHome); kusionPath != "" {
kusionDataFolder = kusionPath
} else {
usr, err := user.Current()
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/kfile/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestKusionDataFolder(t *testing.T) {
for _, tt := range tests {
mockey.PatchConvey(tt.name, t, func() {
// Mock data
os.Setenv(EnvKusionPath, "")
os.Setenv(EnvKusionHome, "")
mockUserCurrent()
mockMkdirall()
got, err := KusionDataFolder()
Expand Down

0 comments on commit 207ebeb

Please sign in to comment.