Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: stable
go-version: '1.26'
- name: Download dependencies
run: go mod download
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
version: v2.1
version: v2.12.2
skip-cache: true
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: 1.22
go-version: '1.26'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: ['1.26']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Set env vars
run: |
echo "CGO_ENABLED=0" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Test
run: go test ./...
27 changes: 24 additions & 3 deletions utils/odoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ import (

type envConverter func([]string) map[string]string

// NormalizeVersionForSemver normalizes Odoo version strings (e.g., saas-19.2, master)
// so they can be safely parsed by golang.org/x/mod/semver.
func NormalizeVersionForSemver(version string) string {
v := strings.TrimSpace(version)
if v == "master" {
return "v999.0"
}
v = strings.ReplaceAll(v, "saas-", "")
if !strings.HasPrefix(v, "v") {
v = "v" + v
}
// Add .0 if it's just a major version
if strings.Count(v, ".") == 0 {
v = v + ".0"
}
return v
}

// GetOdooUser is for future use, so far we do not plan to use other user that odoo to execute the instance
func GetOdooUser() string {
user := os.Getenv("ODOO_USER")
Expand Down Expand Up @@ -143,7 +161,8 @@ func SetupWorker(config *ini.File, containerType, version string) {
config.Section("options").Key("workers").SetValue("-1")
config.Section("options").Key("xmlrpcs").SetValue("False")
config.Section("options").Key("xmlrpc").SetValue("False")
if semver.Compare("v"+version, "v16.0") == -1 {
normalizedVersion := NormalizeVersionForSemver(version)
if semver.Compare(normalizedVersion, "v16.0") == -1 {
config.Section("options").Key("workers").SetValue("0")
}

Expand Down Expand Up @@ -189,12 +208,14 @@ func SetDefaults(config *ini.File, version string) {
config.Section("options").Key("gevent_port").SetValue("8072")
config.Section("options").Key("http_port").SetValue("8069")

if semver.Compare("v"+version, "v16.0") == -1 {
normalizedVersion := NormalizeVersionForSemver(version)

if semver.Compare(normalizedVersion, "v16.0") == -1 {
config.Section("options").Key("longpolling_port").SetValue("8072")
config.Section("options").Key("xmlrpc_port").SetValue("8069")
}

if semver.Compare("v"+version, "v13.0") == -1 {
if semver.Compare(normalizedVersion, "v13.0") == -1 {
config.Section("options").Key("logrotate").SetValue("False")
} else {
config.Section("options").DeleteKey("logrotate")
Expand Down
Loading