Skip to content

Commit

Permalink
move admission/v1alpha1 to k8s.io/api
Browse files Browse the repository at this point in the history
  • Loading branch information
Chao Xu committed Jul 18, 2017
1 parent ebf24c1 commit 57a96ca
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 5,137 deletions.
2 changes: 1 addition & 1 deletion cmd/libs/go2idl/go-to-protobuf/protobuf/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func New() *Generator {
`k8s.io/api/storage/v1beta1`,
`k8s.io/api/storage/v1`,
`k8s.io/api/admissionregistration/v1alpha1`,
`k8s.io/api/admission/v1alpha1`,
`k8s.io/api/networking/v1`,
`k8s.io/kubernetes/federation/apis/federation/v1beta1`,
`k8s.io/kubernetes/pkg/apis/admission/v1alpha1`,
`k8s.io/metrics/pkg/apis/metrics/v1alpha1`,
`k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1`,
`k8s.io/apiserver/pkg/apis/audit/v1alpha1`,
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/admission/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
&announced.GroupMetaFactoryArgs{
GroupName: admission.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version},
ImportPrefix: "k8s.io/kubernetes/pkg/apis/admission",
ImportPrefix: "k8s.io/api/admission",
RootScopedKinds: sets.NewString("AdmissionReview"),
AddInternalObjectsToScheme: admission.AddToScheme,
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/admission/v1alpha1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/admission
// +k8s:openapi-gen=false
// +k8s:conversion-gen-external-types=../../../../vendor/k8s.io/api/admission/v1alpha1
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/admission/v1alpha1

// +groupName=admission.k8s.io
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/admission/v1alpha1"
7 changes: 4 additions & 3 deletions pkg/apis/admission/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ limitations under the License.
package v1alpha1

import (
admissionv1alpha1 "k8s.io/api/admission/v1alpha1"
authenticationv1 "k8s.io/api/authentication/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/admission"
)

// NewAdmissionReview returns an AdmissionReview for the provided admission.Attributes
func NewAdmissionReview(attr admission.Attributes) AdmissionReview {
func NewAdmissionReview(attr admission.Attributes) admissionv1alpha1.AdmissionReview {
gvk := attr.GetKind()
gvr := attr.GetResource()
aUserInfo := attr.GetUserInfo()
Expand All @@ -40,8 +41,8 @@ func NewAdmissionReview(attr admission.Attributes) AdmissionReview {
userInfo.Extra[key] = authenticationv1.ExtraValue(val)
}

return AdmissionReview{
Spec: AdmissionReviewSpec{
return admissionv1alpha1.AdmissionReview{
Spec: admissionv1alpha1.AdmissionReviewSpec{
Name: attr.GetName(),
Namespace: attr.GetNamespace(),
Resource: metav1.GroupVersionResource{
Expand Down
19 changes: 3 additions & 16 deletions pkg/apis/admission/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
admissionv1alpha1 "k8s.io/api/admission/v1alpha1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

Expand All @@ -34,25 +33,13 @@ func Resource(resource string) schema.GroupResource {
}

var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
localSchemeBuilder = &admissionv1alpha1.SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes, RegisterDefaults)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&AdmissionReview{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
localSchemeBuilder.Register(RegisterDefaults)
}
5 changes: 3 additions & 2 deletions plugin/pkg/admission/webhook/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/golang/glog"

admissionv1alpha1 "k8s.io/api/admission/v1alpha1"
"k8s.io/api/admissionregistration/v1alpha1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -38,7 +39,7 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api"
admissionv1alpha1 "k8s.io/kubernetes/pkg/apis/admission/v1alpha1"
admissionv1alpha1helper "k8s.io/kubernetes/pkg/apis/admission/v1alpha1"
admissioninit "k8s.io/kubernetes/pkg/kubeapiserver/admission"
"k8s.io/kubernetes/pkg/kubeapiserver/admission/configuration"

Expand Down Expand Up @@ -213,7 +214,7 @@ func (a *GenericAdmissionWebhook) callHook(ctx context.Context, h *v1alpha1.Exte
}

// Make the webhook request
request := admissionv1alpha1.NewAdmissionReview(attr)
request := admissionv1alpha1helper.NewAdmissionReview(attr)
client, err := a.hookClient(h)
if err != nil {
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
Expand Down
2 changes: 1 addition & 1 deletion plugin/pkg/admission/webhook/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
"strings"
"testing"

"k8s.io/api/admission/v1alpha1"
registrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/authentication/user"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/admission/v1alpha1"

_ "k8s.io/kubernetes/pkg/apis/admission/install"
)
Expand Down
21 changes: 21 additions & 0 deletions staging/src/k8s.io/api/admission/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2017 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,register
// +k8s:openapi-gen=false

// +groupName=admission.k8s.io
package v1alpha1 // import "k8s.io/api/admission/v1alpha1"
File renamed without changes.
51 changes: 51 additions & 0 deletions staging/src/k8s.io/api/admission/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2017 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 v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName is the group name for this API.
const GroupName = "admission.k8s.io"

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

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

var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&AdmissionReview{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
File renamed without changes.
Loading

0 comments on commit 57a96ca

Please sign in to comment.