cmd

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Channel = make(chan interface{}, 1)
View Source
var RootCmd = &ctc_lib.ContainerToolListCommand{
	ContainerToolCommandBase: &ctc_lib.ContainerToolCommandBase{
		Command: &cobra.Command{
			Use:   "container-structure-test",
			Short: "container-structure-test provides a framework to test the structure of a container image",
			Long: `container-structure-test provides a powerful framework to validate
the structure of a container image.
These tests can be used to check the output of commands in an image,
as well as verify metadata and contents of the filesystem.`,
			SilenceErrors: true,
			PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
				if testReport != "" {

					flags.JsonOutput = true
					testReportFile, err := os.Create(testReport)
					if err != nil {
						return err
					}
					TestCmd.SetOutput(testReportFile)
				}
				return nil
			},
		},
		Phase:           "stable",
		DefaultTemplate: "{{.}}",
	},
}
View Source
var TestCmd = &ctc_lib.ContainerToolListCommand{
	ContainerToolCommandBase: &ctc_lib.ContainerToolCommandBase{
		Command: &cobra.Command{
			Use:   "test",
			Short: "Runs the tests",
			Long:  `Runs the tests`,
			Args: func(cmd *cobra.Command, _ []string) error {
				return validateArgs()
			},
		},
		Phase:           "stable",
		DefaultTemplate: output.StructureTestsTemplate,
		TemplateFuncMap: initTemplateFuncMap(),
	},
	OutputList:      make([]interface{}, 0),
	SummaryTemplate: output.SummaryTemplate,
	SummaryObject:   &unversioned.SummaryObject{},
	StreamO: func(command *cobra.Command, args []string) {
		Run()
	},
	Stream: Channel,
	TotalO: func(list []interface{}) (interface{}, error) {
		totalPass := 0
		totalFail := 0
		errStrings := make([]string, 0)
		var err error
		for _, r := range list {
			value, ok := r.(*unversioned.TestResult)
			if !ok {
				errStrings = append(errStrings, fmt.Sprintf("unexpected value %v in list", value))
				ctc_lib.Log.Errorf("unexpected value %v in list", value)
				continue
			}
			if value.IsPass() {
				totalPass++
			} else {
				totalFail++
			}
		}
		if totalPass+totalFail == 0 || totalFail > 0 {
			errStrings = append(errStrings, "FAIL")
		}
		if len(errStrings) > 0 {
			err = fmt.Errorf(strings.Join(errStrings, "\n"))
		}

		return unversioned.SummaryObject{
			Total: totalFail + totalPass,
			Pass:  totalPass,
			Fail:  totalFail,
		}, err
	},
}

Functions

func Parse

func Parse(fp string) (types.StructureTest, error)

func Run

func Run()

func RunTests

func RunTests()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL