forked from LaconicNetwork/kompose
Merge pull request #1750 from AhmedGrati/1748-bug-kompose-should-raise-and-error-when-profiles-are-required
chore: add warning when no service is selected
This commit is contained in:
commit
032b61a656
@ -171,6 +171,14 @@ func (c *Compose) LoadFile(files []string, profiles []string) (kobject.KomposeOb
|
|||||||
return kobject.KomposeObject{}, errors.Wrap(err, "Unable to load files")
|
return kobject.KomposeObject{}, errors.Wrap(err, "Unable to load files")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finding 0 services means two things:
|
||||||
|
// 1. The compose project is empty
|
||||||
|
// 2. The profile that is configured in the compose project is different than the one defined in Kompose convert options
|
||||||
|
// In both cases we should provide the user with a warning indicating that we didn't find any service.
|
||||||
|
if len(project.Services) == 0 {
|
||||||
|
log.Warning("No service selected. The profile specified in services of your compose yaml may not exist.")
|
||||||
|
}
|
||||||
|
|
||||||
komposeObject, err := dockerComposeToKomposeMapping(project)
|
komposeObject, err := dockerComposeToKomposeMapping(project)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return kobject.KomposeObject{}, err
|
return kobject.KomposeObject{}, err
|
||||||
|
|||||||
@ -305,3 +305,8 @@ convert::expect_success "$os_cmd" "$os_output" || exit 1
|
|||||||
# os_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-os.yaml"
|
# os_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-os.yaml"
|
||||||
# convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
# convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1
|
||||||
# convert::expect_success "$os_cmd" "$os_output" || exit 1
|
# convert::expect_success "$os_cmd" "$os_output" || exit 1
|
||||||
|
|
||||||
|
# Test that if we have no profile a warning should raised
|
||||||
|
cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/no-profile-warning/docker-compose.yaml convert"
|
||||||
|
convert::expect_warning "$cmd" "No service selected. The profile specified in services of your compose yaml may not exist." || exit 1
|
||||||
|
|
||||||
|
|||||||
8
script/test/fixtures/no-profile-warning/docker-compose.yaml
vendored
Normal file
8
script/test/fixtures/no-profile-warning/docker-compose.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: nginx
|
||||||
|
profiles:
|
||||||
|
- test
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
Loading…
Reference in New Issue
Block a user