ignition/0001-support-coreos.config.-and-ignition.config.patch
Michael Nguyen cdb9cf4cdb Backport support for ignition vmware properties
Backport support for guestinfo.ignition.config.data
2019-03-20 15:54:30 -04:00

94 lines
3.1 KiB
Diff

From 41faa514b2598386c3a0c8a90ebd207e282cd1d5 Mon Sep 17 00:00:00 2001
From: Michael Nguyen <mnguyen@redhat.com>
Date: Fri, 1 Mar 2019 12:10:47 -0500
Subject: [PATCH] support coreos.config.* and ignition.config.*
This is backwards compatibility work for spec2x following the changes
made in #663 to make options more distribution neutral.
ref: https://github.com/coreos/ignition/pull/663
---
internal/providers/cmdline/cmdline.go | 13 ++++++-------
internal/providers/vmware/vmware_amd64.go | 20 ++++++++++++++++----
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/internal/providers/cmdline/cmdline.go b/internal/providers/cmdline/cmdline.go
index 0bdba2d..1a393fb 100644
--- a/internal/providers/cmdline/cmdline.go
+++ b/internal/providers/cmdline/cmdline.go
@@ -32,7 +32,8 @@ import (
)
const (
- cmdlineUrlFlag = "coreos.config.url"
+ cmdlineUrlFlagLegacy = "coreos.config.url"
+ cmdlineUrlFlag = "ignition.config.url"
)
func FetchConfig(f resource.Fetcher) (types.Config, report.Report, error) {
@@ -83,12 +84,10 @@ func parseCmdline(cmdline []byte) (url string) {
parts := strings.SplitN(strings.TrimSpace(arg), "=", 2)
key := parts[0]
- if key != cmdlineUrlFlag {
- continue
- }
-
- if len(parts) == 2 {
- url = parts[1]
+ if key == cmdlineUrlFlagLegacy || key == cmdlineUrlFlag {
+ if len(parts) == 2 {
+ url = parts[1]
+ }
}
}
diff --git a/internal/providers/vmware/vmware_amd64.go b/internal/providers/vmware/vmware_amd64.go
index e26baf0..9c0ffc7 100644
--- a/internal/providers/vmware/vmware_amd64.go
+++ b/internal/providers/vmware/vmware_amd64.go
@@ -54,6 +54,8 @@ func fetchRawConfig(f resource.Fetcher) (config, error) {
var ovfData string
var ovfEncoding string
+ var ovfDataKey string
+ var ovfEncodingKey string
ovfEnv, err := info.String("ovfenv", "")
if err != nil {
@@ -65,17 +67,27 @@ func fetchRawConfig(f resource.Fetcher) (config, error) {
f.Logger.Warning("failed to parse OVF environment: %v. Continuing...", err)
}
- ovfData = env.Properties["guestinfo.coreos.config.data"]
- ovfEncoding = env.Properties["guestinfo.coreos.config.data.encoding"]
+ if _, ok := env.Properties["guestinfo.coreos.config.data"]; ok {
+ ovfDataKey = "guestinfo.coreos.config.data"
+ ovfEncodingKey = "guestinfo.coreos.config.data.encoding"
+ } else if _, ok := env.Properties["guestinfo.ignition.config.data"]; ok {
+ ovfDataKey = "guestinfo.ignition.config.data"
+ ovfEncodingKey = "guestinfo.ignition.config.data.encoding"
+ } else {
+ f.Logger.Debug("failed to find guestinfo ignition properties")
+ }
+
+ ovfData = env.Properties[ovfDataKey]
+ ovfEncoding = env.Properties[ovfEncodingKey]
}
- data, err := info.String("coreos.config.data", ovfData)
+ data, err := info.String(ovfDataKey[len("guestinfo."):], ovfData)
if err != nil {
f.Logger.Debug("failed to fetch config: %v", err)
return config{}, err
}
- encoding, err := info.String("coreos.config.data.encoding", ovfEncoding)
+ encoding, err := info.String(ovfEncodingKey[len("guestinfo."):], ovfEncoding)
if err != nil {
f.Logger.Debug("failed to fetch config encoding: %v", err)
return config{}, err
--
2.19.1