Skip to content
Snippets Groups Projects
Commit fbde45c9b52e authored by Florent Aide's avatar Florent Aide
Browse files

add support for controlling desired beaver version

parent 70ac01d7c668
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,34 @@
HISTORY
*******
3.2.3 (2024-03-01)
==================
- config file now contains a beaverversion entry. If this entry is not left blank, beaver will try
to match its version with the desired version. If the two versions do not match beaver will refuse
to process the resources to avoid getting a different results.
3.2.2 (2023-10-17)
==================
- disabled keyword in charts can now be a variable
3.2.1 (2023-10-17)
==================
- namespace beaver can now be a variable
3.2.0 (2023-10-17)
==================
- build namespace flag to force helm chart namespace
- bump ci to 1.20.6 to avoid vulncheck
- Fix logging: the wrong logger was used in 'build'
- [ytt] reverse the layer paths order on the command line
- ns name in rs name if ns exists in rs
- beaver now hydrate filename of rs
- recursive variable hydration support added
3.1.9 (2023-03-23)
==================
......
......@@ -44,6 +44,9 @@
```yaml
# Default namespace used for this project
namespace: default
# the desired beaver version. If the binary you use to process this file has a different
# version number, it will fail to avoid messing your resources.
beaverversion: 3.2.3
# an inherited beaver project - which can also inherit another beaver project
inherit: ../../base # path is relative to this beaver config file
inherits:
......
......@@ -17,6 +17,7 @@
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
......
......@@ -5,4 +5,5 @@
"os"
"path/filepath"
"github.com/hashicorp/go-version"
"gopkg.in/yaml.v3"
......@@ -8,4 +9,6 @@
"gopkg.in/yaml.v3"
beaver "orus.io/orus-io/beaver/lib"
)
// Sha define sha feature parameter
......@@ -58,6 +61,8 @@
// Inherit: relative path to another beaver project
// a beaver project is a folder with a beaver.yaml file
Inherit string
// BeaverVersion: the beaver version this config is supposed to work with.
BeaverVersion string
// NameSpace: a kubernetes Namespace, shouldn't be mandatory
NameSpace string
// Inherits: list of relative path to other beaver projects
......@@ -112,5 +117,11 @@
return &config, nil
}
if config.BeaverVersion != "" && beaver.Version() != "" {
if err := ControlVersions(config.BeaverVersion, beaver.Version()); err != nil {
return nil, err
}
}
return nil, fmt.Errorf("no beaver file found in %s", configDir)
}
......@@ -115,2 +126,20 @@
return nil, fmt.Errorf("no beaver file found in %s", configDir)
}
func ControlVersions(desired, actual string) error {
desiredVersion, err := version.NewVersion(desired)
if err != nil {
return fmt.Errorf("failed to parse desired beaver version: %w", err)
}
actualVersion, err := version.NewVersion(actual)
if err != nil {
return fmt.Errorf("failed to parse actual beaver version: %w", err)
}
if !desiredVersion.Equal(actualVersion) {
return fmt.Errorf("desired beaver version is not equal to actual beaver version, %s != %s", desiredVersion.String(), actualVersion.String())
}
return nil
}
......@@ -22,6 +22,7 @@
helmNamespaceFixtures = "fixtures/f3"
disabledAsVar = "fixtures/fDisabledAsVar"
namespaceAsVar = "fixtures/fNamespaceAsVar"
versionTest = "fixtures/versionTest"
)
func TestConfig(t *testing.T) {
......@@ -34,6 +35,20 @@
assert.Equal(t, "../vendor/ytt/odoo", config.Charts["odoo"].Path)
}
func TestConfigVersionValid(t *testing.T) {
config, err := runner.NewConfig(filepath.Join(versionTest, "validbase"))
require.NoError(t, err)
err = runner.ControlVersions(config.BeaverVersion, "3.2.3")
require.NoError(t, err)
}
func TestConfigVersionInValid(t *testing.T) {
config, err := runner.NewConfig(filepath.Join(versionTest, "invalidbase"))
require.NoError(t, err)
err = runner.ControlVersions(config.BeaverVersion, "3.2.3")
require.Error(t, err)
}
func TestBuildArgs(t *testing.T) {
config, err := runner.NewConfig(filepath.Join(helmNamespaceFixtures, "base"))
require.NoError(t, err)
......
beaverversion: 3.2.9
charts:
postgres:
type: helm
path: ../vendor/helm/postgresql
\ No newline at end of file
beaverversion: 3.2.3
charts:
postgres:
type: helm
path: ../vendor/helm/postgresql
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment