func Validate()

in cmd/fuzzer/app/validate.go [75:164]


func Validate() {
	if validateOptions.listFeatures {
		fmt.Println("Feature names:")
		for _, f := range features.All {
			fmt.Println(f.Name())
		}
		os.Exit(0)
	}

	for _, o := range []struct {
		flag, val string
	}{
		{validateOptions.name, "-name"},
		{validateOptions.project, "-project"},
	} {
		if o.val == "" {
			fmt.Fprintf(ValidateFlagSet.Output(), "You must specify the %s flag.\n", o.flag)
			os.Exit(1)
		}
	}

	config, err := clientcmd.BuildConfigFromFlags("", validateOptions.kubeconfig)
	if err != nil {
		panic(err.Error())
	}

	gce, err := e2e.NewCloud(validateOptions.project, "")
	if err != nil {
		panic(err)
	}

	env, err := fuzz.NewDefaultValidatorEnv(config, validateOptions.ns, gce)

	if err != nil {
		panic(err)
	}

	var fs []fuzz.Feature
	if validateOptions.featureRegex == "" {
		fs = features.All
	} else {
		fregexp := regexp.MustCompile(validateOptions.featureRegex)
		for _, f := range features.All {
			if fregexp.Match([]byte(f.Name())) {
				fs = append(fs, f)
			}
		}
	}
	var fsNames []string
	for _, f := range fs {
		fsNames = append(fsNames, f.Name())
	}
	fmt.Printf("Features = %v\n\n", fsNames)

	k8s := k8sClientSet(config)
	ing, err := k8s.NetworkingV1().Ingresses(validateOptions.ns).Get(context.TODO(), validateOptions.name, metav1.GetOptions{})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Ingress =\n%s\n\n", pretty.Sprint(*ing))

	iv, err := fuzz.NewIngressValidator(env, ing, nil, whitebox.AllTests, nil, fs)
	if err != nil {
		panic(err)
	}

	result := iv.Check(context.Background())
	fmt.Printf("Result =\n%s\n", pretty.Sprint(*result))

	if result.Err != nil {
		os.Exit(1)
	}

	vip := ing.Status.LoadBalancer.Ingress[0].IP
	params := &fuzz.GCLBForVIPParams{VIP: vip, Validators: fuzz.FeatureValidators(features.All)}
	gclb, err := fuzz.GCLBForVIP(context.Background(), gce, params)
	if err != nil {
		panic(err)
	}
	fmt.Printf("GCP resources = \n%s\n", pretty.Sprint(gclb))

	if err := iv.PerformWhiteboxTests(gclb); err != nil {
		panic(err)
	}

	if err := iv.FrontendNamingSchemeTest(gclb); err != nil {
		panic(err)
	}
}