Skip to content

Commit 6091c02

Browse files
benjihtommysitu
authored andcommitted
hoverctl will now overwrite the default target if the default is not found
1 parent 37c4d45 commit 6091c02

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

functional-tests/hoverctl/logs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var _ = Describe("When I use hoverctl", func() {
2323
)
2424

2525
BeforeEach(func() {
26-
functional_tests.Run(hoverctlBinary, "targets", "create", "localm", "--admin-port", adminPort, "--proxy-port", proxyPort)
26+
functional_tests.Run(hoverctlBinary, "targets", "create", "local", "--admin-port", adminPort, "--proxy-port", proxyPort)
2727
})
2828

2929
AfterEach(func() {

functional-tests/hoverctl/targets_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ var _ = Describe("When using the `targets` command", func() {
207207
}))
208208
})
209209

210-
It("should error when the default points to a non-existing targets", func() {
210+
It("the default should automatically get updated to local if the default does not exist", func() {
211211
functional_tests.Run(hoverctlBinary, "targets", "create", "newdefault")
212212
functional_tests.Run(hoverctlBinary, "targets", "default", "newdefault")
213213
functional_tests.Run(hoverctlBinary, "targets", "delete", "newdefault", "--force")
214214

215215
output := functional_tests.Run(hoverctlBinary, "targets", "default")
216216

217-
Expect(output).To(ContainSubstring("No targets registered"))
217+
Expect(output).To(ContainSubstring("Default target `newdefault` not found, changing default target to `local`"))
218218
})
219219

220220
It("should error when given an invalid target name", func() {

hoverctl/cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func initConfig() {
7777

7878
config = configuration.GetConfig()
7979

80+
if config.GetTarget(config.DefaultTarget) == nil {
81+
fmt.Printf("Default target `%v` not found, changing default target to `local`", config.DefaultTarget)
82+
config.DefaultTarget = "local"
83+
84+
}
85+
8086
target = config.GetTarget(targetNameFlag)
8187
if targetNameFlag == "" && target == nil {
8288
target = configuration.NewDefaultTarget()

0 commit comments

Comments
 (0)