Skip to content

Commit

Permalink
update openapi generator. generate v1 backendconfig files
Browse files Browse the repository at this point in the history
  • Loading branch information
agau4779 committed Feb 5, 2019
1 parent 408bd9b commit 95c3c8d
Show file tree
Hide file tree
Showing 30 changed files with 1,959 additions and 289 deletions.
15 changes: 12 additions & 3 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,26 @@ set -o pipefail

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
OPENAPI_PKG=${GOPATH}/src/k8s.io/kube-openapi

${CODEGEN_PKG}/generate-groups.sh \
"deepcopy,client,informer,lister" \
k8s.io/ingress-gce/pkg/backendconfig/client k8s.io/ingress-gce/pkg/apis \
backendconfig:v1beta1 \
"backendconfig:v1beta1 backendconfig:v1" \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt

echo "Generating openapi"
go install ${CODEGEN_PKG}/cmd/openapi-gen
echo "Generating openapi for v1beta1"
go install ${OPENAPI_PKG}/cmd/openapi-gen
${GOPATH}/bin/openapi-gen \
--output-file-base zz_generated.openapi \
--input-dirs k8s.io/ingress-gce/pkg/apis/backendconfig/v1beta1\
--output-package k8s.io/ingress-gce/pkg/apis/backendconfig/v1beta1 \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt

echo "Generating openapi for v1"
go install ${OPENAPI_PKG}/cmd/openapi-gen
${GOPATH}/bin/openapi-gen \
--output-file-base zz_generated.openapi \
--input-dirs k8s.io/ingress-gce/pkg/apis/backendconfig/v1\
--output-package k8s.io/ingress-gce/pkg/apis/backendconfig/v1 \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt
21 changes: 21 additions & 0 deletions pkg/apis/backendconfig/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2018 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

// Package v1 is the v1 version of the API.
// +groupName=cloud.google.com
package v1
53 changes: 53 additions & 0 deletions pkg/apis/backendconfig/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2018 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 v1

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

"k8s.io/ingress-gce/pkg/apis/backendconfig"
)

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

// Kind takes an unqualified kind and returns back 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 = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BackendConfig{},
&BackendConfigList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
127 changes: 127 additions & 0 deletions pkg/apis/backendconfig/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
Copyright 2018 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 v1

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

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +k8s:openapi-gen=true
type BackendConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BackendConfigSpec `json:"spec,omitempty"`
Status BackendConfigStatus `json:"status,omitempty"`
}

// BackendConfigSpec is the spec for a BackendConfig resource
// +k8s:openapi-gen=true
type BackendConfigSpec struct {
Iap *IAPConfig `json:"iap,omitempty"`
Cdn *CDNConfig `json:"cdn,omitempty"`
SecurityPolicy *SecurityPolicyConfig `json:"securityPolicy,omitempty"`
TimeoutSec *int64 `json:"timeoutSec,omitempty"`
ConnectionDraining *ConnectionDrainingConfig `json:"connectionDraining,omitempty"`
SessionAffinity *SessionAffinityConfig `json:"sessionAffinity,omitempty"`
}

// BackendConfigStatus is the status for a BackendConfig resource
type BackendConfigStatus struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// BackendConfigList is a list of BackendConfig resources
type BackendConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []BackendConfig `json:"items"`
}

// IAPConfig contains configuration for IAP-enabled backends.
// +k8s:openapi-gen=true
type IAPConfig struct {
Enabled bool `json:"enabled"`
OAuthClientCredentials *OAuthClientCredentials `json:"oauthclientCredentials"`
}

// OAuthClientCredentials contains credentials for a single IAP-enabled backend.
// +k8s:openapi-gen=true
type OAuthClientCredentials struct {
// The name of a k8s secret which stores the OAuth client id & secret.
SecretName string `json:"secretName"`
// Direct reference to OAuth client id.
ClientID string `json:"clientID,omitempty"`
// Direct reference to OAuth client secret.
ClientSecret string `json:"clientSecret,omitempty"`
}

// CDNConfig contains configuration for CDN-enabled backends.
// +k8s:openapi-gen=true
type CDNConfig struct {
Enabled bool `json:"enabled"`
CachePolicy *CacheKeyPolicy `json:"cachePolicy,omitempty"`
}

// CacheKeyPolicy contains configuration for how requests to a CDN-enabled backend are cached.
// +k8s:openapi-gen=true
type CacheKeyPolicy struct {
// If true, requests to different hosts will be cached separately.
IncludeHost bool `json:"includeHost,omitempty"`
// If true, http and https requests will be cached separately.
IncludeProtocol bool `json:"includeProtocol,omitempty"`
// If true, query string parameters are included in the cache key
// according to QueryStringBlacklist and QueryStringWhitelist.
// If neither is set, the entire query string is included and if false
// the entire query string is excluded.
IncludeQueryString bool `json:"includeQueryString,omitempty"`
// Names of query strint parameters to exclude from cache keys. All other
// parameters are included. Either specify QueryStringBlacklist or
// QueryStringWhitelist, but not both.
QueryStringBlacklist []string `json:"queryStringBlacklist,omitempty"`
// Names of query string parameters to include in cache keys. All other
// parameters are excluded. Either specify QueryStringBlacklist or
// QueryStringWhitelist, but not both.
QueryStringWhitelist []string `json:"queryStringWhitelist,omitempty"`
}

// SecurityPolicyConfig contains configuration for CloudArmor-enabled backends.
type SecurityPolicyConfig struct {
// Name of the security policy that should be associated.
Name string `json:"name"`
}

// ConnectionDrainingConfig contains configuration for connection draining.
// For now the draining timeout. May manage more settings in the future.
// +k8s:openapi-gen=true
type ConnectionDrainingConfig struct {
// Draining timeout in seconds.
DrainingTimeoutSec int64 `json:"drainingTimeoutSec,omitempty"`
}

// SessionAffinityConfig contains configuration for stickyness parameters.
// +k8s:openapi-gen=true
type SessionAffinityConfig struct {
AffinityType string `json:"affinityType,omitempty"`
AffinityCookieTtlSec *int64 `json:"affinityCookieTtlSec,omitempty"`
}
Loading

0 comments on commit 95c3c8d

Please sign in to comment.