Skip to content

Commit

Permalink
Merge pull request #1558 from bgilbert/stabilize
Browse files Browse the repository at this point in the history
Stabilize spec 3.4.0; create spec 3.5.0-experimental
  • Loading branch information
bgilbert committed Feb 20, 2023
2 parents 0fd3a9e + c47043f commit 56a634f
Show file tree
Hide file tree
Showing 173 changed files with 5,690 additions and 96 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package config

import (
exp "github.com/coreos/ignition/v2/config/v3_4_experimental"
types_exp "github.com/coreos/ignition/v2/config/v3_4_experimental/types"
exp "github.com/coreos/ignition/v2/config/v3_5_experimental"
types_exp "github.com/coreos/ignition/v2/config/v3_5_experimental/types"

"github.com/coreos/vcontext/report"
)
Expand Down
4 changes: 3 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
v3_1 "github.com/coreos/ignition/v2/config/v3_1/types"
v3_2 "github.com/coreos/ignition/v2/config/v3_2/types"
v3_3 "github.com/coreos/ignition/v2/config/v3_3/types"
v3_4 "github.com/coreos/ignition/v2/config/v3_4_experimental/types"
v3_4 "github.com/coreos/ignition/v2/config/v3_4/types"
v3_5 "github.com/coreos/ignition/v2/config/v3_5_experimental/types"
)

type typeSet map[reflect.Type]struct{}
Expand Down Expand Up @@ -272,6 +273,7 @@ func TestConfigStructure(t *testing.T) {
reflect.TypeOf(v3_2.Config{}),
reflect.TypeOf(v3_3.Config{}),
reflect.TypeOf(v3_4.Config{}),
reflect.TypeOf(v3_5.Config{}),
}

for _, configType := range configs {
Expand Down
2 changes: 1 addition & 1 deletion config/merge/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/coreos/ignition/v2/config/util"
v3_2 "github.com/coreos/ignition/v2/config/v3_2/types"
"github.com/coreos/ignition/v2/config/v3_4_experimental/types"
"github.com/coreos/ignition/v2/config/v3_5_experimental/types"

"github.com/coreos/vcontext/path"
"github.com/stretchr/testify/assert"
Expand Down
10 changes: 5 additions & 5 deletions config/v3_4_experimental/config.go → config/v3_4/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v3_4_experimental
package v3_4

import (
"github.com/coreos/ignition/v2/config/merge"
"github.com/coreos/ignition/v2/config/shared/errors"
"github.com/coreos/ignition/v2/config/util"
prev "github.com/coreos/ignition/v2/config/v3_3"
"github.com/coreos/ignition/v2/config/v3_4_experimental/translate"
"github.com/coreos/ignition/v2/config/v3_4_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/translate"
"github.com/coreos/ignition/v2/config/v3_4/types"
"github.com/coreos/ignition/v2/config/validate"

"github.com/coreos/go-semver/semver"
Expand Down Expand Up @@ -58,8 +58,8 @@ func Parse(rawConfig []byte) (types.Config, report.Report, error) {
return config, rpt, nil
}

// ParseCompatibleVersion parses the raw config of version 3.4.0-experimental or
// lesser into a 3.4-exp types.Config struct and generates a report of any errors,
// ParseCompatibleVersion parses the raw config of version 3.4.0 or
// lesser into a 3.4 types.Config struct and generates a report of any errors,
// warnings, info, and deprecations it encountered
func ParseCompatibleVersion(raw []byte) (types.Config, report.Report, error) {
version, rpt, err := util.GetConfigVersion(raw)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v3_4_experimental
package v3_4

import (
"testing"

"github.com/coreos/ignition/v2/config/shared/errors"
"github.com/coreos/ignition/v2/config/v3_4_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/types"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -79,6 +79,10 @@ func TestParse(t *testing.T) {
in: in{config: []byte(`{"ignition": {"version": "3.3.0"}}`)},
out: out{err: errors.ErrUnknownVersion},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0"}}`)},
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
},
{
in: in{config: []byte(`{"ignition": {"version": "2.0.0-experimental"}}`)},
out: out{err: errors.ErrUnknownVersion},
Expand Down Expand Up @@ -121,7 +125,7 @@ func TestParse(t *testing.T) {
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0-experimental"}}`)},
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
out: out{err: errors.ErrUnknownVersion},
},
{
in: in{config: []byte(`{"ignition": {"version": "2.0.0"},}`)},
Expand All @@ -140,7 +144,7 @@ func TestParse(t *testing.T) {
out: out{err: errors.ErrEmpty},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
in: in{config: []byte(`{"ignition": {"version": "3.4.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
out: out{err: errors.ErrInvalid},
},
}
Expand All @@ -166,9 +170,13 @@ func TestParse(t *testing.T) {
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0-experimental"}}`)},
in: in{config: []byte(`{"ignition": {"version": "3.4.0"}}`)},
out: out{config: types.Config{Ignition: types.Ignition{Version: types.MaxVersion.String()}}},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0-experimental"}}`)},
out: out{err: errors.ErrUnknownVersion},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.5.0"}}`)},
out: out{err: errors.ErrUnknownVersion},
Expand All @@ -182,7 +190,7 @@ func TestParse(t *testing.T) {
out: out{err: errors.ErrInvalid},
},
{
in: in{config: []byte(`{"ignition": {"version": "3.4.0-experimental"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
in: in{config: []byte(`{"ignition": {"version": "3.4.0"}, "storage": {"filesystems": [{"format": "ext4", "label": "zzzzzzzzzzzzzzzzzzzzzzzzzzz"}]}}`)},
out: out{err: errors.ErrInvalid},
},
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/coreos/ignition/v2/config/translate"
"github.com/coreos/ignition/v2/config/util"
old_types "github.com/coreos/ignition/v2/config/v3_3/types"
"github.com/coreos/ignition/v2/config/v3_4_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/types"
)

func translateIgnition(old old_types.Ignition) (ret types.Ignition) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions config/v3_4/types/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2020 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package types

import (
"github.com/coreos/ignition/v2/config/shared/errors"
"github.com/coreos/ignition/v2/config/util"

"github.com/coreos/go-semver/semver"
"github.com/coreos/vcontext/path"
"github.com/coreos/vcontext/report"
)

var (
MaxVersion = semver.Version{
Major: 3,
Minor: 4,
}
)

func (cfg Config) Validate(c path.ContextPath) (r report.Report) {
systemdPath := "/etc/systemd/system/"
unitPaths := map[string]struct{}{}
for _, unit := range cfg.Systemd.Units {
if !util.NilOrEmpty(unit.Contents) {
pathString := systemdPath + unit.Name
unitPaths[pathString] = struct{}{}
}
for _, dropin := range unit.Dropins {
if !util.NilOrEmpty(dropin.Contents) {
pathString := systemdPath + unit.Name + ".d/" + dropin.Name
unitPaths[pathString] = struct{}{}
}
}
}
for i, f := range cfg.Storage.Files {
if _, exists := unitPaths[f.Path]; exists {
r.AddOnError(c.Append("storage", "files", i, "path"), errors.ErrPathConflictsSystemd)
}
}
for i, d := range cfg.Storage.Directories {
if _, exists := unitPaths[d.Path]; exists {
r.AddOnError(c.Append("storage", "directories", i, "path"), errors.ErrPathConflictsSystemd)
}
}
for i, l := range cfg.Storage.Links {
if _, exists := unitPaths[l.Path]; exists {
r.AddOnError(c.Append("storage", "links", i, "path"), errors.ErrPathConflictsSystemd)
}
}
return
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 56a634f

Please sign in to comment.