Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 477-import-selinux
Browse files Browse the repository at this point in the history
  • Loading branch information
yasminvalim committed Jan 4, 2024
2 parents 6f9bf5f + e859cb4 commit a419de4
Show file tree
Hide file tree
Showing 40 changed files with 2,381 additions and 90 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ RHCOS packaging for the current RHCOS development release:
- [ ] Get the PR reviewed and merge it
- [ ] Update your local repo and run `rhpkg build`
- [ ] File ticket similar to [this one](https://issues.redhat.com/browse/ART-3711) to sync the new version to mirror.openshift.com
- [ ] Wait until mirror.openshift.com is updated and confirm the new version is correct
CentOS Stream 9 packaging:
- [ ] Create a `rebase-c9s-butane` issue in the internal team-operations repo and follow the steps there
10 changes: 5 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
name: Test
strategy:
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x]
go-version: [1.20.x, 1.21.x]
os: [ubuntu-latest]
include:
- go-version: 1.20.x
- go-version: 1.21.x
os: macos-latest
- go-version: 1.20.x
- go-version: 1.21.x
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -48,7 +48,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
if: runner.os == 'Linux'
with:
version: v1.52.2
version: v1.55.1
args: -E=gofmt --timeout=30m0s
regenerate:
name: Regenerate
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: 1.21.x
- name: Regenerate
run: ./generate
- name: Check whether generated output is current
Expand Down
5 changes: 4 additions & 1 deletion config/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ var (
ErrMountPointForbidden = errors.New("path must be under /etc or /var if with_mount_unit is true")

// boot device
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, x86_64")
ErrUnknownBootDeviceLayout = errors.New("layout must be one of: aarch64, ppc64le, s390x-eckd, s390x-virt, s390x-zfcp, x86_64")
ErrTooFewMirrorDevices = errors.New("mirroring requires at least two devices")
ErrNoLuksBootDevice = errors.New("device is required for layouts: s390x-eckd, s390x-zfcp")
ErrMirrorNotSupport = errors.New("mirroring not supported on layouts: s390x-eckd, s390x-zfcp, s390x-virt")
ErrLuksBootDeviceBadName = errors.New("device name must start with /dev/dasd on s390x-eckd layout or /dev/sd on s390x-zfcp layout")

// partition
ErrReuseByLabel = errors.New("partitions cannot be reused by label; number must be specified except on boot disk (/dev/disk/by-id/coreos-boot-disk) or when wipe_table is true")
Expand Down
10 changes: 8 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ import (
fcos1_4 "github.com/coreos/butane/config/fcos/v1_4"
fcos1_5 "github.com/coreos/butane/config/fcos/v1_5"
fcos1_6_exp "github.com/coreos/butane/config/fcos/v1_6_exp"
fiot1_0 "github.com/coreos/butane/config/fiot/v1_0"
fiot1_1_exp "github.com/coreos/butane/config/fiot/v1_1_exp"
flatcar1_0 "github.com/coreos/butane/config/flatcar/v1_0"
flatcar1_1 "github.com/coreos/butane/config/flatcar/v1_1"
flatcar1_2_exp "github.com/coreos/butane/config/flatcar/v1_2_exp"
openshift4_10 "github.com/coreos/butane/config/openshift/v4_10"
openshift4_11 "github.com/coreos/butane/config/openshift/v4_11"
openshift4_12 "github.com/coreos/butane/config/openshift/v4_12"
openshift4_13 "github.com/coreos/butane/config/openshift/v4_13"
openshift4_14_exp "github.com/coreos/butane/config/openshift/v4_14_exp"
openshift4_14 "github.com/coreos/butane/config/openshift/v4_14"
openshift4_15_exp "github.com/coreos/butane/config/openshift/v4_15_exp"
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 @@ -71,10 +74,13 @@ func init() {
RegisterTranslator("openshift", "4.11.0", openshift4_11.ToConfigBytes)
RegisterTranslator("openshift", "4.12.0", openshift4_12.ToConfigBytes)
RegisterTranslator("openshift", "4.13.0", openshift4_13.ToConfigBytes)
RegisterTranslator("openshift", "4.14.0-experimental", openshift4_14_exp.ToConfigBytes)
RegisterTranslator("openshift", "4.14.0", openshift4_14.ToConfigBytes)
RegisterTranslator("openshift", "4.15.0-experimental", openshift4_15_exp.ToConfigBytes)
RegisterTranslator("r4e", "1.0.0", r4e1_0.ToIgn3_3Bytes)
RegisterTranslator("r4e", "1.1.0", r4e1_1.ToIgn3_4Bytes)
RegisterTranslator("r4e", "1.2.0-experimental", r4e1_2_exp.ToIgn3_5Bytes)
RegisterTranslator("fiot", "1.0.0", fiot1_0.ToIgn3_4Bytes)
RegisterTranslator("fiot", "1.1.0-experimental", fiot1_1_exp.ToIgn3_5Bytes)
RegisterTranslator("rhcos", "0.1.0", unsupportedRhcosVariant)
}

Expand Down
1 change: 1 addition & 0 deletions config/fcos/v1_6_exp/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type BootDevice struct {

type BootDeviceLuks struct {
Discard *bool `yaml:"discard"`
Device *string `yaml:"device"`
Tang []base.Tang `yaml:"tang"`
Threshold *int `yaml:"threshold"`
Tpm2 *bool `yaml:"tpm2"`
Expand Down
13 changes: 11 additions & 2 deletions config/fcos/v1_6_exp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio
wantEFIPart = true
case *layout == "ppc64le":
wantPRePPart = true
case *layout == "s390x-eckd" || *layout == "s390x-virt" || *layout == "s390x-zfcp":
default:
// should have failed validation
panic("unknown layout")
Expand Down Expand Up @@ -250,9 +251,17 @@ func (c Config) processBootDevice(config *types.Config, ts *translate.Translatio

// encrypted root partition
if wantLuks {
luksDevice := "/dev/disk/by-partlabel/root"
if wantMirror {
var luksDevice string
switch {
//Luks Device for dasd and zFCP-scsi
case layout != nil && *layout == "s390x-eckd":
luksDevice = *c.BootDevice.Luks.Device + "2"
case layout != nil && *layout == "s390x-zfcp":
luksDevice = *c.BootDevice.Luks.Device + "4"
case wantMirror:
luksDevice = "/dev/md/md-root"
default:
luksDevice = "/dev/disk/by-partlabel/root"
}
clevis, ts2, r2 := translateBootDeviceLuks(c.BootDevice.Luks, options)
rendered.Storage.Luks = []types.Luks{{
Expand Down
21 changes: 21 additions & 0 deletions config/fcos/v1_6_exp/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
const rootDevice = "/dev/disk/by-id/coreos-boot-disk"

var allowedMountpoints = regexp.MustCompile(`^/(etc|var)(/|$)`)
var dasdRe = regexp.MustCompile("(/dev/dasd[a-z]$)")
var sdRe = regexp.MustCompile("(/dev/sd[a-z]$)")

// We can't define a Validate function directly on Disk because that's defined in base,
// so we use a Validate function on the top-level Config instead.
Expand All @@ -52,9 +54,28 @@ func (d BootDevice) Validate(c path.ContextPath) (r report.Report) {
if d.Layout != nil {
switch *d.Layout {
case "aarch64", "ppc64le", "x86_64":
case "s390x-eckd":
if util.NilOrEmpty(d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
} else if !dasdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrLuksBootDeviceBadName)
}
case "s390x-zfcp":
if util.NilOrEmpty(d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrNoLuksBootDevice)
} else if !sdRe.MatchString(*d.Luks.Device) {
r.AddOnError(c.Append(*d.Layout), common.ErrLuksBootDeviceBadName)
}
case "s390x-virt":
default:
r.AddOnError(c.Append("layout"), common.ErrUnknownBootDeviceLayout)
}

if *d.Layout == "s390x-eckd" || *d.Layout == "s390x-zfcp" || *d.Layout == "s390x-virt" {
if len(d.Mirror.Devices) > 0 {
r.AddOnError(c.Append(*d.Layout), common.ErrMirrorNotSupport)
}
}
}
r.Merge(d.Mirror.Validate(c.Append("mirror")))
return
Expand Down
23 changes: 23 additions & 0 deletions config/fiot/v1_0/schema.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 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 v1_0

import (
base "github.com/coreos/butane/base/v0_5"
)

type Config struct {
base.Config `yaml:",inline"`
}
54 changes: 54 additions & 0 deletions config/fiot/v1_0/translate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2022 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 v1_0

import (
"github.com/coreos/butane/config/common"
cutil "github.com/coreos/butane/config/util"

"github.com/coreos/ignition/v2/config/v3_4/types"
"github.com/coreos/vcontext/report"
)

var (
fieldFilters = cutil.NewFilters(types.Config{}, cutil.FilterMap{
"kernelArguments": common.ErrGeneralKernelArgumentSupport,
"storage.disks": common.ErrDiskSupport,
"storage.filesystems": common.ErrFilesystemSupport,
"storage.luks": common.ErrLuksSupport,
"storage.raid": common.ErrRaidSupport,
})
)

// Return FieldFilters for this spec.
func (c Config) FieldFilters() *cutil.FieldFilters {
return &fieldFilters
}

// 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_4(options common.TranslateOptions) (types.Config, report.Report, error) {
cfg, r, err := cutil.Translate(c, "ToIgn3_4Unvalidated", options)
return cfg.(types.Config), r, err
}

// ToIgn3_4Bytes translates from a v1.1 Butane config to a v3.4.0 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 ToIgn3_4Bytes(input []byte, options common.TranslateBytesOptions) ([]byte, report.Report, error) {
return cutil.TranslateBytes(input, &Config{}, "ToIgn3_4", options)
}
Loading

0 comments on commit a419de4

Please sign in to comment.