Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More explicit error on app install type mismatch #4142

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions model/app/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import (

var slugReg = regexp.MustCompile(`^[a-z0-9\-]+$`)

var ErrInvalidManifestTypes = errors.New("manifest types are not the sames")
var ErrInvalidManifestTypes = errors.New("Manifest type is unknown")
var ErrInvalidManifestForWebapp = errors.New("Manifest type is not valid for a webapp. Maybe you want to install a konnector?")
var ErrInvalidManifestForKonnector = errors.New("Manifest type is not valid for a konnector. Maybe you want to install a webapp?")

// Operation is the type of operation the installer is created for.
type Operation int
Expand Down Expand Up @@ -608,7 +610,16 @@ func (i *Installer) ReadManifest(state State) (Manifest, error) {
appTypesMismatch := i.man.AppType() != newManifestAppType

if !appTypesEmpty && appTypesMismatch {
return nil, fmt.Errorf("%w: expected %d, got %d. Are you sure of %s type ? (konnector/webapp)", ErrInvalidManifestTypes, i.man.AppType(), newManifestAppType, i.man.Slug())
var typeError error
switch i.man.AppType() {
case consts.KonnectorType:
typeError = ErrInvalidManifestForKonnector
case consts.WebappType:
typeError = ErrInvalidManifestForWebapp
default:
typeError = ErrInvalidManifestTypes
}
return nil, fmt.Errorf("[%s] %w", i.man.Slug(), typeError)
}
return newManifest, nil
}
Expand Down
2 changes: 1 addition & 1 deletion model/app/installer_konnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestInstallerKonnector(t *testing.T) {
assert.NoError(t, err)
_, err = inst.RunSync()
assert.Error(t, err)
assert.ErrorIs(t, err, app.ErrInvalidManifestTypes)
assert.ErrorIs(t, err, app.ErrInvalidManifestForKonnector)
})
}

Expand Down
2 changes: 1 addition & 1 deletion model/app/installer_webapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ func TestInstallerWebApp(t *testing.T) {
assert.NoError(t, err)
_, err = inst.RunSync()
assert.Error(t, err)
assert.ErrorIs(t, err, app.ErrInvalidManifestTypes)
assert.ErrorIs(t, err, app.ErrInvalidManifestForWebapp)
})
}

Expand Down
Loading