Skip to content

Commit

Permalink
fix: fix apply not change uncontrolled state (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH authored Mar 22, 2024
1 parent 0ce66f5 commit de08559
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions route/v2/compose_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strings"

"github.com/IceWhaleTech/CasaOS-AppManagement/codegen"
"github.com/IceWhaleTech/CasaOS-AppManagement/common"
Expand Down Expand Up @@ -144,6 +145,13 @@ func (a *AppManagement) ApplyComposeAppSettings(ctx echo.Context, id codegen.Com
} else {
xcasaosMap[common.ComposeExtensionPropertyNameIsUncontrolled] = true
composeApp.Extensions[common.ComposeExtensionNameXCasaOS] = xcasaosMap

// replace the buf is_uncontrolled is_uncontrolled: false => true
// otherwise, the new buf will be the same as the old one
// the replace is only in apply not install Compose. Because only the old compose has is_uncontrolled
// TODO: refactor the implement in a better way. not replace the string directly
buf = []byte(strings.ReplaceAll(string(buf), "is_uncontrolled: false", "is_uncontrolled: true"))

}
} else {
// set to controlled app
Expand All @@ -154,6 +162,9 @@ func (a *AppManagement) ApplyComposeAppSettings(ctx echo.Context, id codegen.Com
} else {
xcasaosMap[common.ComposeExtensionPropertyNameIsUncontrolled] = false
composeApp.Extensions[common.ComposeExtensionNameXCasaOS] = xcasaosMap

// replace the buf is_uncontrolled is_uncontrolled: true => false
buf = []byte(strings.ReplaceAll(string(buf), "is_uncontrolled: true", "is_uncontrolled: false"))
}
}

Expand Down

0 comments on commit de08559

Please sign in to comment.