Skip to content

Commit

Permalink
better alias for package
Browse files Browse the repository at this point in the history
  • Loading branch information
mkabilov committed Jul 25, 2017
1 parent 941bfb3 commit 1659a9b
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 70 deletions.
6 changes: 3 additions & 3 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"

"github.com/Sirupsen/logrus"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/apps/v1beta1"
Expand Down Expand Up @@ -62,7 +62,7 @@ type Cluster struct {
mu sync.Mutex
masterLess bool
userSyncStrategy spec.UserSyncer
deleteOptions *meta_v1.DeleteOptions
deleteOptions *metav1.DeleteOptions
podEventsQueue *cache.FIFO

teamsAPIClient *teams.API
Expand Down Expand Up @@ -101,7 +101,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql
kubeResources: kubeResources,
masterLess: false,
userSyncStrategy: users.DefaultUserSyncStrategy{},
deleteOptions: &meta_v1.DeleteOptions{OrphanDependents: &orphanDependents},
deleteOptions: &metav1.DeleteOptions{OrphanDependents: &orphanDependents},
podEventsQueue: podEventsQueue,
KubeClient: kubeClient,
teamsAPIClient: teams.NewTeamsAPI(cfg.OpConfig.TeamsAPIUrl, logger.Logger),
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"fmt"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/pkg/api/v1"
Expand All @@ -19,7 +19,7 @@ func (c *Cluster) ExecCommand(podName *spec.NamespacedName, command ...string) (
execErr bytes.Buffer
)

pod, err := c.KubeClient.Pods(podName.Namespace).Get(podName.Name, meta_v1.GetOptions{})
pod, err := c.KubeClient.Pods(podName.Namespace).Get(podName.Name, metav1.GetOptions{})
if err != nil {
return "", fmt.Errorf("could not get pod info: %v", err)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/cluster/k8sres.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sort"

"k8s.io/apimachinery/pkg/api/resource"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/apps/v1beta1"
Expand Down Expand Up @@ -312,7 +312,7 @@ func (c *Cluster) generatePodTemplate(resourceRequirements *v1.ResourceRequireme
}

template := v1.PodTemplateSpec{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Labels: c.labelsSet(),
Namespace: c.Metadata.Name,
},
Expand All @@ -338,7 +338,7 @@ func (c *Cluster) generateStatefulSet(spec spec.PostgresSpec) (*v1beta1.Stateful
}

statefulSet := &v1beta1.StatefulSet{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: c.Metadata.Name,
Namespace: c.Metadata.Namespace,
Labels: c.labelsSet(),
Expand All @@ -355,7 +355,7 @@ func (c *Cluster) generateStatefulSet(spec spec.PostgresSpec) (*v1beta1.Stateful
}

func generatePersistentVolumeClaimTemplate(volumeSize, volumeStorageClass string) (*v1.PersistentVolumeClaim, error) {
metadata := meta_v1.ObjectMeta{
metadata := metav1.ObjectMeta{
Name: constants.DataVolumeName,
}
if volumeStorageClass != "" {
Expand Down Expand Up @@ -413,7 +413,7 @@ func (c *Cluster) generateSingleUserSecret(namespace string, pgUser spec.PgUser)
}
username := pgUser.Name
secret := v1.Secret{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: c.credentialSecretName(username),
Namespace: namespace,
Labels: c.labelsSet(),
Expand Down Expand Up @@ -469,7 +469,7 @@ func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec)
}

service := &v1.Service{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: c.Metadata.Namespace,
Labels: c.roleLabelsSet(role),
Expand All @@ -483,7 +483,7 @@ func (c *Cluster) generateService(role PostgresRole, newSpec *spec.PostgresSpec)

func (c *Cluster) generateMasterEndpoints(subsets []v1.EndpointSubset) *v1.Endpoints {
endpoints := &v1.Endpoints{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: c.Metadata.Name,
Namespace: c.Metadata.Namespace,
Labels: c.roleLabelsSet(Master),
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cluster
import (
"fmt"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"

"github.com/zalando-incubator/postgres-operator/pkg/spec"
Expand All @@ -13,7 +13,7 @@ import (

func (c *Cluster) listPods() ([]v1.Pod, error) {
ns := c.Metadata.Namespace
listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: c.labelsSet().String(),
}

Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *Cluster) recreatePods() error {
ls := c.labelsSet()
namespace := c.Metadata.Namespace

listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: ls.String(),
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/cluster/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cluster
import (
"fmt"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/apps/v1beta1"
Expand All @@ -17,7 +17,7 @@ import (

func (c *Cluster) loadResources() error {
ns := c.Metadata.Namespace
listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: c.labelsSet().String(),
}

Expand Down Expand Up @@ -172,7 +172,7 @@ func (c *Cluster) replaceStatefulSet(newStatefulSet *v1beta1.StatefulSet) error
orphanDepencies := true
oldStatefulset := c.Statefulset

options := meta_v1.DeleteOptions{OrphanDependents: &orphanDepencies}
options := metav1.DeleteOptions{OrphanDependents: &orphanDepencies}
if err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Delete(oldStatefulset.Name, &options); err != nil {
return fmt.Errorf("could not delete statefulset %q: %v", statefulSetName, err)
}
Expand All @@ -183,7 +183,7 @@ func (c *Cluster) replaceStatefulSet(newStatefulSet *v1beta1.StatefulSet) error

err := retryutil.Retry(constants.StatefulsetDeletionInterval, constants.StatefulsetDeletionTimeout,
func() (bool, error) {
_, err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Get(oldStatefulset.Name, meta_v1.GetOptions{})
_, err := c.KubeClient.StatefulSets(oldStatefulset.Namespace).Get(oldStatefulset.Name, metav1.GetOptions{})

return err != nil, nil
})
Expand Down Expand Up @@ -263,7 +263,7 @@ func (c *Cluster) updateService(role PostgresRole, newService *v1.Service) error
if role == Master {
// for the master service we need to re-create the endpoint as well. Get the up-to-date version of
// the addresses stored in it before the service is deleted (deletion of the service removes the endpooint)
currentEndpoint, err = c.KubeClient.Endpoints(c.Service[role].Namespace).Get(c.Service[role].Name, meta_v1.GetOptions{})
currentEndpoint, err = c.KubeClient.Endpoints(c.Service[role].Namespace).Get(c.Service[role].Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("could not get current cluster endpoints: %v", err)
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func (c *Cluster) applySecrets() error {
secret, err := c.KubeClient.Secrets(secretSpec.Namespace).Create(secretSpec)
if k8sutil.ResourceAlreadyExists(err) {
var userMap map[string]spec.PgUser
curSecret, err := c.KubeClient.Secrets(secretSpec.Namespace).Get(secretSpec.Name, meta_v1.GetOptions{})
curSecret, err := c.KubeClient.Secrets(secretSpec.Namespace).Get(secretSpec.Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("could not get current secret: %v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/cluster/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/apps/v1beta1"
Expand Down Expand Up @@ -124,7 +124,7 @@ func (c *Cluster) getOAuthToken() (string, error) {
// Temporary getting postgresql-operator secret from the NamespaceDefault
credentialsSecret, err := c.KubeClient.
Secrets(c.OpConfig.OAuthTokenSecretName.Namespace).
Get(c.OpConfig.OAuthTokenSecretName.Name, meta_v1.GetOptions{})
Get(c.OpConfig.OAuthTokenSecretName.Name, metav1.GetOptions{})

if err != nil {
c.logger.Debugf("Oauth token secret name: %q", c.OpConfig.OAuthTokenSecretName)
Expand Down Expand Up @@ -194,7 +194,7 @@ func (c *Cluster) waitForPodDeletion(podEvents chan spec.PodEvent) error {
func (c *Cluster) waitStatefulsetReady() error {
return retryutil.Retry(c.OpConfig.ResourceCheckInterval, c.OpConfig.ResourceCheckTimeout,
func() (bool, error) {
listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: c.labelsSet().String(),
}
ss, err := c.KubeClient.StatefulSets(c.Metadata.Namespace).List(listOptions)
Expand All @@ -214,15 +214,15 @@ func (c *Cluster) waitPodLabelsReady() error {
ls := c.labelsSet()
namespace := c.Metadata.Namespace

listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: ls.String(),
}
masterListOption := meta_v1.ListOptions{
masterListOption := metav1.ListOptions{
LabelSelector: labels.Merge(ls, labels.Set{
c.OpConfig.PodRoleLabel: constants.PodRoleMaster,
}).String(),
}
replicaListOption := meta_v1.ListOptions{
replicaListOption := metav1.ListOptions{
LabelSelector: labels.Merge(ls, labels.Set{
c.OpConfig.PodRoleLabel: constants.PodRoleReplica,
}).String(),
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"k8s.io/apimachinery/pkg/api/resource"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"

"github.com/zalando-incubator/postgres-operator/pkg/spec"
Expand All @@ -18,7 +18,7 @@ import (

func (c *Cluster) listPersistentVolumeClaims() ([]v1.PersistentVolumeClaim, error) {
ns := c.Metadata.Namespace
listOptions := meta_v1.ListOptions{
listOptions := metav1.ListOptions{
LabelSelector: c.labelsSet().String(),
}

Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *Cluster) listPersistentVolumes() ([]*v1.PersistentVolume, error) {
continue
}
}
pv, err := c.KubeClient.PersistentVolumes().Get(pvc.Spec.VolumeName, meta_v1.GetOptions{})
pv, err := c.KubeClient.PersistentVolumes().Get(pvc.Spec.VolumeName, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("could not get PersistentVolume: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/Sirupsen/logrus"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
Expand Down Expand Up @@ -78,7 +78,7 @@ func (c *Controller) initOperatorConfig() {

if c.config.ConfigMapName != (spec.NamespacedName{}) {
configMap, err := c.KubeClient.ConfigMaps(c.config.ConfigMapName.Namespace).
Get(c.config.ConfigMapName.Name, meta_v1.GetOptions{})
Get(c.config.ConfigMapName.Name, metav1.GetOptions{})
if err != nil {
panic(err)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package controller

import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/pkg/api/v1"
Expand All @@ -10,11 +10,11 @@ import (
"github.com/zalando-incubator/postgres-operator/pkg/util"
)

func (c *Controller) podListFunc(options meta_v1.ListOptions) (runtime.Object, error) {
func (c *Controller) podListFunc(options metav1.ListOptions) (runtime.Object, error) {
var labelSelector string
var fieldSelector string

opts := meta_v1.ListOptions{
opts := metav1.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fieldSelector,
Watch: options.Watch,
Expand All @@ -25,11 +25,11 @@ func (c *Controller) podListFunc(options meta_v1.ListOptions) (runtime.Object, e
return c.KubeClient.Pods(c.opConfig.Namespace).List(opts)
}

func (c *Controller) podWatchFunc(options meta_v1.ListOptions) (watch.Interface, error) {
func (c *Controller) podWatchFunc(options metav1.ListOptions) (watch.Interface, error) {
var labelSelector string
var fieldSelector string

opts := meta_v1.ListOptions{
opts := metav1.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fieldSelector,
Watch: options.Watch,
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync/atomic"
"time"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
Expand All @@ -25,22 +25,22 @@ func (c *Controller) clusterResync(stopCh <-chan struct{}) {
for {
select {
case <-ticker.C:
c.clusterListFunc(meta_v1.ListOptions{ResourceVersion: "0"})
c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"})
case <-stopCh:
return
}
}
}

func (c *Controller) clusterListFunc(options meta_v1.ListOptions) (runtime.Object, error) {
func (c *Controller) clusterListFunc(options metav1.ListOptions) (runtime.Object, error) {
var list spec.PostgresqlList
var activeClustersCnt, failedClustersCnt int

req := c.RestClient.
Get().
Namespace(c.opConfig.Namespace).
Resource(constants.ResourceName).
VersionedParams(&options, meta_v1.ParameterCodec)
VersionedParams(&options, metav1.ParameterCodec)

b, err := req.DoRaw()
if err != nil {
Expand Down Expand Up @@ -99,13 +99,13 @@ func (d *tprDecoder) Decode() (action watch.EventType, object runtime.Object, er
return e.Type, &e.Object, nil
}

func (c *Controller) clusterWatchFunc(options meta_v1.ListOptions) (watch.Interface, error) {
func (c *Controller) clusterWatchFunc(options metav1.ListOptions) (watch.Interface, error) {
options.Watch = true
r, err := c.RestClient.
Get().
Namespace(c.opConfig.Namespace).
Resource(constants.ResourceName).
VersionedParams(&options, meta_v1.ParameterCodec).
VersionedParams(&options, metav1.ParameterCodec).
FieldsSelectorParam(nil).
Stream()

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"hash/crc32"

meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
extv1beta "k8s.io/client-go/pkg/apis/extensions/v1beta1"

Expand All @@ -30,7 +30,7 @@ func (c *Controller) makeClusterConfig() cluster.Config {

func thirdPartyResource(TPRName string) *extv1beta.ThirdPartyResource {
return &extv1beta.ThirdPartyResource{
ObjectMeta: meta_v1.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
//ThirdPartyResources are cluster-wide
Name: TPRName,
},
Expand Down Expand Up @@ -69,7 +69,7 @@ func (c *Controller) getInfrastructureRoles(rolesSecret *spec.NamespacedName) (r

infraRolesSecret, err := c.KubeClient.
Secrets(rolesSecret.Namespace).
Get(rolesSecret.Name, meta_v1.GetOptions{})
Get(rolesSecret.Name, metav1.GetOptions{})
if err != nil {
c.logger.Debugf("Infrastructure roles secret name: %q", *rolesSecret)
return nil, fmt.Errorf("could not get infrastructure roles secret: %v", err)
Expand Down

0 comments on commit 1659a9b

Please sign in to comment.