Skip to content

Commit fa3af8b

Browse files
guillaumerosepraveenkumar
authored andcommitted
libmachine: move config version constant along with the struct Host
Version belongs only to this struct.
1 parent c6300a3 commit fa3af8b

5 files changed

Lines changed: 8 additions & 14 deletions

File tree

pkg/libmachine/host/host.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
"github.com/code-ready/machine/libmachine/state"
1313
)
1414

15+
// ConfigVersion dictates which version of the config.json format is
16+
// used. It needs to be bumped if there is a breaking change, and
17+
// therefore migration, introduced to the config file format.
18+
const Version = 3
19+
1520
type Host struct {
1621
ConfigVersion int
1722
Driver drivers.Driver

pkg/libmachine/host/migrate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77

88
"github.com/code-ready/crc/pkg/drivers/none"
9-
"github.com/code-ready/crc/pkg/libmachine/version"
109
)
1110

1211
var (
@@ -37,7 +36,7 @@ func MigrateHost(name string, data []byte) (*Host, error) {
3736
return nil, err
3837
}
3938

40-
if hostMetadata.ConfigVersion != version.ConfigVersion {
39+
if hostMetadata.ConfigVersion != Version {
4140
return nil, errUnexpectedConfigVersion
4241
}
4342

pkg/libmachine/libmachine.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/code-ready/crc/pkg/libmachine/host"
1111
"github.com/code-ready/crc/pkg/libmachine/mcnutils"
1212
"github.com/code-ready/crc/pkg/libmachine/persist"
13-
"github.com/code-ready/crc/pkg/libmachine/version"
1413
"github.com/code-ready/machine/libmachine/drivers"
1514
rpcdriver "github.com/code-ready/machine/libmachine/drivers/rpc"
1615
"github.com/code-ready/machine/libmachine/state"
@@ -52,7 +51,7 @@ func (api *Client) NewHost(driverName string, driverPath string, rawDriver []byt
5251
}
5352

5453
return &host.Host{
55-
ConfigVersion: version.ConfigVersion,
54+
ConfigVersion: host.Version,
5655
Name: driver.GetMachineName(),
5756
Driver: driver,
5857
DriverName: driver.DriverName(),

pkg/libmachine/persist/filestore_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/code-ready/crc/pkg/drivers/none"
1111
"github.com/code-ready/crc/pkg/libmachine/host"
12-
"github.com/code-ready/crc/pkg/libmachine/version"
1312
"github.com/stretchr/testify/assert"
1413
)
1514

@@ -125,7 +124,7 @@ func TestStoreLoad(t *testing.T) {
125124

126125
func testHost() *host.Host {
127126
return &host.Host{
128-
ConfigVersion: version.ConfigVersion,
127+
ConfigVersion: host.Version,
129128
Name: "test-host",
130129
Driver: none.NewDriver("test-host", "/tmp/artifacts"),
131130
DriverName: "none",

pkg/libmachine/version/version.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)