Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base kubernetes branch for 1.16.0 #86

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
408 changes: 408 additions & 0 deletions Godeps/LICENSES

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions build/kazel_generated.bzl
Expand Up @@ -107,6 +107,7 @@ tags_values_pkgs = {"openapi-gen": {
"staging/src/k8s.io/node-api/pkg/apis/node/v1alpha1",
"staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1",
"staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1",
"vendor/github.com/openshift/api/image/v1",
],
}}

Expand Down Expand Up @@ -192,4 +193,5 @@ tags_pkgs_values = {"openapi-gen": {
"staging/src/k8s.io/node-api/pkg/apis/node/v1alpha1": ["true"],
"staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1": ["true"],
"staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1": ["true"],
"vendor/github.com/openshift/api/image/v1": ["true"],
}}
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -366,6 +366,8 @@ replace (
github.com/opencontainers/runc => github.com/opencontainers/runc v1.0.0-rc2.0.20190611121236-6cc515888830
github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v1.0.0
github.com/opencontainers/selinux => github.com/opencontainers/selinux v1.2.2
github.com/openshift/api => github.com/openshift/api v3.9.1-0.20190925205819-e39b0dc4e188+incompatible
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b
github.com/pborman/uuid => github.com/pborman/uuid v1.2.0
github.com/pelletier/go-toml => github.com/pelletier/go-toml v1.2.0
github.com/peterbourgon/diskv => github.com/peterbourgon/diskv v2.0.1+incompatible
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Expand Up @@ -347,6 +347,10 @@ github.com/opencontainers/runtime-spec v1.0.0 h1:O6L965K88AilqnxeYPks/75HLpp4IG+
github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.2.2 h1:Kx9J6eDG5/24A6DtUquGSpJQ+m2MUTahn4FtGEe8bFg=
github.com/opencontainers/selinux v1.2.2/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
github.com/openshift/api v3.9.1-0.20190925205819-e39b0dc4e188+incompatible h1:fo4PhGUciMa8Xs2wtOSYY51cnr3+4o/Zkc8nWIC3t/E=
github.com/openshift/api v3.9.1-0.20190925205819-e39b0dc4e188+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b h1:E++qQ7W1/EdvuMo+YGVbMPn4HihEp7YT5Rghh0VmA9A=
github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b/go.mod h1:6rzn+JTr7+WYS2E1TExP4gByoABxMznR6y2SnUIkmxk=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
Expand Down
1 change: 1 addition & 0 deletions hack/.golint_failures
Expand Up @@ -428,6 +428,7 @@ staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/tokentest
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook
staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook
staging/src/k8s.io/cli-runtime/pkg/genericclioptions
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch
staging/src/k8s.io/cli-runtime/pkg/printers
staging/src/k8s.io/cli-runtime/pkg/resource
staging/src/k8s.io/client-go/deprecated-dynamic
Expand Down
16 changes: 15 additions & 1 deletion hack/make-rules/test.sh
Expand Up @@ -62,10 +62,24 @@ kube::test::find_dirs() {
-o -path './third_party/*' \
-o -path './staging/*' \
-o -path './vendor/*' \
-o -path './cmd/kubeadm/*' \
-o -path './cluster/gce/*' \
-o -path './plugin/pkg/admission/imagepolicy/*' \
-o -path './pkg/kubelet/oom/*' \
-o -path './pkg/master/*' \
-o -path './pkg/volume/csi/*' \
\) -prune \
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed "s|^\./|${KUBE_GO_PACKAGE}/|" | LC_ALL=C sort -u

find ./staging -name '*_test.go' -not -path '*/test/integration/*' -prune -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u
find ./staging -not \( \
\( \
-path '*/test/integration/*' \
-o -path './staging/src/k8s.io/apiserver/pkg/server/options/*' \
-o -path './staging/src/k8s.io/apiserver/pkg/util/webhook/*' \
-o -path './staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/*' \
-o -path './staging/src/k8s.io/legacy-cloud-providers/gce/*' \
\) -prune \
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u
)
}

