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

Add the storage version API #88607

Merged
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
2 changes: 2 additions & 0 deletions build/kazel_generated.bzl
Expand Up @@ -86,6 +86,7 @@ tags_values_pkgs = {"openapi-gen": {
"staging/src/k8s.io/apimachinery/pkg/runtime",
"staging/src/k8s.io/apimachinery/pkg/util/intstr",
"staging/src/k8s.io/apimachinery/pkg/version",
"staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1",
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1",
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1",
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1",
Expand Down Expand Up @@ -168,6 +169,7 @@ tags_pkgs_values = {"openapi-gen": {
"staging/src/k8s.io/apimachinery/pkg/runtime": ["true"],
"staging/src/k8s.io/apimachinery/pkg/util/intstr": ["true"],
"staging/src/k8s.io/apimachinery/pkg/version": ["true"],
"staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1": ["true"],
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1": ["true"],
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1": ["true"],
"staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1": ["true"],
Expand Down
2 changes: 2 additions & 0 deletions hack/.golint_failures
Expand Up @@ -309,6 +309,8 @@ staging/src/k8s.io/apiserver/pkg/apis/apiserver
staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1
staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1
staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1beta1
staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal
staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1
staging/src/k8s.io/apiserver/pkg/apis/audit
staging/src/k8s.io/apiserver/pkg/apis/audit/v1
staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1
Expand Down
1 change: 1 addition & 0 deletions staging/src/k8s.io/apiserver/BUILD
Expand Up @@ -11,6 +11,7 @@ filegroup(
":package-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserver:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/audit:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/config:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/example:all-srcs",
Expand Down
42 changes: 42 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/BUILD
@@ -0,0 +1,42 @@
package(default_visibility = ["//visibility:public"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)

go_library(
name = "go_default_library",
srcs = [
"doc.go",
"register.go",
"types.go",
"zz_generated.deepcopy.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal",
importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal",
deps = [
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//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",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/install:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/validation:all-srcs",
],
tags = ["automanaged"],
)
22 changes: 22 additions & 0 deletions staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/doc.go
@@ -0,0 +1,22 @@
/*
Copyright 2019 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.
*/

// +k8s:deepcopy-gen=package
// +groupName=internal.apiserver.k8s.io

// Package apiserverinternal contains the "internal" version of the API used by
// the apiservers themselves.
package apiserverinternal // import "k8s.io/apiserver/pkg/apis/apiserverinternal"
caesarxuchao marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,24 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["fuzzer.go"],
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer",
importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer",
visibility = ["//visibility:public"],
deps = ["//staging/src/k8s.io/apimachinery/pkg/runtime/serializer: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,26 @@
/*
Copyright 2019 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 fuzzer

import (
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
)

// Funcs returns the fuzzer functions for the apiserverinternal api group.
func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
return []interface{}{}
}
@@ -0,0 +1,43 @@
package(default_visibility = ["//visibility:public"])

load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)

go_library(
name = "go_default_library",
srcs = ["install.go"],
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/apis/apiserverinternal/install",
importpath = "k8s.io/apiserver/pkg/apis/apiserverinternal/install",
deps = [
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1:go_default_library",
],
)

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

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

go_test(
name = "go_default_test",
srcs = ["roundtrip_test.go"],
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer:go_default_library",
],
)
@@ -0,0 +1,33 @@
/*
Copyright 2019 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 install installs the experimental API group, making it available as
// an option to all of the API encoding/decoding machinery.
package install

import (
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apiserver/pkg/apis/apiserverinternal"
"k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1"
)

// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(apiserverinternal.AddToScheme(scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
}
@@ -0,0 +1,29 @@
/*
Copyright 2019 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 install

import (
"testing"

"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
"k8s.io/apiserver/pkg/apis/apiserverinternal/fuzzer"
)

func TestRoundTrip(t *testing.T) {
roundtrip.RoundTripTestForAPIGroup(t, Install, fuzzer.Funcs)
roundtrip.RoundTripProtobufTestForAPIGroup(t, Install, fuzzer.Funcs)
}
@@ -0,0 +1,53 @@
/*
Copyright 2019 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 apiserverinternal

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

// GroupName is the group name use in this package
const GroupName = "internal.apiserver.k8s.io"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&StorageVersion{},
&StorageVersionList{},
)
return nil
}