mirror of
https://github.com/rancher/os.git
synced 2025-09-02 15:24:32 +00:00
Unescape kernel params
so kernel params like rancher.cloud_init.datasources='["url:http://10.0.2.2:8800/cc.yml"]' could be used
This commit is contained in:
@@ -225,3 +225,9 @@ func GetCurrentContainerId() (string, error) {
|
||||
|
||||
return parts[len(parts)-1:][0], nil
|
||||
}
|
||||
|
||||
func UnescapeKernelParams(s string) string {
|
||||
s = strings.Replace(s, `\"`, `"`, -1)
|
||||
s = strings.Replace(s, `\'`, `'`, -1)
|
||||
return s
|
||||
}
|
||||
|
@@ -90,3 +90,13 @@ func TestMerge(t *testing.T) {
|
||||
}
|
||||
assert.Equal(expected, Merge(m0, m1))
|
||||
}
|
||||
|
||||
func TestCmdLineStr(t *testing.T) {
|
||||
assert := require.New(t)
|
||||
|
||||
cmdLine := `rancher.cloud_init.datasources=[\'url:http://192.168.1.100/cloud-config\']`
|
||||
assert.Equal("rancher.cloud_init.datasources=['url:http://192.168.1.100/cloud-config']", UnescapeKernelParams(cmdLine))
|
||||
|
||||
cmdLine = `rancher.cloud_init.datasources=[\"url:http://192.168.1.100/cloud-config\"]`
|
||||
assert.Equal(`rancher.cloud_init.datasources=["url:http://192.168.1.100/cloud-config"]`, UnescapeKernelParams(cmdLine))
|
||||
}
|
||||
|
Reference in New Issue
Block a user