First compilable state with go-client 6.0

There are shortcuts in this code, i.e. we created the deepcopy function
by using the deepcopy package instead of the generated code, that will
be addressed once migrated to client-go v8. Also, some objects,
particularly statefulsets, are still taken from v1beta, this will also
be addressed in further commits once the changes are stabilized.
This commit is contained in:
Oleksii Kliukin 2018-07-26 12:26:57 +02:00
parent 439f4321ee
commit d1c22d4a2e
7 changed files with 119 additions and 19 deletions

20
glide.lock generated
View File

@ -1,8 +1,8 @@
hash: 3180f1ac5556054a2c2d28615737f0eee29a725ae798d5b877e92f42dcbffff5
updated: 2018-07-24T16:45:06.47728+02:00
hash: f2f7f9d5d3c6f0f370fcec00e6c4a7c8fe84c0e75579d9bf7e40f19fe837b7c2
updated: 2018-07-25T15:45:34.017577+02:00
imports:
- name: github.com/aws/aws-sdk-go
version: bc3f534c19ffdf835e524e11f0f825b3eaf541c3
version: 468b9714c11f10b22e533253b35eb9c28f4be691
subpackages:
- aws
- aws/awserr
@ -97,7 +97,7 @@ imports:
- name: github.com/jmespath/go-jmespath
version: c2b33e8439af944379acbdd9c3a5fe0bc44bd8a5
- name: github.com/json-iterator/go
version: 36b14963da70d11297d313183d7e6388c8510e1e
version: f2b4162afba35581b6d4a50d3b8f34e33c144682
- name: github.com/juju/ratelimit
version: 5b9ff866471762aa2ab2dced63c9fb6f53921342
- name: github.com/kr/text
@ -112,6 +112,10 @@ imports:
- buffer
- jlexer
- jwriter
- name: github.com/modern-go/concurrent
version: bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94
- name: github.com/modern-go/reflect2
version: 05fbef0ca5da472bbf96c9322b84a53edc03c9fd
- name: github.com/mohae/deepcopy
version: c48cc78d482608239f6c4c92a4abd87eb8761c90
- name: github.com/motomux/pretty
@ -193,7 +197,7 @@ imports:
- storage/v1alpha1
- storage/v1beta1
- name: k8s.io/apiextensions-apiserver
version: 98ecf7bbd60f9f11a72000e4f05203f542136219
version: 913221cf6cd1c328ae50ba5f25027268f6be38cf
subpackages:
- pkg/apis/apiextensions
- pkg/apis/apiextensions/v1beta1
@ -201,7 +205,7 @@ imports:
- pkg/client/clientset/clientset/scheme
- pkg/client/clientset/clientset/typed/apiextensions/v1beta1
- name: k8s.io/apimachinery
version: 180eddb345a5be3a157cea1c624700ad5bd27b8f
version: fb40df2b502912cbe3a93aa61c2b2487f39cb42f
subpackages:
- pkg/api/errors
- pkg/api/meta
@ -300,6 +304,10 @@ imports:
- util/flowcontrol
- util/homedir
- util/integer
- name: k8s.io/code-generator
version: 0ab89e584187c20cc7c1a3f30db69f3b4ab64196
- name: k8s.io/gengo
version: 906d99f89cd644eecf75ab547b29bf9f876f0b59
- name: k8s.io/kube-openapi
version: 39a7bf85c140f972372c2a0d1ee40adbf0c8bfe1
subpackages:

View File

@ -11,10 +11,13 @@ import:
- package: github.com/lib/pq
- package: github.com/motomux/pretty
- package: k8s.io/apimachinery
version: kubernetes-1.9.0
version: kubernetes-1.9.9
- package: k8s.io/apiextensions-apiserver
version: kubernetes-1.9.0
version: kubernetes-1.9.9
- package: k8s.io/client-go
version: ^6.0.0
- package: k8s.io/code-generator
version: kubernetes-1.9.9
- package: k8s.io/gengo
- package: gopkg.in/yaml.v2
- package: github.com/mohae/deepcopy

View File

