diff --git a/mantle/go.mod b/mantle/go.mod index 6b9cc12fd3..90406232cd 100644 --- a/mantle/go.mod +++ b/mantle/go.mod @@ -11,11 +11,11 @@ require ( github.com/aliyun/alibaba-cloud-sdk-go v1.61.1442 github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible github.com/aws/aws-sdk-go v1.34.28 - github.com/coreos/butane v0.16.0 + github.com/coreos/butane v0.17.0 github.com/coreos/coreos-assembler v0.14.0 github.com/coreos/go-semver v0.3.0 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e - github.com/coreos/go-systemd/v22 v22.4.0 + github.com/coreos/go-systemd/v22 v22.5.0 github.com/coreos/ignition/v2 v2.14.0 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f github.com/coreos/stream-metadata-go v0.4.0 @@ -70,7 +70,7 @@ require ( github.com/satori/go.uuid v1.2.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace // indirect - github.com/stretchr/testify v1.8.0 // indirect + github.com/stretchr/testify v1.8.1 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect diff --git a/mantle/go.sum b/mantle/go.sum index 19de4ce716..f7f185ee43 100644 --- a/mantle/go.sum +++ b/mantle/go.sum @@ -65,8 +65,8 @@ github.com/clarketm/json v1.17.1 h1:U1IxjqJkJ7bRK4L6dyphmoO840P6bdhPdbbLySourqI= github.com/clarketm/json v1.17.1/go.mod h1:ynr2LRfb0fQU34l07csRNBTcivjySLLiY1YzQqKVfdo= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/coreos/butane v0.16.0 h1:qIH6H9O5lF+NfX7Msz6b4+MezZ68zYCNXBjTPbgnlyU= -github.com/coreos/butane v0.16.0/go.mod h1:7TBe8e7UqDtqsR9pMZl/mKeYT1QYTAFcAiGF5ivUaaQ= +github.com/coreos/butane v0.17.0 h1:iVpxfzMVrxKwDnfzFZktMsZLxOeENmYsc7dIDridgAs= +github.com/coreos/butane v0.17.0/go.mod h1:rDdKVjZIA5XaxHaqgYuFmBzKPZcMoABOKgKd5qInMeM= github.com/coreos/go-json v0.0.0-20211020211907-c63f628265de/go.mod h1:lryFBkhadOfv8Jue2Vr/f/Yviw8h1DQPQojbXqEChY0= github.com/coreos/go-json v0.0.0-20220810161552-7cce03887f34 h1:14qC8Go5ArRXeK4neVu4GwD/2KZcLsRotqGW7eBRqwk= github.com/coreos/go-json v0.0.0-20220810161552-7cce03887f34/go.mod h1:jdmhE6D2v5tisGyVw92x7/r3USTNm2VAkdRZ4ZydKQk= @@ -75,8 +75,8 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.4.0 h1:y9YHcjnjynCd/DVbg5j9L/33jQM3MxJlbj/zWskzfGU= -github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/ignition/v2 v2.14.0 h1:KfkCCnA6AK0kts/1zxzzNH5lDMCQN9sqqGcGs+RJVX4= github.com/coreos/ignition/v2 v2.14.0/go.mod h1:wxc4qdYEIHLygzWbVVEuoD7lQGTZmMgX0VjAPYBbeEQ= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= @@ -300,6 +300,7 @@ github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -307,8 +308,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= diff --git a/mantle/vendor/github.com/coreos/butane/config/common/errors.go b/mantle/vendor/github.com/coreos/butane/config/common/errors.go index 1961f00749..33e422a0ab 100644 --- a/mantle/vendor/github.com/coreos/butane/config/common/errors.go +++ b/mantle/vendor/github.com/coreos/butane/config/common/errors.go @@ -60,19 +60,23 @@ var ( ErrInvalidKernelType = errors.New("must be empty, \"default\", or \"realtime\"") ErrBtrfsSupport = errors.New("btrfs is not supported in this spec version") ErrFilesystemNoneSupport = errors.New("format \"none\" is not supported in this spec version") - ErrDirectorySupport = errors.New("directories are not supported in this spec version") ErrFileSchemeSupport = errors.New("file contents source must be data URL in this spec version") ErrFileAppendSupport = errors.New("appending to files is not supported in this spec version") ErrFileCompressionSupport = errors.New("file compression is not supported in this spec version") ErrFileSpecialModeSupport = errors.New("special mode bits are not supported in this spec version") - ErrLinkSupport = errors.New("links are not supported in this spec version") ErrGroupSupport = errors.New("groups are not supported in this spec version") ErrUserFieldSupport = errors.New("fields other than \"name\" and \"ssh_authorized_keys\" are not supported in this spec version") ErrUserNameSupport = errors.New("users other than \"core\" are not supported in this spec version") ErrKernelArgumentSupport = errors.New("this field cannot be used for kernel arguments in this spec version; use openshift.kernel_arguments instead") // Storage - ErrClevisSupport = errors.New("clevis is not supported in this spec version") + ErrClevisSupport = errors.New("clevis is not supported in this spec version") + ErrDirectorySupport = errors.New("directories are not supported in this spec version") + ErrDiskSupport = errors.New("disk customization is not supported in this spec version") + ErrFilesystemSupport = errors.New("filesystem customization is not supported in this spec version") + ErrLinkSupport = errors.New("links are not supported in this spec version") + ErrLuksSupport = errors.New("luks is not supported in this spec version") + ErrRaidSupport = errors.New("raid is not supported in this spec version") // Extensions ErrExtensionNameRequired = errors.New("field \"name\" is required") @@ -80,4 +84,7 @@ var ( // Grub ErrGrubUserNameNotSpecified = errors.New("field \"name\" is required") ErrGrubPasswordNotSpecified = errors.New("field \"password_hash\" is required") + + // Kernel arguments + ErrGeneralKernelArgumentSupport = errors.New("kernel argument customization is not supported in this spec version") ) diff --git a/mantle/vendor/github.com/coreos/butane/config/config.go b/mantle/vendor/github.com/coreos/butane/config/config.go index 61719477f3..b9bbbd8d06 100644 --- a/mantle/vendor/github.com/coreos/butane/config/config.go +++ b/mantle/vendor/github.com/coreos/butane/config/config.go @@ -32,6 +32,8 @@ import ( openshift4_13_exp "github.com/coreos/butane/config/openshift/v4_13_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" + r4e1_1_exp "github.com/coreos/butane/config/r4e/v1_1_exp" rhcos0_1 "github.com/coreos/butane/config/rhcos/v0_1" "github.com/coreos/go-semver/semver" @@ -64,6 +66,8 @@ func init() { RegisterTranslator("openshift", "4.11.0", openshift4_11.ToConfigBytes) RegisterTranslator("openshift", "4.12.0", openshift4_12.ToConfigBytes) RegisterTranslator("openshift", "4.13.0-experimental", openshift4_13_exp.ToConfigBytes) + RegisterTranslator("r4e", "1.0.0", r4e1_0.ToIgn3_3Bytes) + RegisterTranslator("r4e", "1.1.0-experimental", r4e1_1_exp.ToIgn3_4Bytes) RegisterTranslator("rhcos", "0.1.0", rhcos0_1.ToIgn3_2Bytes) } diff --git a/mantle/vendor/github.com/coreos/butane/config/fcos/v1_5_exp/translate.go b/mantle/vendor/github.com/coreos/butane/config/fcos/v1_5_exp/translate.go index f2eec2fd0c..e5913f6a30 100644 --- a/mantle/vendor/github.com/coreos/butane/config/fcos/v1_5_exp/translate.go +++ b/mantle/vendor/github.com/coreos/butane/config/fcos/v1_5_exp/translate.go @@ -335,7 +335,11 @@ func (c Config) processPackages(options common.TranslateOptions) (types.Config, return ret, ts, r } hash := sha256.New() - hash.Write([]byte(src)) + count, err := hash.Write([]byte(src)) + if count != len(src) || err != nil { + // hash write shouldn't fail + panic(fmt.Sprintf("short write to hash: %v", err)) + } sha := hex.EncodeToString(hash.Sum(nil))[0:7] file := types.File{ Node: types.Node{ diff --git a/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/schema.go b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/schema.go new file mode 100644 index 0000000000..55c855a7da --- /dev/null +++ b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/schema.go @@ -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_4" +) + +type Config struct { + base.Config `yaml:",inline"` +} diff --git a/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/translate.go b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/translate.go new file mode 100644 index 0000000000..c5475ecc98 --- /dev/null +++ b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_0/translate.go @@ -0,0 +1,79 @@ +// 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/butane/translate" + + "github.com/coreos/ignition/v2/config/v3_3/types" + "github.com/coreos/vcontext/path" + "github.com/coreos/vcontext/report" +) + +// ToIgn3_3Unvalidated 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_3Unvalidated(options common.TranslateOptions) (types.Config, translate.TranslationSet, report.Report) { + ret, ts, r := c.Config.ToIgn3_3Unvalidated(options) + if r.IsFatal() { + return types.Config{}, translate.TranslationSet{}, r + } + + checkForForbiddenFields(ret, &r) + + return ret, ts, r +} + +// Checks and adds the appropiate errors when unsupported fields on r4e are +// provided +func checkForForbiddenFields(t types.Config, r *report.Report) { + for i := range t.KernelArguments.ShouldExist { + r.AddOnError(path.New("path", "json", "kernel_arguments", "should_exist", i), common.ErrGeneralKernelArgumentSupport) + } + for i := range t.KernelArguments.ShouldNotExist { + r.AddOnError(path.New("path", "json", "kernel_arguments", "should_not_exist", i), common.ErrGeneralKernelArgumentSupport) + } + for i := range t.Storage.Disks { + r.AddOnError(path.New("path", "json", "storage", "disks", i), common.ErrDiskSupport) + } + for i := range t.Storage.Filesystems { + r.AddOnError(path.New("path", "json", "storage", "filesystems", i), common.ErrFilesystemSupport) + } + for i := range t.Storage.Luks { + r.AddOnError(path.New("path", "json", "storage", "luks", i), common.ErrLuksSupport) + } + for i := range t.Storage.Raid { + r.AddOnError(path.New("path", "json", "storage", "raid", i), common.ErrRaidSupport) + } +} + +// ToIgn3_3 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_3(options common.TranslateOptions) (types.Config, report.Report, error) { + cfg, r, err := cutil.Translate(c, "ToIgn3_3Unvalidated", options) + return cfg.(types.Config), r, err +} + +// ToIgn3_3Bytes translates from a v1.0 Butane config to a v3.3.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_3Bytes(input []byte, options common.TranslateBytesOptions) ([]byte, report.Report, error) { + return cutil.TranslateBytes(input, &Config{}, "ToIgn3_3", options) +} diff --git a/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/schema.go b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/schema.go new file mode 100644 index 0000000000..56deb4c938 --- /dev/null +++ b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/schema.go @@ -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_1_exp + +import ( + base "github.com/coreos/butane/base/v0_5_exp" +) + +type Config struct { + base.Config `yaml:",inline"` +} diff --git a/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/translate.go b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/translate.go new file mode 100644 index 0000000000..e3ccdb5073 --- /dev/null +++ b/mantle/vendor/github.com/coreos/butane/config/r4e/v1_1_exp/translate.go @@ -0,0 +1,78 @@ +// 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_1_exp + +import ( + "github.com/coreos/butane/config/common" + cutil "github.com/coreos/butane/config/util" + "github.com/coreos/butane/translate" + "github.com/coreos/ignition/v2/config/v3_4_experimental/types" + "github.com/coreos/vcontext/path" + "github.com/coreos/vcontext/report" +) + +// ToIgn3_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_4Unvalidated(options common.TranslateOptions) (types.Config, translate.TranslationSet, report.Report) { + ret, ts, r := c.Config.ToIgn3_4Unvalidated(options) + if r.IsFatal() { + return types.Config{}, translate.TranslationSet{}, r + } + + checkForForbiddenFields(ret, &r) + + return ret, ts, r +} + +// Checks and adds the appropiate errors when unsupported fields on r4e are +// provided +func checkForForbiddenFields(t types.Config, r *report.Report) { + for i := range t.KernelArguments.ShouldExist { + r.AddOnError(path.New("path", "json", "kernel_arguments", "should_exist", i), common.ErrGeneralKernelArgumentSupport) + } + for i := range t.KernelArguments.ShouldNotExist { + r.AddOnError(path.New("path", "json", "kernel_arguments", "should_not_exist", i), common.ErrGeneralKernelArgumentSupport) + } + for i := range t.Storage.Disks { + r.AddOnError(path.New("path", "json", "storage", "disks", i), common.ErrDiskSupport) + } + for i := range t.Storage.Filesystems { + r.AddOnError(path.New("path", "json", "storage", "filesystems", i), common.ErrFilesystemSupport) + } + for i := range t.Storage.Luks { + r.AddOnError(path.New("path", "json", "storage", "luks", i), common.ErrLuksSupport) + } + for i := range t.Storage.Raid { + r.AddOnError(path.New("path", "json", "storage", "raid", i), common.ErrRaidSupport) + } +} + +// 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) +} diff --git a/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go b/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go index 439ad28746..c5b23a8196 100644 --- a/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go +++ b/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go @@ -69,6 +69,58 @@ func Enabled() bool { return true } +// StderrIsJournalStream returns whether the process stderr is connected +// to the Journal's stream transport. +// +// This can be used for automatic protocol upgrading described in [Journal Native Protocol]. +// +// Returns true if JOURNAL_STREAM environment variable is present, +// and stderr's device and inode numbers match it. +// +// Error is returned if unexpected error occurs: e.g. if JOURNAL_STREAM environment variable +// is present, but malformed, fstat syscall fails, etc. +// +// [Journal Native Protocol]: https://systemd.io/JOURNAL_NATIVE_PROTOCOL/#automatic-protocol-upgrading +func StderrIsJournalStream() (bool, error) { + return fdIsJournalStream(syscall.Stderr) +} + +// StdoutIsJournalStream returns whether the process stdout is connected +// to the Journal's stream transport. +// +// Returns true if JOURNAL_STREAM environment variable is present, +// and stdout's device and inode numbers match it. +// +// Error is returned if unexpected error occurs: e.g. if JOURNAL_STREAM environment variable +// is present, but malformed, fstat syscall fails, etc. +// +// Most users should probably use [StderrIsJournalStream]. +func StdoutIsJournalStream() (bool, error) { + return fdIsJournalStream(syscall.Stdout) +} + +func fdIsJournalStream(fd int) (bool, error) { + journalStream := os.Getenv("JOURNAL_STREAM") + if journalStream == "" { + return false, nil + } + + var expectedStat syscall.Stat_t + _, err := fmt.Sscanf(journalStream, "%d:%d", &expectedStat.Dev, &expectedStat.Ino) + if err != nil { + return false, fmt.Errorf("failed to parse JOURNAL_STREAM=%q: %v", journalStream, err) + } + + var stat syscall.Stat_t + err = syscall.Fstat(fd, &stat) + if err != nil { + return false, err + } + + match := stat.Dev == expectedStat.Dev && stat.Ino == expectedStat.Ino + return match, nil +} + // Send a message to the local systemd journal. vars is a map of journald // fields to values. Fields must be composed of uppercase letters, numbers, // and underscores, but must not start with an underscore. Within these diff --git a/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go b/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go index 677aca68ed..322e41e74c 100644 --- a/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go +++ b/mantle/vendor/github.com/coreos/go-systemd/v22/journal/journal_windows.go @@ -33,3 +33,11 @@ func Enabled() bool { func Send(message string, priority Priority, vars map[string]string) error { return errors.New("could not initialize socket to journald") } + +func StderrIsJournalStream() (bool, error) { + return false, nil +} + +func StdoutIsJournalStream() (bool, error) { + return false, nil +} diff --git a/mantle/vendor/modules.txt b/mantle/vendor/modules.txt index 140eaf4d18..25e7b5602b 100644 --- a/mantle/vendor/modules.txt +++ b/mantle/vendor/modules.txt @@ -168,7 +168,7 @@ github.com/aws/aws-sdk-go/service/sts/stsiface # github.com/clarketm/json v1.17.1 ## explicit github.com/clarketm/json -# github.com/coreos/butane v0.16.0 +# github.com/coreos/butane v0.17.0 ## explicit; go 1.17 github.com/coreos/butane/base/util github.com/coreos/butane/base/v0_1 @@ -198,6 +198,8 @@ github.com/coreos/butane/config/openshift/v4_8 github.com/coreos/butane/config/openshift/v4_8/result github.com/coreos/butane/config/openshift/v4_9 github.com/coreos/butane/config/openshift/v4_9/result +github.com/coreos/butane/config/r4e/v1_0 +github.com/coreos/butane/config/r4e/v1_1_exp github.com/coreos/butane/config/rhcos/v0_1 github.com/coreos/butane/config/util github.com/coreos/butane/translate @@ -214,7 +216,7 @@ github.com/coreos/go-semver/semver ## explicit github.com/coreos/go-systemd/journal github.com/coreos/go-systemd/unit -# github.com/coreos/go-systemd/v22 v22.4.0 +# github.com/coreos/go-systemd/v22 v22.5.0 ## explicit; go 1.12 github.com/coreos/go-systemd/v22/dbus github.com/coreos/go-systemd/v22/journal @@ -386,7 +388,7 @@ github.com/spf13/cobra # github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace ## explicit; go 1.12 github.com/spf13/pflag -# github.com/stretchr/testify v1.8.0 +# github.com/stretchr/testify v1.8.1 ## explicit; go 1.13 github.com/stretchr/testify/assert # github.com/vincent-petithory/dataurl v1.0.0