Skip to content

Commit

Permalink
Merge pull request #570 from nicksardo/pkg-rename
Browse files Browse the repository at this point in the history
Renaming few remaining packages
  • Loading branch information
nicksardo authored Apr 7, 2017
2 parents cfef9d8 + 5b37d2b commit 7c635a8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
34 changes: 17 additions & 17 deletions controllers/gce/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
listers "k8s.io/client-go/listers/core/v1"
base_api "k8s.io/client-go/pkg/api"
api "k8s.io/client-go/pkg/api/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
Expand Down Expand Up @@ -103,7 +103,7 @@ func NewLoadBalancerController(kubeClient kubernetes.Interface, clusterManager *
CloudClusterManager: clusterManager,
stopCh: make(chan struct{}),
recorder: eventBroadcaster.NewRecorder(base_api.Scheme,
api.EventSource{Component: "loadbalancer-controller"}),
api_v1.EventSource{Component: "loadbalancer-controller"}),
}
lbc.nodeQueue = NewTaskQueue(lbc.syncNodes)
lbc.ingQueue = NewTaskQueue(lbc.sync)
Expand All @@ -117,7 +117,7 @@ func NewLoadBalancerController(kubeClient kubernetes.Interface, clusterManager *
glog.Infof("Ignoring add for ingress %v based on annotation %v", addIng.Name, ingressClassKey)
return
}
lbc.recorder.Eventf(addIng, api.EventTypeNormal, "ADD", fmt.Sprintf("%s/%s", addIng.Namespace, addIng.Name))
lbc.recorder.Eventf(addIng, api_v1.EventTypeNormal, "ADD", fmt.Sprintf("%s/%s", addIng.Namespace, addIng.Name))
lbc.ingQueue.enqueue(obj)
},
DeleteFunc: func(obj interface{}) {
Expand Down Expand Up @@ -157,24 +157,24 @@ func NewLoadBalancerController(kubeClient kubernetes.Interface, clusterManager *

lbc.svcLister.Indexer, lbc.svcController = cache.NewIndexerInformer(
cache.NewListWatchFromClient(lbc.client.Core().RESTClient(), "services", namespace, fields.Everything()),
&api.Service{},
&api_v1.Service{},
resyncPeriod,
svcHandlers,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)

lbc.podLister.Indexer, lbc.podController = cache.NewIndexerInformer(
cache.NewListWatchFromClient(lbc.client.Core().RESTClient(), "pods", namespace, fields.Everything()),
&api.Pod{},
&api_v1.Pod{},
resyncPeriod,
cache.ResourceEventHandlerFuncs{},
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)

// Node watch handlers
lbc.nodeLister.Indexer, lbc.nodeController = cache.NewIndexerInformer(
cache.NewListWatchFromClient(lbc.client.Core().RESTClient(), "nodes", api.NamespaceAll, fields.Everything()),
&api.Node{},
cache.NewListWatchFromClient(lbc.client.Core().RESTClient(), "nodes", api_v1.NamespaceAll, fields.Everything()),
&api_v1.Node{},
resyncPeriod,
cache.ResourceEventHandlerFuncs{},
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
Expand All @@ -189,7 +189,7 @@ func NewLoadBalancerController(kubeClient kubernetes.Interface, clusterManager *

// enqueueIngressForService enqueues all the Ingress' for a Service.
func (lbc *LoadBalancerController) enqueueIngressForService(obj interface{}) {
svc := obj.(*api.Service)
svc := obj.(*api_v1.Service)
ings, err := lbc.ingLister.GetServiceIngress(svc)
if err != nil {
glog.V(5).Infof("ignoring service %v: %v", svc.Name, err)
Expand Down Expand Up @@ -311,7 +311,7 @@ func (lbc *LoadBalancerController) sync(key string) (err error) {
eventMsg += " :Quota"
}
if ingExists {
lbc.recorder.Eventf(obj.(*extensions.Ingress), api.EventTypeWarning, eventMsg, err.Error())
lbc.recorder.Eventf(obj.(*extensions.Ingress), api_v1.EventTypeWarning, eventMsg, err.Error())
} else {
err = fmt.Errorf("%v, error: %v", eventMsg, err)
}
Expand All @@ -331,10 +331,10 @@ func (lbc *LoadBalancerController) sync(key string) (err error) {
if urlMap, err := lbc.tr.toURLMap(&ing); err != nil {
syncError = fmt.Errorf("%v, convert to url map error %v", syncError, err)
} else if err := l7.UpdateUrlMap(urlMap); err != nil {
lbc.recorder.Eventf(&ing, api.EventTypeWarning, "UrlMap", err.Error())
lbc.recorder.Eventf(&ing, api_v1.EventTypeWarning, "UrlMap", err.Error())
syncError = fmt.Errorf("%v, update url map error: %v", syncError, err)
} else if err := lbc.updateIngressStatus(l7, ing); err != nil {
lbc.recorder.Eventf(&ing, api.EventTypeWarning, "Status", err.Error())
lbc.recorder.Eventf(&ing, api_v1.EventTypeWarning, "Status", err.Error())
syncError = fmt.Errorf("%v, update ingress error: %v", syncError, err)
}
return syncError
Expand All @@ -352,8 +352,8 @@ func (lbc *LoadBalancerController) updateIngressStatus(l7 *loadbalancers.L7, ing
return err
}
currIng.Status = extensions.IngressStatus{
LoadBalancer: api.LoadBalancerStatus{
Ingress: []api.LoadBalancerIngress{
LoadBalancer: api_v1.LoadBalancerStatus{
Ingress: []api_v1.LoadBalancerIngress{
{IP: ip},
},
},
Expand All @@ -367,7 +367,7 @@ func (lbc *LoadBalancerController) updateIngressStatus(l7 *loadbalancers.L7, ing
if _, err := ingClient.UpdateStatus(currIng); err != nil {
return err
}
lbc.recorder.Eventf(currIng, api.EventTypeNormal, "CREATE", "ip: %v", ip)
lbc.recorder.Eventf(currIng, api_v1.EventTypeNormal, "CREATE", "ip: %v", ip)
}
}
// Update annotations through /update endpoint
Expand Down Expand Up @@ -435,11 +435,11 @@ func (lbc *LoadBalancerController) syncNodes(key string) error {
}

func getNodeReadyPredicate() listers.NodeConditionPredicate {
return func(node *api.Node) bool {
return func(node *api_v1.Node) bool {
for ix := range node.Status.Conditions {
condition := &node.Status.Conditions[ix]
if condition.Type == api.NodeReady {
return condition.Status == api.ConditionTrue
if condition.Type == api_v1.NodeReady {
return condition.Status == api_v1.ConditionTrue
}
}
return false
Expand Down
6 changes: 3 additions & 3 deletions controllers/gce/controller/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

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

"k8s.io/ingress/controllers/gce/loadbalancers"
Expand Down Expand Up @@ -64,11 +64,11 @@ func (t *apiServerTLSLoader) load(ing *extensions.Ingress) (*loadbalancers.TLSCe
if err != nil {
return nil, err
}
cert, ok := secret.Data[api.TLSCertKey]
cert, ok := secret.Data[api_v1.TLSCertKey]
if !ok {
return nil, fmt.Errorf("secret %v has no private key", secretName)
}
key, ok := secret.Data[api.TLSPrivateKeyKey]
key, ok := secret.Data[api_v1.TLSPrivateKeyKey]
if !ok {
return nil, fmt.Errorf("secret %v has no cert", secretName)
}
Expand Down
34 changes: 17 additions & 17 deletions controllers/gce/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
listers "k8s.io/client-go/listers/core/v1"
api "k8s.io/client-go/pkg/api/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -221,9 +221,9 @@ type StoreToPodLister struct {
cache.Indexer
}

func (s *StoreToPodLister) List(selector labels.Selector) (ret []*api.Pod, err error) {
func (s *StoreToPodLister) List(selector labels.Selector) (ret []*api_v1.Pod, err error) {
err = ListAll(s.Indexer, selector, func(m interface{}) {
ret = append(ret, m.(*api.Pod))
ret = append(ret, m.(*api_v1.Pod))
})
return ret, err
}
Expand Down Expand Up @@ -254,7 +254,7 @@ func (s *StoreToIngressLister) List() (ing extensions.IngressList, err error) {

// GetServiceIngress gets all the Ingress' that have rules pointing to a service.
// Note that this ignores services without the right nodePorts.
func (s *StoreToIngressLister) GetServiceIngress(svc *api.Service) (ings []extensions.Ingress, err error) {
func (s *StoreToIngressLister) GetServiceIngress(svc *api_v1.Service) (ings []extensions.Ingress, err error) {
IngressLoop:
for _, m := range s.Store.List() {
ing := *m.(*extensions.Ingress)
Expand Down Expand Up @@ -309,7 +309,7 @@ func (t *GCETranslator) toURLMap(ing *extensions.Ingress) (utils.GCEURLMap, erro
// to all other services under the assumption that the user will
// modify nodeport.
if _, ok := err.(errorNodePortNotFound); ok {
t.recorder.Eventf(ing, api.EventTypeWarning, "Service", err.(errorNodePortNotFound).Error())
t.recorder.Eventf(ing, api_v1.EventTypeWarning, "Service", err.(errorNodePortNotFound).Error())
continue
}

Expand Down Expand Up @@ -343,12 +343,12 @@ func (t *GCETranslator) toURLMap(ing *extensions.Ingress) (utils.GCEURLMap, erro
if _, ok := err.(errorNodePortNotFound); ok {
msg = fmt.Sprintf("couldn't find nodeport for %v/%v", ing.Namespace, ing.Spec.Backend.ServiceName)
}
t.recorder.Eventf(ing, api.EventTypeWarning, "Service", fmt.Sprintf("failed to identify user specified default backend, %v, using system default", msg))
t.recorder.Eventf(ing, api_v1.EventTypeWarning, "Service", fmt.Sprintf("failed to identify user specified default backend, %v, using system default", msg))
} else if defaultBackend != nil {
t.recorder.Eventf(ing, api.EventTypeNormal, "Service", fmt.Sprintf("default backend set to %v:%v", ing.Spec.Backend.ServiceName, defaultBackend.Port))
t.recorder.Eventf(ing, api_v1.EventTypeNormal, "Service", fmt.Sprintf("default backend set to %v:%v", ing.Spec.Backend.ServiceName, defaultBackend.Port))
}
} else {
t.recorder.Eventf(ing, api.EventTypeNormal, "Service", "no user specified default backend, using system default")
t.recorder.Eventf(ing, api_v1.EventTypeNormal, "Service", "no user specified default backend, using system default")
}
hostPathBackend.PutDefaultBackend(defaultBackend)
return hostPathBackend, nil
Expand All @@ -374,7 +374,7 @@ func (t *GCETranslator) toGCEBackend(be *extensions.IngressBackend, ns string) (
// and returns the nodeport.
func (t *GCETranslator) getServiceNodePort(be extensions.IngressBackend, namespace string) (int, error) {
obj, exists, err := t.svcLister.Indexer.Get(
&api.Service{
&api_v1.Service{
ObjectMeta: meta_v1.ObjectMeta{
Name: be.ServiceName,
Namespace: namespace,
Expand All @@ -388,7 +388,7 @@ func (t *GCETranslator) getServiceNodePort(be extensions.IngressBackend, namespa
return invalidPort, errorNodePortNotFound{be, err}
}
var nodePort int
for _, p := range obj.(*api.Service).Spec.Ports {
for _, p := range obj.(*api_v1.Service).Spec.Ports {
switch be.ServicePort.Type {
case intstr.Int:
if p.Port == be.ServicePort.IntVal {
Expand Down Expand Up @@ -440,7 +440,7 @@ func (t *GCETranslator) toNodePorts(ings *extensions.IngressList) []int64 {
return knownPorts
}

func getZone(n *api.Node) string {
func getZone(n *api_v1.Node) string {
zone, ok := n.Labels[zoneKey]
if !ok {
return defaultZone
Expand Down Expand Up @@ -479,7 +479,7 @@ func (t *GCETranslator) ListZones() ([]string, error) {

// geHTTPProbe returns the http readiness probe from the first container
// that matches targetPort, from the set of pods matching the given labels.
func (t *GCETranslator) getHTTPProbe(svc api.Service, targetPort intstr.IntOrString) (*api.Probe, error) {
func (t *GCETranslator) getHTTPProbe(svc api_v1.Service, targetPort intstr.IntOrString) (*api_v1.Probe, error) {
l := svc.Spec.Selector

// Lookup any container with a matching targetPort from the set of pods
Expand Down Expand Up @@ -531,9 +531,9 @@ func (t *GCETranslator) getHTTPProbe(svc api.Service, targetPort intstr.IntOrStr
// - an HTTPGet probe, as opposed to a tcp or exec probe
// - has a scheme of HTTP, as opposed to HTTPS
// - has no special host or headers fields
func isSimpleHTTPProbe(probe *api.Probe) bool {
func isSimpleHTTPProbe(probe *api_v1.Probe) bool {
return (probe != nil && probe.Handler.HTTPGet != nil && probe.Handler.HTTPGet.Host == "" &&
probe.Handler.HTTPGet.Scheme == api.URISchemeHTTP && len(probe.Handler.HTTPGet.HTTPHeaders) == 0)
probe.Handler.HTTPGet.Scheme == api_v1.URISchemeHTTP && len(probe.Handler.HTTPGet.HTTPHeaders) == 0)
}

// HealthCheck returns the http readiness probe for the endpoint backing the
Expand All @@ -546,7 +546,7 @@ func (t *GCETranslator) HealthCheck(port int64) (*compute.HttpHealthCheck, error
var healthCheck *compute.HttpHealthCheck
// Find the label and target port of the one service with the given nodePort
for _, as := range sl {
s := as.(*api.Service)
s := as.(*api_v1.Service)
for _, p := range s.Spec.Ports {

// only one Service can match this nodePort, try and look up
Expand Down Expand Up @@ -600,13 +600,13 @@ func (t *GCETranslator) HealthCheck(port int64) (*compute.HttpHealthCheck, error
healthCheck = utils.DefaultHealthCheckTemplate(port)
}
for _, ing := range ingresses {
t.recorder.Eventf(&ing, api.EventTypeNormal, "GCE", fmt.Sprintf("health check using %v:%v%v", healthCheck.Host, healthCheck.Port, healthCheck.RequestPath))
t.recorder.Eventf(&ing, api_v1.EventTypeNormal, "GCE", fmt.Sprintf("health check using %v:%v%v", healthCheck.Host, healthCheck.Port, healthCheck.RequestPath))
}
return healthCheck, nil
}

// PodsByCreationTimestamp sorts a list of Pods by creation timestamp, using their names as a tie breaker.
type PodsByCreationTimestamp []*api.Pod
type PodsByCreationTimestamp []*api_v1.Pod

func (o PodsByCreationTimestamp) Len() int { return len(o) }
func (o PodsByCreationTimestamp) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
Expand Down
14 changes: 7 additions & 7 deletions controllers/gce/storage/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
api "k8s.io/client-go/pkg/api/v1"
api_v1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"
)

Expand Down Expand Up @@ -58,7 +58,7 @@ func (c *ConfigMapVault) Get(key string) (string, bool, error) {
if err != nil || !found {
return "", false, err
}
data := item.(*api.ConfigMap).Data
data := item.(*api_v1.ConfigMap).Data
c.storeLock.Lock()
defer c.storeLock.Unlock()
if k, ok := data[key]; ok {
Expand All @@ -73,7 +73,7 @@ func (c *ConfigMapVault) Get(key string) (string, bool, error) {
func (c *ConfigMapVault) Put(key, val string) error {
c.storeLock.Lock()
defer c.storeLock.Unlock()
apiObj := &api.ConfigMap{
apiObj := &api_v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: c.name,
Namespace: c.namespace,
Expand All @@ -83,7 +83,7 @@ func (c *ConfigMapVault) Put(key, val string) error {

item, exists, err := c.ConfigMapStore.GetByKey(cfgMapKey)
if err == nil && exists {
data := item.(*api.ConfigMap).Data
data := item.(*api_v1.ConfigMap).Data
existingVal, ok := data[key]
if ok && existingVal == val {
// duplicate, no need to update.
Expand Down Expand Up @@ -155,21 +155,21 @@ type APIServerConfigMapStore struct {

// Add adds the given config map to the apiserver's store.
func (a *APIServerConfigMapStore) Add(obj interface{}) error {
cfg := obj.(*api.ConfigMap)
cfg := obj.(*api_v1.ConfigMap)
_, err := a.client.Core().ConfigMaps(cfg.Namespace).Create(cfg)
return err
}

// Update updates the existing config map object.
func (a *APIServerConfigMapStore) Update(obj interface{}) error {
cfg := obj.(*api.ConfigMap)
cfg := obj.(*api_v1.ConfigMap)
_, err := a.client.Core().ConfigMaps(cfg.Namespace).Update(cfg)
return err
}

// Delete deletes the existing config map object.
func (a *APIServerConfigMapStore) Delete(obj interface{}) error {
cfg := obj.(*api.ConfigMap)
cfg := obj.(*api_v1.ConfigMap)
return a.client.Core().ConfigMaps(cfg.Namespace).Delete(cfg.Name, &metav1.DeleteOptions{})
}

Expand Down

0 comments on commit 7c635a8

Please sign in to comment.