@ -6,7 +6,6 @@ import (
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/api/core/v1"
"k8s.io/client-go/tools/remotecommand"
@ -54,15 +53,15 @@ func (c *Cluster) ExecCommand(podName *spec.NamespacedName, command ...string) (
Stderr: true,
}, scheme.ParameterCodec)
exec, err := remotecommand.NewExecutor(c.RestConfig, "POST", req.URL())
exec, err := remotecommand.NewSPDYExecutor(c.RestConfig, "POST", req.URL())
if err != nil {
return "", fmt.Errorf("failed to init executor: %v", err)
}
err = exec.Stream(remotecommand.StreamOptions{
SupportedProtocols: remotecommandconsts.SupportedStreamingProtocols,
Stdout: &execOut,
Stderr: &execErr,
Tty: false,
})
if err != nil {

View File

@ -147,12 +147,12 @@ func (d *crdDecoder) Decode() (action watch.EventType, object runtime.Object, er
func (c *Controller) clusterWatchFunc(options metav1.ListOptions) (watch.Interface, error) {
options.Watch = true
// MIGRATION: FieldsSelectorParam(nil)
r, err := c.KubeClient.CRDREST.
Get().
Namespace(c.opConfig.WatchedNamespace).
Resource(constants.PostgresCRDResource).
VersionedParams(&options, metav1.ParameterCodec).
FieldsSelectorParam(nil).
Stream()
if err != nil {

View File

@ -10,6 +10,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// MaintenanceWindow describes the time window when the operator is allowed to do maintenance on a cluster.
@ -154,14 +155,34 @@ var (
// will not contain any private fields not-reachable to deepcopy. This should be ok,
// since Error is never read from a Kubernetes object.
func (p *Postgresql) Clone() *Postgresql {
if p == nil {
return nil
}
if p == nil {return nil}
c := deepcopy.Copy(p).(*Postgresql)
c.Error = nil
return c
}
func (in *Postgresql) DeepCopyInto(out *Postgresql) {
if in != nil {
out = deepcopy.Copy(in).(*Postgresql)
}
return
}
func (in *Postgresql) DeepCopy() *Postgresql {
if in == nil { return nil }
out := new(Postgresql)
in.DeepCopyInto(out)
return out
}
func (in *Postgresql) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
func parseTime(s string) (time.Time, error) {
parts := strings.Split(s, ":")
if len(parts) != 2 {
@ -287,6 +308,29 @@ func validateCloneClusterDescription(clone *CloneDescription) error {
type postgresqlListCopy PostgresqlList
type postgresqlCopy Postgresql
func (in *PostgresqlList) DeepCopy() *PostgresqlList {
if in == nil { return nil }
out := new(PostgresqlList)
in.DeepCopyInto(out)
return out
}
func (in *PostgresqlList) DeepCopyInto(out *PostgresqlList) {
if in != nil {
out = deepcopy.Copy(in).(*PostgresqlList)
}
return
}
func (in *PostgresqlList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// UnmarshalJSON converts a JSON into the PostgreSQL object.
func (p *Postgresql) UnmarshalJSON(data []byte) error {
var tmp postgresqlCopy

View File

@ -6,6 +6,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/zalando-incubator/postgres-operator/pkg/spec"
"github.com/mohae/deepcopy"
"k8s.io/apimachinery/pkg/runtime"
)
type OperatorConfiguration struct {
@ -160,3 +162,46 @@ func (opcl *OperatorConfigurationList) UnmarshalJSON(data []byte) error {
*opcl = OperatorConfigurationList(ref)
return nil
}
func (in *OperatorConfiguration) DeepCopyInto(out *OperatorConfiguration) {
if in != nil {
out = deepcopy.Copy(in).(*OperatorConfiguration)
}
return
}
func (in *OperatorConfiguration) DeepCopy() *OperatorConfiguration {
if in == nil { return nil }
out := new(OperatorConfiguration)
in.DeepCopyInto(out)
return out
}
func (in *OperatorConfiguration) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
func (in *OperatorConfigurationList) DeepCopyInto(out *OperatorConfigurationList) {
if in != nil {
out = deepcopy.Copy(in).(*OperatorConfigurationList)
}
return
}
func (in *OperatorConfigurationList) DeepCopy() *OperatorConfigurationList {
if in == nil { return nil }
out := new(OperatorConfigurationList)
in.DeepCopyInto(out)
return out
}
func (in *OperatorConfigurationList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

View File

@ -4,19 +4,19 @@ import (
"fmt"
"reflect"
"k8s.io/api/core/v1"
policybeta1 "k8s.io/api/policy/v1beta1"
apiextclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apiextbeta1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/kubernetes/typed/apps/v1beta1"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
policyv1beta1 "k8s.io/client-go/kubernetes/typed/policy/v1beta1"
rbacv1beta1 "k8s.io/client-go/kubernetes/typed/rbac/v1beta1"
"k8s.io/api"
"k8s.io/api/core/v1"
policybeta1 "k8s.io/api/policy/v1beta1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
@ -93,7 +93,8 @@ func NewFromConfig(cfg *rest.Config) (KubernetesClient, error) {
Version: constants.CRDApiVersion,
}
cfg2.APIPath = constants.K8sAPIPath
cfg2.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs}
// MIGRATION: api.codecs -> scheme.Codecs?
cfg2.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
crd, err := rest.RESTClientFor(&cfg2)
if err != nil {