-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from yangcao77/integrateValidation
validation consolidation
- Loading branch information
Showing
9 changed files
with
354 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,65 @@ | ||
package validate | ||
|
||
import ( | ||
"k8s.io/klog" | ||
"fmt" | ||
"github.com/devfile/api/v2/pkg/validation" | ||
devfileData "github.com/devfile/library/pkg/devfile/parser/data" | ||
"github.com/devfile/library/pkg/devfile/parser/data/v2/common" | ||
"strings" | ||
) | ||
|
||
// ValidateDevfileData validates whether sections of devfile are compatible | ||
func ValidateDevfileData(data interface{}) error { | ||
func ValidateDevfileData(data devfileData.DevfileData) error { | ||
|
||
// Skipped | ||
klog.V(4).Info("No validation present. Skipped for the moment.") | ||
return nil | ||
commands, err := data.GetCommands(common.DevfileOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
components, err := data.GetComponents(common.DevfileOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
projects, err := data.GetProjects(common.DevfileOptions{}) | ||
if err != nil { | ||
return err | ||
} | ||
//starterProjects, err := data.GetStarterProjects(common.DevfileOptions{}) | ||
//if err != nil { | ||
// return err | ||
//} | ||
|
||
var errstrings []string | ||
// validate components | ||
err = validation.ValidateComponents(components) | ||
if err != nil { | ||
errstrings = append(errstrings, err.Error()) | ||
} | ||
|
||
// validate commands | ||
err = validation.ValidateCommands(commands, components) | ||
if err != nil { | ||
errstrings = append(errstrings, err.Error()) | ||
} | ||
|
||
err = validation.ValidateEvents(data.GetEvents(), commands) | ||
if err != nil { | ||
errstrings = append(errstrings, err.Error()) | ||
} | ||
|
||
err = validation.ValidateProjects(projects) | ||
if err != nil { | ||
errstrings = append(errstrings, err.Error()) | ||
} | ||
|
||
//err = validation.ValidateStarterProjects(starterProjects) | ||
//if err != nil { | ||
// errstrings = append(errstrings, err.Error()) | ||
//} | ||
|
||
if len(errstrings) > 0 { | ||
return fmt.Errorf(strings.Join(errstrings, "\n")) | ||
} else { | ||
return nil | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.