Skip to content

Commit

Permalink
openshift/v4.18: Stabilize 4.18.0 spec
Browse files Browse the repository at this point in the history
fixes: #564
  • Loading branch information
yasminvalim committed Nov 27, 2024
1 parent a982e39 commit 75d7dff
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package result

import (
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/types"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.)

package v4_18_exp
package v4_18

import (
fcos "github.com/coreos/butane/config/fcos/v1_7_exp"
fcos "github.com/coreos/butane/config/fcos/v1_6"
)

const ROLE_LABEL_KEY = "machineconfiguration.openshift.io/role"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.)

package v4_18_exp
package v4_18

import (
"net/url"
"strings"

"github.com/coreos/butane/config/common"
"github.com/coreos/butane/config/openshift/v4_18_exp/result"
"github.com/coreos/butane/config/openshift/v4_18/result"
cutil "github.com/coreos/butane/config/util"
"github.com/coreos/butane/translate"

"github.com/coreos/ignition/v2/config/util"
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/types"
"github.com/coreos/vcontext/path"
"github.com/coreos/vcontext/report"
)
Expand Down Expand Up @@ -113,11 +113,10 @@ func (c Config) FieldFilters() *cutil.FieldFilters {
// can be tracked back to their source in the source config. No config
// validation is performed on input or output.
func (c Config) ToMachineConfig4_18Unvalidated(options common.TranslateOptions) (result.MachineConfig, translate.TranslationSet, report.Report) {
cfg, ts, r := c.Config.ToIgn3_6Unvalidated(options)
cfg, ts, r := c.Config.ToIgn3_4Unvalidated(options)
if r.IsFatal() {
return result.MachineConfig{}, ts, r
}
ts = translateUserGrubCfg(&cfg, &ts)

// wrap
ts = ts.PrefixPaths(path.New("yaml"), path.New("json", "spec", "config"))
Expand Down Expand Up @@ -174,11 +173,11 @@ func (c Config) ToMachineConfig4_18(options common.TranslateOptions) (result.Mac
return cfg.(result.MachineConfig), r, err
}

// ToIgn3_6Unvalidated translates the config to an Ignition config. It also
// ToIgn63_4Unvalidated translates the config to an Ignition config. It also
// returns the set of translations it did so paths in the resultant config
// can be tracked back to their source in the source config. No config
// validation is performed on input or output.
func (c Config) ToIgn3_6Unvalidated(options common.TranslateOptions) (types.Config, translate.TranslationSet, report.Report) {
func (c Config) ToIgn3_4Unvalidated(options common.TranslateOptions) (types.Config, translate.TranslationSet, report.Report) {
mc, ts, r := c.ToMachineConfig4_18Unvalidated(options)
cfg := mc.Spec.Config

Expand All @@ -194,12 +193,12 @@ func (c Config) ToIgn3_6Unvalidated(options common.TranslateOptions) (types.Conf
return cfg, ts, r
}

// ToIgn3_6 translates the config to an Ignition config. It returns a
// ToIgn3_4 translates the config to an Ignition config. It returns a
// report of any errors or warnings in the source and resultant config. If
// the report has fatal errors or it encounters other problems translating,
// an error is returned.
func (c Config) ToIgn3_6(options common.TranslateOptions) (types.Config, report.Report, error) {
cfg, r, err := cutil.Translate(c, "ToIgn3_6Unvalidated", options)
func (c Config) ToIgn3_4(options common.TranslateOptions) (types.Config, report.Report, error) {
cfg, r, err := cutil.Translate(c, "ToIgn3_4Unvalidated", options)
return cfg.(types.Config), r, err
}

Expand All @@ -208,7 +207,7 @@ func (c Config) ToIgn3_6(options common.TranslateOptions) (types.Config, report.
// translating, an error is returned.
func ToConfigBytes(input []byte, options common.TranslateBytesOptions) ([]byte, report.Report, error) {
if options.Raw {
return cutil.TranslateBytes(input, &Config{}, "ToIgn3_6", options)
return cutil.TranslateBytes(input, &Config{}, "ToIgn3_4", options)
} else {
return cutil.TranslateBytesYAML(input, &Config{}, "ToMachineConfig4_18", options)
}
Expand Down Expand Up @@ -302,26 +301,3 @@ func validateMCOSupport(mc result.MachineConfig) report.Report {
}
return r
}

// fcos config generates a user.cfg file using append; however, OpenShift config
// does not support append (since MCO does not support it). Let change the file to use contents
func translateUserGrubCfg(config *types.Config, ts *translate.TranslationSet) translate.TranslationSet {
newMappings := translate.NewTranslationSet("json", "json")
for i, file := range config.Storage.Files {
if file.Path == "/boot/grub2/user.cfg" {
if len(file.Append) != 1 {
// The number of append objects was different from expected, this file
// was created by the user and not via butane GRUB sugar
return *ts
}
fromPath := path.New("json", "storage", "files", i, "append", 0)
translatedPath := path.New("json", "storage", "files", i, "contents")
config.Storage.Files[i].FileEmbedded1.Contents = file.Append[0]
config.Storage.Files[i].FileEmbedded1.Append = nil
newMappings.AddFromCommonObject(fromPath, translatedPath, config.Storage.Files[i].FileEmbedded1.Contents)

return ts.Map(newMappings)
}
}
return *ts
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.)

package v4_18_exp
package v4_18

import (
"fmt"
"testing"

baseutil "github.com/coreos/butane/base/util"
base "github.com/coreos/butane/base/v0_7_exp"
base "github.com/coreos/butane/base/v0_6"
"github.com/coreos/butane/config/common"
fcos "github.com/coreos/butane/config/fcos/v1_7_exp"
"github.com/coreos/butane/config/openshift/v4_18_exp/result"
fcos "github.com/coreos/butane/config/fcos/v1_6"
"github.com/coreos/butane/config/openshift/v4_18/result"
confutil "github.com/coreos/butane/config/util"
"github.com/coreos/butane/translate"

"github.com/coreos/ignition/v2/config/util"
"github.com/coreos/ignition/v2/config/v3_6_experimental/types"
"github.com/coreos/ignition/v2/config/v3_4/types"
"github.com/coreos/vcontext/path"
"github.com/coreos/vcontext/report"
"github.com/stretchr/testify/assert"
Expand All @@ -52,7 +52,7 @@ func TestElidedFieldWarning(t *testing.T) {
expected.AddOnWarn(path.New("yaml", "openshift", "fips"), common.ErrFieldElided)
expected.AddOnWarn(path.New("yaml", "openshift", "kernel_type"), common.ErrFieldElided)

_, _, r := in.ToIgn3_6Unvalidated(common.TranslateOptions{})
_, _, r := in.ToIgn3_4Unvalidated(common.TranslateOptions{})
assert.Equal(t, expected, r, "report mismatch")
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func TestTranslateConfig(t *testing.T) {
Spec: result.Spec{
Config: types.Config{
Ignition: types.Ignition{
Version: "3.6.0-experimental",
Version: "3.4.0",
},
},
},
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestTranslateConfig(t *testing.T) {
Spec: result.Spec{
Config: types.Config{
Ignition: types.Ignition{
Version: "3.6.0-experimental",
Version: "3.4.0",
},
Storage: types.Storage{
Filesystems: []types.Filesystem{
Expand Down Expand Up @@ -272,89 +272,6 @@ func TestTranslateConfig(t *testing.T) {
{From: path.New("yaml", "openshift", "fips"), To: path.New("json", "spec", "fips")},
},
},
// Test Grub config
{
Config{
Metadata: Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Config: fcos.Config{
Grub: fcos.Grub{
Users: []fcos.GrubUser{
{
Name: "root",
PasswordHash: util.StrToPtr("grub.pbkdf2.sha512.10000.874A958E526409..."),
},
},
},
},
},
result.MachineConfig{
ApiVersion: result.MC_API_VERSION,
Kind: result.MC_KIND,
Metadata: result.Metadata{
Name: "z",
Labels: map[string]string{
ROLE_LABEL_KEY: "z",
},
},
Spec: result.Spec{
Config: types.Config{
Ignition: types.Ignition{
Version: "3.6.0-experimental",
},
Storage: types.Storage{
Filesystems: []types.Filesystem{
{
Device: "/dev/disk/by-label/boot",
Format: util.StrToPtr("ext4"),
Path: util.StrToPtr("/boot"),
},
},
Files: []types.File{
{
Node: types.Node{
Path: "/boot/grub2/user.cfg",
},
FileEmbedded1: types.FileEmbedded1{
Contents: types.Resource{
Source: util.StrToPtr("data:,%23%20Generated%20by%20Butane%0A%0Aset%20superusers%3D%22root%22%0Apassword_pbkdf2%20root%20grub.pbkdf2.sha512.10000.874A958E526409...%0A"),
Compression: util.StrToPtr(""),
},
},
},
},
},
},
},
},
[]translate.Translation{
{From: path.New("yaml", "version"), To: path.New("json", "apiVersion")},
{From: path.New("yaml", "version"), To: path.New("json", "kind")},
{From: path.New("yaml", "version"), To: path.New("json", "spec")},
{From: path.New("yaml"), To: path.New("json", "spec", "config")},
{From: path.New("yaml", "ignition"), To: path.New("json", "spec", "config", "ignition")},
{From: path.New("yaml", "version"), To: path.New("json", "spec", "config", "ignition", "version")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0)},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "path")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "device")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "format")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0)},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "path")},
// "append" field is a remnant of translations performed in fcos config
// TODO: add a delete function to translation.TranslationSet and delete "append" translation
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "append")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents", "source")},
{From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents", "compression")},
},
},
}

for i, test := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.)

package v4_18_exp
package v4_18

import (
"github.com/coreos/butane/config/common"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.)

package v4_18_exp
package v4_18

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
---
# This file is automatically generated from internal/doc and Ignition's
# config/doc. Do not edit.
title: OpenShift v4.18.0-experimental
title: OpenShift v4.18.0
parent: Configuration specifications
nav_order: 150
---

# OpenShift Specification v4.18.0-experimental
# OpenShift Specification v4.18.0

**Note: This configuration is experimental and has not been stabilized. It is subject to change without warning or announcement.**

The OpenShift configuration is a YAML document conforming to the following specification, with **_italicized_** entries being optional:

<div id="spec-docs"></div>

* **variant** (string): used to differentiate configs for different operating systems. Must be `openshift` for this specification.
* **version** (string): the semantic version of the spec for this document. This document is for version `4.18.0-experimental` and generates Ignition configs with version `3.6.0-experimental`.
* **version** (string): the semantic version of the spec for this document. This document is for version `4.18.0` and generates Ignition configs with version `3.4.0`.
* **metadata** (object): metadata about the generated MachineConfig resource. Respected when rendering to a MachineConfig, ignored when rendering directly to an Ignition config.
* **name** (string): a unique [name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names) for this MachineConfig resource.
* **labels** (object): string key/value pairs to apply as [Kubernetes labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) to this MachineConfig resource. `machineconfiguration.openshift.io/role` is required.
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ key](https://getfedora.org/security/).

### Features

- Stabilize OpenShift spec 4.18.0, targeting Ignition spec 3.4.0
- Stabilize Fcos spec 1.6.0, targeting Ignition spec 3.5.0
- Add Fcos spec 1.7.0-experimental, targeting Ignition spec
3.6.0-experimental
Expand Down
3 changes: 2 additions & 1 deletion docs/specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ We recommend that you always use the latest **stable** specification for your op
- [v1.1.0](config-flatcar-v1_1.md)
- [v1.0.0](config-flatcar-v1_0.md)
- OpenShift (`openshift`)
- [v4.18.0](config-openshift-v4_18.md)
- [v4.17.0](config-openshift-v4_17.md)
- [v4.16.0](config-openshift-v4_16.md)
- [v4.15.0](config-openshift-v4_15.md)
Expand Down Expand Up @@ -84,7 +85,7 @@ Each version of the Butane specification corresponds to a version of the Ignitio
| `openshift` | 4.15.0 | 3.4.0 |
| `openshift` | 4.16.0 | 3.4.0 |
| `openshift` | 4.17.0 | 3.4.0 |
| `openshift` | 4.18.0-experimental | 3.5.0-experimental |
| `openshift` | 4.18.0 | 3.4.0 |
| `r4e` | 1.0.0 | 3.3.0 |
| `r4e` | 1.1.0 | 3.4.0 |
| `r4e` | 1.2.0-experimental | 3.5.0-experimental |
Expand Down
2 changes: 1 addition & 1 deletion internal/doc/butane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ root:
- variant: fcos
min: 1.6.0-experimental
- variant: openshift
min: 4.18.0-experimental
min: 4.19.0-experimental
- name: luks
desc: describes the clevis configuration for encrypting the root filesystem.
children:
Expand Down
5 changes: 3 additions & 2 deletions internal/doc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import (
openshift4_15 "github.com/coreos/butane/config/openshift/v4_15"
openshift4_16 "github.com/coreos/butane/config/openshift/v4_16"
openshift4_17 "github.com/coreos/butane/config/openshift/v4_17"
openshift4_18_exp "github.com/coreos/butane/config/openshift/v4_18_exp"
openshift4_18 "github.com/coreos/butane/config/openshift/v4_18"
openshift4_8 "github.com/coreos/butane/config/openshift/v4_8"
openshift4_9 "github.com/coreos/butane/config/openshift/v4_9"
r4e1_0 "github.com/coreos/butane/config/r4e/v1_0"
Expand Down Expand Up @@ -128,7 +128,7 @@ func generate(dir string) error {
"openshift",
[]version{
// inverse order of website navbar
{"4.18.0-experimental", openshift4_18_exp.Config{}},
{"4.18.0", openshift4_18.Config{}},
{"4.8.0", openshift4_8.Config{}},
{"4.9.0", openshift4_9.Config{}},
{"4.10.0", openshift4_10.Config{}},
Expand All @@ -139,6 +139,7 @@ func generate(dir string) error {
{"4.15.0", openshift4_15.Config{}},
{"4.16.0", openshift4_16.Config{}},
{"4.17.0", openshift4_17.Config{}},
{"4.18.0", openshift4_18.Config{}},
},
},
{
Expand Down

0 comments on commit 75d7dff

Please sign in to comment.