Expand Down
6 changes: 3 additions & 3 deletions hack/make-rules/verify.sh
Expand Up @@ -36,6 +36,7 @@ EXCLUDED_PATTERNS=(
"verify-test-owners.sh" # TODO(rmmh): figure out how to avoid endless conflicts
"verify-*-dockerized.sh" # Don't run any scripts that intended to be run dockerized
"verify-import-aliases.sh" # to be run periodically by folks working on conformance tests
"verify-boilerplate.sh" # ignored due to ocp patches
)

# Exclude typecheck in certain cases, if they're running in a separate job.
Expand Down Expand Up @@ -67,7 +68,6 @@ fi
QUICK_PATTERNS+=(
"verify-api-groups.sh"
"verify-bazel.sh"
"verify-boilerplate.sh"
"verify-vendor-licenses.sh"
"verify-gofmt.sh"
"verify-imports.sh"
Expand All @@ -81,8 +81,8 @@ QUICK_PATTERNS+=(
"verify-test-owners.sh"
)

while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
while IFS='' read -r line; do QUICK_CHECKS+=("$line"); done < <(ls "${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/}" 2>/dev/null || true)
while IFS='' read -r line; do EXCLUDED_CHECKS+=("$line"); done < <(ls "${EXCLUDED_PATTERNS[@]/#/${KUBE_ROOT}/hack/}" 2>/dev/null || true)
while IFS='' read -r line; do QUICK_CHECKS+=("$line"); done < <(ls "${QUICK_PATTERNS[@]/#/${KUBE_ROOT}/hack/}" 2>/dev/null || true)
TARGET_LIST=()
IFS=" " read -r -a TARGET_LIST <<< "${WHAT:-}"

Expand Down
5 changes: 4 additions & 1 deletion pkg/printers/internalversion/printers.go
Expand Up @@ -75,9 +75,12 @@ const (
nodeLabelRole = "kubernetes.io/role"
)

// Allow injecting additional print handlers
var AddHandlers = AddKubeHandlers

// AddHandlers adds print handlers for default Kubernetes types dealing with internal versions.
// TODO: handle errors from Handler
func AddHandlers(h printers.PrintHandler) {
func AddKubeHandlers(h printers.PrintHandler) {
podColumnDefinitions := []metav1beta1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "Ready", Type: "string", Description: "The aggregate readiness state of this pod for accepting traffic."},
Expand Down
Expand Up @@ -272,10 +272,10 @@ func TestSetCRDCondition(t *testing.T) {
}
for i := range tc.expectedcrdCondition {
if !IsCRDConditionEquivalent(&tc.expectedcrdCondition[i], &crd.Status.Conditions[i]) {
t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition, crd.Status.Conditions)
t.Errorf("%v expected %v, got %v", tc.name, tc.expectedcrdCondition[i], crd.Status.Conditions[i])
}
if crd.Status.Conditions[i].LastTransitionTime.IsZero() {
t.Errorf("%q lastTransitionTime should not be null: %v", tc.name, i, crd.Status.Conditions)
t.Errorf("%q/%d lastTransitionTime should not be null: %v", tc.name, i, crd.Status.Conditions[i])
}
}
}
Expand Down
1 change: 1 addition & 0 deletions staging/src/k8s.io/apimachinery/pkg/api/meta/restmapper.go
Expand Up @@ -115,6 +115,7 @@ func (m *DefaultRESTMapper) AddSpecific(kind schema.GroupVersionKind, plural, si
// callers to use the RESTMapper they mean.
var unpluralizedSuffixes = []string{
"endpoints",
"securitycontextconstraints",
}

// UnsafeGuessKindToResource converts Kind to a resource name.
Expand Down
7 changes: 6 additions & 1 deletion staging/src/k8s.io/cli-runtime/pkg/genericclioptions/BUILD
Expand Up @@ -14,6 +14,7 @@ go_library(
"jsonpath_flags.go",
"kube_template_flags.go",
"name_flags.go",
"patch_config_flags.go",
"print_flags.go",
"record_flags.go",
"template_flags.go",
Expand All @@ -25,6 +26,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/printers:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/resource:go_default_library",
"//staging/src/k8s.io/client-go/discovery:go_default_library",
Expand All @@ -49,7 +51,10 @@ filegroup(

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
srcs = [
":package-srcs",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
Expand Down
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
"k8s.io/client-go/discovery"
diskcached "k8s.io/client-go/discovery/cached/disk"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -250,7 +251,12 @@ func (f *ConfigFlags) ToRESTMapper() (meta.RESTMapper, error) {
// AddFlags binds client configuration flags to a given flagset
func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet) {
if f.KubeConfig != nil {
flags.StringVar(f.KubeConfig, "kubeconfig", *f.KubeConfig, "Path to the kubeconfig file to use for CLI requests.")
if !openshiftpatch.IsOC {
flags.StringVar(f.KubeConfig, "kubeconfig", *f.KubeConfig, "Path to the kubeconfig file to use for CLI requests.")
} else {
flags.StringVar(f.KubeConfig, "kubeconfig", *f.KubeConfig, "Path to the kubeconfig file to use for CLI requests.")
flags.StringVar(f.KubeConfig, OpenShiftKubeConfigFlagName, *f.KubeConfig, "Path to the kubeconfig file to use for CLI requests.")
}
}
if f.CacheDir != nil {
flags.StringVar(f.CacheDir, flagHTTPCacheDir, *f.CacheDir, "Default HTTP cache directory")
Expand Down
@@ -0,0 +1,27 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["patch_openshift.go"],
importmap = "k8s.io/kubernetes/vendor/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch",
importpath = "k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
@@ -0,0 +1,34 @@
package openshiftpatch

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var IsOC = false

var OAPIToGroupifiedGVK func(gvk *schema.GroupVersionKind)

func FixOAPIGroupifiedGVK(gvk *schema.GroupVersionKind) {
if OAPIToGroupifiedGVK != nil {
OAPIToGroupifiedGVK(gvk)
}
}

var OAPIToGroupified func(uncast runtime.Object, gvk *schema.GroupVersionKind)

func FixOAPIGroupKind(uncast runtime.Object, gvk *schema.GroupVersionKind) {
if OAPIToGroupified != nil {
OAPIToGroupified(uncast, gvk)
}
}

var IsOAPIFn func(gvk schema.GroupVersionKind) bool

func IsOAPI(gvk schema.GroupVersionKind) bool {
if IsOAPIFn == nil {
return false
}

return IsOAPIFn(gvk)
}
@@ -0,0 +1,16 @@
package genericclioptions

import "fmt"

// OpenShiftKubeConfigFlagName exists only so that we can track down all non-standard offenders
const OpenShiftKubeConfigFlagName = "config"

func NewErrConfigurationMissing() error {
return fmt.Errorf(`Missing or incomplete configuration info. Please login or point to an existing, complete config file:

1. Via the command-line flag --config
2. Via the KUBECONFIG environment variable
3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.`)
}
1 change: 1 addition & 0 deletions staging/src/k8s.io/cli-runtime/pkg/printers/BUILD
Expand Up @@ -23,6 +23,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch:go_default_library",
"//staging/src/k8s.io/client-go/util/jsonpath:go_default_library",
"//vendor/sigs.k8s.io/yaml:go_default_library",
],
Expand Down
8 changes: 7 additions & 1 deletion staging/src/k8s.io/cli-runtime/pkg/printers/json.go
Expand Up @@ -26,7 +26,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -71,6 +71,9 @@ func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if obj.GetObjectKind().GroupVersionKind().Empty() {
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
}
if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return fmt.Errorf("attempt to print an ungroupified object: %v", obj.GetObjectKind().GroupVersionKind())
}

data, err := json.MarshalIndent(obj, "", " ")
if err != nil {
Expand Down Expand Up @@ -132,6 +135,9 @@ func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if obj.GetObjectKind().GroupVersionKind().Empty() {
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
}
if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return fmt.Errorf("attempt to print an ungroupified object: %v", obj.GetObjectKind().GroupVersionKind())
}

output, err := yaml.Marshal(obj)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions staging/src/k8s.io/cli-runtime/pkg/printers/jsonpath.go
Expand Up @@ -24,6 +24,7 @@ import (
"reflect"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
"k8s.io/client-go/util/jsonpath"
)

Expand Down Expand Up @@ -121,6 +122,9 @@ func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj)).Type().PkgPath()) {
return fmt.Errorf(InternalObjectPrinterErr)
}
if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return fmt.Errorf("attempt to print an ungroupified object: %v", obj.GetObjectKind().GroupVersionKind())
}

