Skip to content

Commit

Permalink
kubetestgen -> kubeconform
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefftree committed Mar 25, 2020
1 parent 77edd42 commit 074a676
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 77 deletions.
3 changes: 1 addition & 2 deletions test/conformance/BUILD
Expand Up @@ -33,8 +33,7 @@ filegroup(
srcs = [
":package-srcs",
"//test/conformance/behaviors:all-srcs",
"//test/conformance/kubetestgen:all-srcs",
"//test/conformance/kubetestlink:all-srcs",
"//test/conformance/kubeconform:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
Expand Down
File renamed without changes.
Expand Up @@ -2,8 +2,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["kubetestgen.go"],
importpath = "k8s.io/kubernetes/test/conformance/kubetestgen",
srcs = [
"gen.go",
"kubeconform.go",
"link.go",
],
importpath = "k8s.io/kubernetes/test/conformance/kubeconform",
visibility = ["//visibility:private"],
deps = [
"//test/conformance/behaviors:go_default_library",
Expand All @@ -29,7 +33,7 @@ filegroup(
)

go_binary(
name = "kubetestgen",
name = "kubeconform",
data = ["//api/openapi-spec"],
embed = [":go_default_library"],
visibility = ["//visibility:public"],
Expand Down
File renamed without changes.
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"os"
"sort"
Expand All @@ -30,29 +29,10 @@ import (
"k8s.io/kubernetes/test/conformance/behaviors"
)

type options struct {
schemaPath string
resource string
area string
behaviorsDir string
}

func parseFlags() *options {
o := &options{}
flag.StringVar(&o.schemaPath, "schema", "", "Path to the OpenAPI schema")
flag.StringVar(&o.resource, "resource", ".*", "Resource name")
flag.StringVar(&o.area, "area", "default", "Area name to use")
flag.StringVar(&o.behaviorsDir, "dir", "../behaviors/", "Path to the behaviors directory")
flag.Parse()
return o
}

var defMap map[string]analysis.SchemaRef

func main() {
func gen(o *options) {
defMap = make(map[string]analysis.SchemaRef)
o := parseFlags()

d, err := loads.JSONSpec(o.schemaPath)
if err != nil {
fmt.Printf("ERROR: %s\n", err.Error())
Expand Down
64 changes: 64 additions & 0 deletions test/conformance/kubeconform/kubeconform.go
@@ -0,0 +1,64 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"
"fmt"
)

type options struct {
// Flags only used for generating behaviors
schemaPath string
resource string
area string

// Flags only used for linking behaviors
testdata string
listMissing bool

// Flags shared between CLI tools
behaviorsDir string
}

func parseFlags() *options {
o := &options{}

flag.StringVar(&o.schemaPath, "schema", "", "Path to the OpenAPI schema")
flag.StringVar(&o.resource, "resource", ".*", "Resource name")
flag.StringVar(&o.area, "area", "default", "Area name to use")

flag.StringVar(&o.testdata, "testdata", "../testdata/conformance.yaml", "YAML file containing test linkage data")
flag.BoolVar(&o.listMissing, "missing", true, "Only list behaviors missing tests")

flag.StringVar(&o.behaviorsDir, "dir", "../behaviors", "Path to the behaviors directory")

flag.Parse()
return o
}

func main() {
o := parseFlags()
action := flag.Arg(0)
if action == "gen" {
gen(o)
} else if action == "link" {
link(o)
} else {
fmt.Printf("Unknown argument %s\n", action)
}
}
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"io/ioutil"
"os"
Expand All @@ -29,24 +28,7 @@ import (
"k8s.io/kubernetes/test/conformance/behaviors"
)

type options struct {
behaviorsDir string
testdata string
listMissing bool
}

func parseFlags() *options {
o := &options{}
flag.StringVar(&o.behaviorsDir, "behaviors", "../behaviors/", "Path to the behaviors directory")
flag.StringVar(&o.testdata, "testdata", "../testdata/conformance.yaml", "YAML file containing test linkage data")
flag.BoolVar(&o.listMissing, "missing", true, "Only list behaviors missing tests")
flag.Parse()
return o
}

func main() {
o := parseFlags()

func link(o *options) {
var behaviorFiles []string
behaviorsMapping := make(map[string][]string)
var conformanceDataList []behaviors.ConformanceData
Expand All @@ -66,6 +48,7 @@ func main() {
fmt.Printf("%v", err)
return
}
fmt.Printf("%v", behaviorFiles)

for _, behaviorFile := range behaviorFiles {
var suite behaviors.Suite
Expand All @@ -87,6 +70,10 @@ func main() {
}

conformanceYaml, err := ioutil.ReadFile(o.testdata)
if err != nil {
fmt.Printf("%v", err)
return
}

err = yaml.Unmarshal(conformanceYaml, &conformanceDataList)
if err != nil {
Expand Down
32 changes: 0 additions & 32 deletions test/conformance/kubetestlink/BUILD

This file was deleted.

0 comments on commit 074a676

Please sign in to comment.