mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat: print warning on some unsupported compose features (#288)
* feat: error on unsupported compose features This implements a check for the unimplemented features of the uncloud support matrix and points to the matrix in the error. Fixes: #237 This redos #277, as I messed up my branch, (basically rebase gone wrong). Signed-off-by: Miek Gieben <miek@miek.nl> * Fix tests by capturing stderr The error should be nil, but we _do_ want to know if the user saw an warning. Redirect stderr to capture this as the error is emited by printing to stderr. Signed-off-by: Miek Gieben <miek@miek.nl> --------- Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -422,3 +422,52 @@ func validateServicesExtensions(project *types.Project) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateServicesFeatures checks the service for unsupported features and returns an error for this first one found.
|
||||
func validateServicesFeatures(project *types.Project) error {
|
||||
err := func(service, feature string) error {
|
||||
return fmt.Errorf("service: '%s': unsupported feature: '%s', see %s", service, feature, "https://uncloud.run/docs/compose-file-reference/support-matrix")
|
||||
}
|
||||
|
||||
for _, service := range project.Services {
|
||||
if service.SecurityOpt != nil {
|
||||
return err(service.Name, "security_opt")
|
||||
}
|
||||
if service.DNS != nil {
|
||||
return err(service.Name, "dns")
|
||||
}
|
||||
if service.DNSSearch != nil {
|
||||
return err(service.Name, "dns_search")
|
||||
}
|
||||
if service.Labels != nil {
|
||||
return err(service.Name, "labels")
|
||||
}
|
||||
if service.Links != nil {
|
||||
return err(service.Name, "links")
|
||||
}
|
||||
if service.MemSwappiness > 0 {
|
||||
return err(service.Name, "mem_swappiness")
|
||||
}
|
||||
if service.MemSwapLimit > 0 {
|
||||
return err(service.Name, "memswap_limit")
|
||||
}
|
||||
if service.Secrets != nil {
|
||||
return err(service.Name, "secrets")
|
||||
}
|
||||
if service.StorageOpt != nil {
|
||||
return err(service.Name, "storage_opt")
|
||||
}
|
||||
// we only allow the 'default' network, nothing else.
|
||||
if x := service.Networks; x != nil {
|
||||
if len(x) != 1 {
|
||||
return err(service.Name, "networks")
|
||||
}
|
||||
config, ok := x["default"]
|
||||
if !ok || config != nil {
|
||||
return err(service.Name, "networks")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user