-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1922 from madhu-pillai/bump_ignition_3.5
Stablize Ignition spec 3.5
- Loading branch information
Showing
185 changed files
with
5,727 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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 v3_5 | ||
|
||
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_4" | ||
"github.com/coreos/ignition/v2/config/v3_5/translate" | ||
"github.com/coreos/ignition/v2/config/v3_5/types" | ||
"github.com/coreos/ignition/v2/config/validate" | ||
|
||
"github.com/coreos/go-semver/semver" | ||
"github.com/coreos/vcontext/report" | ||
) | ||
|
||
func Merge(parent, child types.Config) types.Config { | ||
res, _ := merge.MergeStructTranscribe(parent, child) | ||
return res.(types.Config) | ||
} | ||
|
||
// Parse parses the raw config into a types.Config struct and generates a report of any | ||
// errors, warnings, info, and deprecations it encountered | ||
func Parse(rawConfig []byte) (types.Config, report.Report, error) { | ||
if len(rawConfig) == 0 { | ||
return types.Config{}, report.Report{}, errors.ErrEmpty | ||
} | ||
|
||
var config types.Config | ||
if rpt, err := util.HandleParseErrors(rawConfig, &config); err != nil { | ||
return types.Config{}, rpt, err | ||
} | ||
|
||
version, err := semver.NewVersion(config.Ignition.Version) | ||
|
||
if err != nil || *version != types.MaxVersion { | ||
return types.Config{}, report.Report{}, errors.ErrUnknownVersion | ||
} | ||
|
||
rpt := validate.ValidateWithContext(config, rawConfig) | ||
if rpt.IsFatal() { | ||
return types.Config{}, rpt, errors.ErrInvalid | ||
} | ||
|
||
return config, rpt, nil | ||
} | ||
|
||
// ParseCompatibleVersion parses the raw config of version 3.5.0 or | ||
// lesser into a 3.5 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) | ||
if err != nil { | ||
return types.Config{}, rpt, err | ||
} | ||
|
||
if version == types.MaxVersion { | ||
return Parse(raw) | ||
} | ||
prevCfg, r, err := prev.ParseCompatibleVersion(raw) | ||
if err != nil { | ||
return types.Config{}, r, err | ||
} | ||
return translate.Translate(prevCfg), r, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 5, | ||
} | ||
) | ||
|
||
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.
Oops, something went wrong.