var queryObj interface{} = obj
if unstructured, ok := obj.(runtime.Unstructured); ok {
Expand Down
4 changes: 4 additions & 0 deletions staging/src/k8s.io/cli-runtime/pkg/printers/name.go
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
)

// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
Expand Down Expand Up @@ -78,6 +79,9 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if obj.GetObjectKind().GroupVersionKind().Empty() {
return fmt.Errorf("missing apiVersion or kind; try GetObjectKind().SetGroupVersionKind() if you know the type")
}
if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return fmt.Errorf("attempt to print an ungroupified object: %v", obj.GetObjectKind().GroupVersionKind())
}

name := "<unknown>"
if acc, err := meta.Accessor(obj); err == nil {
Expand Down
5 changes: 5 additions & 0 deletions staging/src/k8s.io/cli-runtime/pkg/printers/template.go
Expand Up @@ -25,6 +25,7 @@ import (

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
)

// GoTemplatePrinter is an implementation of ResourcePrinter which formats data with a Go Template.
Expand Down Expand Up @@ -64,6 +65,10 @@ func (p *GoTemplatePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
return fmt.Errorf(InternalObjectPrinterErr)
}

if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return fmt.Errorf("attempt to print an ungroupified object: %v", obj.GetObjectKind().GroupVersionKind())
}

