@@ -103,21 +103,11 @@ func (c *fileConfig) UnsetHost(hostname string) error {
103
103
cm := ConfigMap {hostsEntry .ValueNode }
104
104
cm .RemoveEntry (hostname )
105
105
106
- _ , err = c .hostEntries ()
107
- if strings .Contains (err .Error (), "could not find any host configurations" ) {
108
- // no hosts, fallback to the default hostname
109
- defaultHost := instance .FallbackHostname ()
110
- err = c .Set ("" , "default_hostname" , defaultHost )
111
- if err != nil {
112
- return err
113
- }
114
- }
115
-
116
106
return nil
117
107
}
118
108
119
109
func (c * fileConfig ) ConfigForHost (hostname string ) (* HostConfig , error ) {
120
- hosts , err := c .hostEntries ()
110
+ hosts , err := c .HostEntries ()
121
111
if err != nil {
122
112
return nil , err
123
113
}
@@ -167,7 +157,7 @@ func (c *fileConfig) Write() error {
167
157
return WriteConfigFile (HostsConfigFile (), yamlNormalize (hostsBytes ))
168
158
}
169
159
170
- func (c * fileConfig ) hostEntries () ([]* HostConfig , error ) {
160
+ func (c * fileConfig ) HostEntries () ([]* HostConfig , error ) {
171
161
entry , err := c .FindEntry ("hosts" )
172
162
if err != nil {
173
163
return []* HostConfig {}, nil
@@ -184,7 +174,7 @@ func (c *fileConfig) hostEntries() ([]*HostConfig, error) {
184
174
// Hosts returns a list of all known hostnames configured in hosts.yml
185
175
// TODO replace with HostsTyped
186
176
func (c * fileConfig ) Hosts () ([]string , error ) {
187
- entries , err := c .hostEntries ()
177
+ entries , err := c .HostEntries ()
188
178
if err != nil {
189
179
return nil , err
190
180
}
@@ -203,7 +193,7 @@ func (c *fileConfig) Hosts() ([]string, error) {
203
193
// Every call re-reads the config file.
204
194
func (c * fileConfig ) HostsTyped () ([]HostConfigTyped , error ) {
205
195
var ret []HostConfigTyped
206
- hosts , err := c .hostEntries ()
196
+ hosts , err := c .HostEntries ()
207
197
if err != nil {
208
198
return nil , err
209
199
}
0 commit comments