Skip to content

Commit

Permalink
[FIX] Remove deprecated Odoo paremeters
Browse files Browse the repository at this point in the history
Since v16.0 Odoo replaced longpolling_port and xmlrpc_port with gevent_port and http_port, when the older names are present it will show some anoying warnings.

Updated the workflow files to match the newer versions and Golang.
  • Loading branch information
ruiztulio committed Dec 10, 2024
1 parent caf6a11 commit 23add96
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 19 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29
skip-go-installation: true
version: v1.61
skip-cache: true
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.22
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --rm-dist
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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.18.x]
go-version: [1.22.x]
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@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Test
run: go test ./...
14 changes: 13 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module entrypoint

go 1.16
go 1.22.0

toolchain go1.23.4

require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
Expand All @@ -10,3 +12,13 @@ require (
github.com/stretchr/testify v1.3.0
gopkg.in/ini.v1 v1.51.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)
5 changes: 4 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -241,8 +243,9 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
27 changes: 23 additions & 4 deletions utils/odoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package utils

import (
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/ini.v1"
"os"
"path/filepath"
"strconv"
"strings"

log "github.com/sirupsen/logrus"
"golang.org/x/mod/semver"
"gopkg.in/ini.v1"
)

type envConverter func([]string) map[string]string
Expand Down Expand Up @@ -177,14 +179,20 @@ func UpdateFromVars(config *ini.File, odooVars map[string]string, appendNew bool
// - Won't allow admin as default super user password, a random string is generated
// - Won't allow to change the default ports because inside the container is not needed and will mess with the external
// - Disable logrotate since supervisor will handle that
func SetDefaults(config *ini.File) {
func SetDefaults(config *ini.File, version string) {
config.Section("options").Key("xmlrpc_port").SetValue("8069")
config.Section("options").Key("longpolling_port").SetValue("8072")
config.Section("options").Key("logrorate").SetValue("False")
if config.Section("options").Key("admin_passwd").Value() == "admin" ||
config.Section("options").Key("admin_passwd").Value() == "" {
config.Section("options").Key("admin_passwd").SetValue(RandStringRunes(64))
}
if semver.Compare(version, "v16.0") != -1 {
config.Section("options").DeleteKey("longpolling_port")
config.Section("options").DeleteKey("xmlrpc_port")
config.Section("options").Key("gevent_port").SetValue("8072")
config.Section("options").Key("http_port").SetValue("8069")
}
}

// Odoo this func coordinates all the odoo configuration loading the config file, calling all the methods needed to
Expand Down Expand Up @@ -214,7 +222,7 @@ func Odoo() error {
}
log.Debugf("Instance type: %s", instanceType)
UpdateSentry(odooCfg, instanceType)
SetDefaults(odooCfg)
SetDefaults(odooCfg, parseVersion(os.Getenv("VERSION")))
autostart := true
if os.Getenv("AUTOSTART") != "" {
autostart, err = strconv.ParseBool(os.Getenv("AUTOSTART"))
Expand Down Expand Up @@ -275,3 +283,14 @@ func prepareFiles() error {
}
return nil
}

func parseVersion(v string) string {
wV := strings.ToLower(v)
if strings.Contains(wV, "saas") {
parts := strings.SplitN(v, "-", 2)
if len(parts) == 2 {
return "v" + parts[1]
}
}
return "v" + v
}
24 changes: 24 additions & 0 deletions utils/odoo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ func TestGetInstanceType(t *testing.T) {
assert.Errorf(t, err, "cannot determine the instance type, env vars INSTANCE_TYPE and ODOO_STAGE 'must' match")
}

func TestParseVersion(t *testing.T) {
test := []struct {
given string
want string
}{
{
given: "17.0",
want: "v17.0",
},
{
given: "saas-8",
want: "v8",
},
{
given: "saas-17.4",
want: "v17.4",
},
}

for _, c := range test {
assert.Equal(t, c.want, parseVersion(c.given))
}
}

//func TestUpdateSentry(t *testing.T) {
// values := []struct{
// input map[string]string
Expand Down

0 comments on commit 23add96

Please sign in to comment.