var data []byte
var err error
data, err = json.Marshal(obj)
Expand Down
14 changes: 11 additions & 3 deletions staging/src/k8s.io/cli-runtime/pkg/printers/typesetter.go
Expand Up @@ -21,7 +21,7 @@ import (
"io"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch"
)

// TypeSetterPrinter is an implementation of ResourcePrinter wraps another printer with types set on the objects
Expand All @@ -42,13 +42,14 @@ func (p *TypeSetterPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
if obj == nil {
return p.Delegate.PrintObj(obj, w)
}
if !obj.GetObjectKind().GroupVersionKind().Empty() {
if !obj.GetObjectKind().GroupVersionKind().Empty() && !openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
return p.Delegate.PrintObj(obj, w)
}

// we were empty coming in, make sure we're empty going out. This makes the call thread-unsafe
existingGVK := obj.GetObjectKind().GroupVersionKind()
defer func() {
obj.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{})
obj.GetObjectKind().SetGroupVersionKind(existingGVK)
}()

gvks, _, err := p.Typer.ObjectKinds(obj)
Expand All @@ -68,6 +69,13 @@ func (p *TypeSetterPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
break
}

if openshiftpatch.IsOAPI(obj.GetObjectKind().GroupVersionKind()) {
gvk := obj.GetObjectKind().GroupVersionKind()
openshiftpatch.FixOAPIGroupifiedGVK(&gvk)
obj.GetObjectKind().SetGroupVersionKind(gvk)
return p.Delegate.PrintObj(obj, w)
}

return p.Delegate.PrintObj(obj, w)
}

Expand Down
1 change: 1 addition & 0 deletions staging/src/k8s.io/cli-runtime/pkg/resource/BUILD
Expand Up @@ -35,6 +35,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/openshiftpatch:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/kustomize:go_default_library",
"//staging/src/k8s.io/client-go/discovery:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
Expand Down