Skip to content

Commit ecc8d62

Browse files
authored
Plain doesn't seem to work (#15)
1 parent cb8f8ac commit ecc8d62

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Simple tool to convert files to MachineConfig objects to be used with the machin
1313
- [x] normalized parameters (...)
1414
- [x] multiple labels support
1515
- [x] base64 file encoded content support
16-
- [x] plain file content support
1716
- [x] json output
1817
- [x] yaml output
1918

@@ -24,6 +23,10 @@ Simple tool to convert files to MachineConfig objects to be used with the machin
2423
- [ ] Good code
2524
- [ ] Better error handling
2625

26+
## Not working
27+
28+
- [ ] [plain file content support](https://github.com/e-minguez/file-to-machineconfig/issues/13)
29+
2730
## Usage
2831

2932
Download the latest binary release:

file-to-machineconfig.go

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func main() {
3232
flag.StringVar(&data.APIVer, "apiversion", "", "MachineConfig API version")
3333
flag.StringVar(&data.IgnitionVer, "ignitionversion", "", "Ignition version")
3434
flag.IntVar(&data.Mode, "mode", 0, "File's permission mode in octal")
35-
flag.BoolVar(&data.Plain, "plain", false, "Embed a plain file instead encoding it to base64 (false by default)")
3635
flag.BoolVar(&data.Yaml, "yaml", false, "Use yaml output instead JSON (false by default)")
3736

3837
flag.Parse()

pkg/converter/converter.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type Parameters struct {
3030
IgnitionVer string
3131
Content string
3232
Mode int
33-
Plain bool
3433
Yaml bool
3534
}
3635

@@ -54,15 +53,6 @@ func fileToBase64(file string) string {
5453
return encodedcontent
5554
}
5655

57-
// fileToPlain Create a single string from a file
58-
func fileToPlain(file string) string {
59-
f, err := ioutil.ReadFile(file)
60-
if err != nil {
61-
log.Fatal(err)
62-
}
63-
return string(f)
64-
}
65-
6656
// labelsToMap Creates a string map with the labels the user provides
6757
func labelsToMap(labels string) map[string]string {
6858
// Remove blanks and split the labels by the comma
@@ -175,13 +165,8 @@ func NewMachineConfig(data Parameters) MachineConfig.MachineConfig {
175165
// Default content will be base64
176166
fileContent := "data:text/plain;charset=utf-8;base64,"
177167

178-
if data.Plain == true {
179-
fileContent = fileToPlain(data.LocalPath)
180-
181-
} else {
182-
// Create the base64 data with the proper ignition prefix
183-
fileContent += fileToBase64(data.LocalPath)
184-
}
168+
// Create the base64 data with the proper ignition prefix
169+
fileContent += fileToBase64(data.LocalPath)
185170

186171
// Create a map with the labels (as required by the machine-config struct)
187172
labelmap := labelsToMap(data.Labels)

0 commit comments

Comments
 (0)