Skip to content

Commit

Permalink
allow (optional) per-host ignition files
Browse files Browse the repository at this point in the history
  • Loading branch information
jeefy committed Jun 24, 2023
1 parent 21d9458 commit 339ca25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
9 changes: 5 additions & 4 deletions pkg/hardware/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
)

type Host struct {
MAC string `json:"mac"`
Hostname string `json:"hostname"`
IP string `json:"ip"`
Booted string `json:"booted"`
MAC string `json:"mac"`
Hostname string `json:"hostname"`
IP string `json:"ip"`
Booted string `json:"booted"`
IgnitionFile string `json:"ignitionFile",omitempty`
}

type BootyData struct {
Expand Down
7 changes: 6 additions & 1 deletion pkg/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ WantedBy=default.target`,
JoinString: viper.GetString(config.JoinString),
ServerIP: viper.GetString(config.ServerIP),
}
t, err := template.ParseFiles(fmt.Sprintf("%s/%s", viper.GetString(config.DataDir), viper.GetString(config.IgnitionFile)))

ignitionFile := viper.GetString(config.IgnitionFile)
if host.IgnitionFile != "" {
ignitionFile = host.IgnitionFile
}
t, err := template.ParseFiles(fmt.Sprintf("%s/%s", viper.GetString(config.DataDir), ignitionFile))
if err != nil {
w.Write([]byte(err.Error()))
return
Expand Down
16 changes: 12 additions & 4 deletions web/src/views/HostsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ export default {
<table>
<tr v-for="(host, mac, index) of hostData.hosts">
<td>
<span><a href="/ignition.json?mac={{mac}}" target="_blank">{{mac}}</a></span>
<span><a :href="`/ignition.json?mac=${mac}`" target="_blank">{{mac}}</a></span>
</td>
<td>
<span v-show="!host.edit">{{host.hostname}}</span>
<input type="text" v-model="host.hostname" v-show="host.edit">
<input type="text" placeholder="Hostname" v-model="host.hostname" v-show="host.edit">
</td>
<td>
<span v-show="!host.edit">{{host.ignitionFile}}</span>
<input type="text" placeholder="Ignition File" v-model="host.ignitionFile" v-show="host.edit">
</td>
<td>
<button v-show="!host.edit" v-on:click="editHost(mac, host)">edit</button>
Expand All @@ -94,11 +98,15 @@ export default {
<table>
<tr v-for="(host, mac, index) of hostData.unknownHosts">
<td>
<span>{{mac}}</span>
<span><a :href="`/ignition.json?mac=${mac}`" target="_blank">{{mac}}</a></span>
</td>
<td>
<span v-show="!host.edit">{{host.hostname}}</span>
<input type="text" v-model="host.hostname" v-show="host.edit">
<input type="text" placeholder="Hostname" v-model="host.hostname" v-show="host.edit">
</td>
<td>
<span v-show="!host.edit">{{host.ignitionFile}}</span>
<input type="text" placeholder="Ignition File" v-model="host.ignitionFile" v-show="host.edit">
</td>
<td>
<button v-show="!host.edit" v-on:click="editHost(mac, host)">edit</button>
Expand Down

0 comments on commit 339ca25

Please sign in to comment.