Skip to content

Commit 47b556a

Browse files
committed
Improve the error message when running nested inside a non-Toolbx container
Fixes issue #1183 Signed-off-by: Nieves Montero <[email protected]>
1 parent b8138e0 commit 47b556a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/cmd/root.go

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ func preRun(cmd *cobra.Command, args []string) error {
144144
}
145145
}
146146

147+
if utils.IsInsideContainer() && !utils.IsInsideToolboxContainer() {
148+
return createErrorNonToolboxContainer()
149+
}
150+
147151
toolboxPath := os.Getenv("TOOLBOX_PATH")
148152

149153
if toolboxPath == "" {

src/cmd/utils.go

+10
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ func createErrorInvalidRelease(hint string) error {
138138
return errors.New(errMsg)
139139
}
140140

141+
func createErrorNonToolboxContainer() error {
142+
var builder strings.Builder
143+
fmt.Fprintf(&builder, "this is not a Toolbox container.\n")
144+
fmt.Fprintf(&builder, "Toolbox is only meant to work with Toolbox containers.\n")
145+
fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
146+
147+
errMsg := builder.String()
148+
return errors.New(errMsg)
149+
}
150+
141151
func getUsageForCommonCommands() string {
142152
var builder strings.Builder
143153
fmt.Fprintf(&builder, "create Create a new toolbox container\n")

0 commit comments

Comments
 (0)