Skip to content

Commit

Permalink
Change k8s.io/api/core/v1 pkg alias to core (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Oct 21, 2017
1 parent 6b4b692 commit 976badf
Show file tree
Hide file tree
Showing 57 changed files with 593 additions and 595 deletions.
6 changes: 3 additions & 3 deletions apis/voyager/certificate.go
@@ -1,7 +1,7 @@
package voyager

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

Expand Down Expand Up @@ -80,8 +80,8 @@ type DNSChallengeProvider struct {
}

type CertificateStorage struct {
Secret *apiv1.LocalObjectReference `json:"secret,omitempty"`
Vault *VaultStore `json:"vault,omitempty"`
Secret *core.LocalObjectReference `json:"secret,omitempty"`
Vault *VaultStore `json:"vault,omitempty"`
}

type SecretStore struct {
Expand Down
10 changes: 5 additions & 5 deletions apis/voyager/ingress.go
@@ -1,7 +1,7 @@
package voyager

import (
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
Expand Down Expand Up @@ -78,11 +78,11 @@ type IngressSpec struct {
LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"`

// Compute Resources required by the sidecar container.
Resources apiv1.ResourceRequirements `json:"resources,omitempty"`
Resources core.ResourceRequirements `json:"resources,omitempty"`

// If specified, the pod's scheduling constraints
// +optional
Affinity *apiv1.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
Affinity *core.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`

// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
Expand All @@ -91,7 +91,7 @@ type IngressSpec struct {

// If specified, the pod's tolerations.
// +optional
Tolerations []apiv1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
Tolerations []core.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
}

// IngressTLS describes the transport layer security associated with an Ingress.
Expand All @@ -116,7 +116,7 @@ type IngressTLS struct {
// IngressStatus describe the current state of the Ingress.
type IngressStatus struct {
// LoadBalancer contains the current status of the load-balancer.
LoadBalancer apiv1.LoadBalancerStatus `json:"loadBalancer,omitempty"`
LoadBalancer core.LoadBalancerStatus `json:"loadBalancer,omitempty"`
}

// IngressRule represents the rules mapping the paths under a specified host to
Expand Down
6 changes: 3 additions & 3 deletions apis/voyager/v1beta1/certificate.go
@@ -1,7 +1,7 @@
package v1beta1

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

Expand Down Expand Up @@ -81,8 +81,8 @@ type DNSChallengeProvider struct {
}

type CertificateStorage struct {
Secret *apiv1.LocalObjectReference `json:"secret,omitempty"`
Vault *VaultStore `json:"vault,omitempty"`
Secret *core.LocalObjectReference `json:"secret,omitempty"`
Vault *VaultStore `json:"vault,omitempty"`
}

type VaultStore struct {
Expand Down
6 changes: 3 additions & 3 deletions apis/voyager/v1beta1/dns_resolver.go
Expand Up @@ -3,7 +3,7 @@ package v1beta1
import (
"fmt"

apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
)

const (
Expand Down Expand Up @@ -37,8 +37,8 @@ type DNSResolver struct {
Hold map[string]string `json:"hold"`
}

func DNSResolverForService(svc apiv1.Service) (useDNSResolver bool, resolver *DNSResolver, err error) {
if svc.Spec.Type != apiv1.ServiceTypeExternalName {
func DNSResolverForService(svc core.Service) (useDNSResolver bool, resolver *DNSResolver, err error) {
if svc.Spec.Type != core.ServiceTypeExternalName {
return false, nil, fmt.Errorf("Service %s@%s is expected to be of type ServiceTypeExternalName, actual type %s", svc.Name, svc.Namespace, svc.Spec.Type)
}

Expand Down
10 changes: 5 additions & 5 deletions apis/voyager/v1beta1/ingress.go
@@ -1,7 +1,7 @@
package v1beta1

import (
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
Expand Down Expand Up @@ -79,11 +79,11 @@ type IngressSpec struct {
LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"`

// Compute Resources required by the sidecar container.
Resources apiv1.ResourceRequirements `json:"resources,omitempty"`
Resources core.ResourceRequirements `json:"resources,omitempty"`

// If specified, the pod's scheduling constraints
// +optional
Affinity *apiv1.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`
Affinity *core.Affinity `json:"affinity,omitempty" protobuf:"bytes,18,opt,name=affinity"`

// If specified, the pod will be dispatched by specified scheduler.
// If not specified, the pod will be dispatched by default scheduler.
Expand All @@ -92,7 +92,7 @@ type IngressSpec struct {

// If specified, the pod's tolerations.
// +optional
Tolerations []apiv1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
Tolerations []core.Toleration `json:"tolerations,omitempty" protobuf:"bytes,22,opt,name=tolerations"`
}

// IngressTLS describes the transport layer security associated with an Ingress.
Expand All @@ -117,7 +117,7 @@ type IngressTLS struct {
// IngressStatus describe the current state of the Ingress.
type IngressStatus struct {
// LoadBalancer contains the current status of the load-balancer.
LoadBalancer apiv1.LoadBalancerStatus `json:"loadBalancer,omitempty"`
LoadBalancer core.LoadBalancerStatus `json:"loadBalancer,omitempty"`
}

// IngressRule represents the rules mapping the paths under a specified host to
Expand Down
12 changes: 6 additions & 6 deletions apis/voyager/v1beta1/objectref.go
@@ -1,12 +1,12 @@
package v1beta1

import (
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
)

func (r Ingress) ObjectReference() *apiv1.ObjectReference {
func (r Ingress) ObjectReference() *core.ObjectReference {
if r.APISchema() == APISchemaIngress {
return &apiv1.ObjectReference{
return &core.ObjectReference{
APIVersion: APISchemaIngress,
Kind: ResourceKindIngress,
Namespace: r.Namespace,
Expand All @@ -15,7 +15,7 @@ func (r Ingress) ObjectReference() *apiv1.ObjectReference {
ResourceVersion: r.ResourceVersion,
}
}
return &apiv1.ObjectReference{
return &core.ObjectReference{
APIVersion: SchemeGroupVersion.String(),
Kind: ResourceKindIngress,
Namespace: r.Namespace,
Expand All @@ -25,8 +25,8 @@ func (r Ingress) ObjectReference() *apiv1.ObjectReference {
}
}

func (c Certificate) ObjectReference() *apiv1.ObjectReference {
return &apiv1.ObjectReference{
func (c Certificate) ObjectReference() *core.ObjectReference {
return &core.ObjectReference{
APIVersion: SchemeGroupVersion.String(),
Kind: ResourceKindCertificate,
Namespace: c.Namespace,
Expand Down
6 changes: 3 additions & 3 deletions pkg/certificate/acme_test.go
Expand Up @@ -8,7 +8,7 @@ import (
fakevoyager "github.com/appscode/voyager/client/fake"
"github.com/appscode/voyager/pkg/config"
"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
Expand All @@ -17,7 +17,7 @@ func TestClient(t *testing.T) {
controller, err := NewController(
etx.Background(),
fake.NewSimpleClientset(
&apiv1.Secret{
&core.Secret{
ObjectMeta: v1.ObjectMeta{
Name: "foo",
Namespace: "bar",
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestClient(t *testing.T) {
},
ACMEUserSecretName: "foo",
Storage: api.CertificateStorage{
Secret: &apiv1.LocalObjectReference{},
Secret: &core.LocalObjectReference{},
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/certificate/controller.go
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/appscode/voyager/pkg/config"
"github.com/appscode/voyager/pkg/eventer"
"github.com/xenolf/lego/acme"
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand All @@ -37,7 +37,7 @@ type Controller struct {

crd *api.Certificate
ChallengeProvider string
UserSecret *apiv1.Secret
UserSecret *core.Secret
DNSCredentials map[string][]byte
curCert *x509.Certificate
acmeUser *ACMEUser
Expand Down Expand Up @@ -133,7 +133,7 @@ func (c *Controller) Process() error {
if err == nil {
c.recorder.Eventf(
c.crd.ObjectReference(),
apiv1.EventTypeNormal,
core.EventTypeNormal,
eventer.EventReasonCertificateIssueSuccessful,
"Successfully issued certificate",
)
Expand All @@ -152,7 +152,7 @@ func (c *Controller) Process() error {
if err == nil {
c.recorder.Eventf(
c.crd.ObjectReference(),
apiv1.EventTypeNormal,
core.EventTypeNormal,
eventer.EventReasonCertificateIssueSuccessful,
"Successfully renewed certificate",
)
Expand Down Expand Up @@ -204,7 +204,7 @@ func (c *Controller) getACMEClient() error {
if err := c.acmeClient.AgreeToTOS(); err != nil {
return fmt.Errorf("failed to register user %s. Reason: %s", c.acmeUser.Email, err)
}
c.UserSecret, err = v1u.PatchSecret(c.KubeClient, c.UserSecret, func(in *apiv1.Secret) *apiv1.Secret {
c.UserSecret, err = v1u.PatchSecret(c.KubeClient, c.UserSecret, func(in *core.Secret) *core.Secret {
if in.Data == nil {
in.Data = make(map[string][]byte)
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/certificate/controller_test.go
Expand Up @@ -15,7 +15,7 @@ import (
acf "github.com/appscode/voyager/client/fake"
"github.com/appscode/voyager/pkg/config"
"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
Expand All @@ -24,7 +24,7 @@ func TestEnsureClient(t *testing.T) {
if testing.Verbose() {
skipTestIfSecretNotProvided(t)

fakeSecret := &apiv1.Secret{
fakeSecret := &core.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "fakesecret",
Namespace: "bar",
Expand All @@ -44,15 +44,15 @@ func TestEnsureClient(t *testing.T) {
Domains: strings.Split(os.Getenv("TEST_DNS_DOMAINS"), ","),
ACMEUserSecretName: "user",
ChallengeProvider: api.ChallengeProvider{DNS: &api.DNSChallengeProvider{Provider: "googlecloud", CredentialSecretName: "fakesecret"}},
Storage: api.CertificateStorage{Secret: &apiv1.LocalObjectReference{}},
Storage: api.CertificateStorage{Secret: &core.LocalObjectReference{}},
},
}

fakeController, err := NewController(etx.Background(), fake.NewSimpleClientset(
&apiv1.Secret{
&core.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "secret", Namespace: "bar"},
},
&apiv1.Secret{
&core.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "user", Namespace: "bar"},
Data: map[string][]byte{
api.ACMEUserEmail: []byte(os.Getenv("TEST_ACME_USER_EMAIL")),
Expand Down Expand Up @@ -85,19 +85,19 @@ func TestCreate(t *testing.T) {
Domains: strings.Split(os.Getenv("TEST_DNS_DOMAINS"), ","),
ACMEUserSecretName: "user",
ChallengeProvider: api.ChallengeProvider{DNS: &api.DNSChallengeProvider{Provider: "googlecloud", CredentialSecretName: "fakesecret"}},
Storage: api.CertificateStorage{Secret: &apiv1.LocalObjectReference{}},
Storage: api.CertificateStorage{Secret: &core.LocalObjectReference{}},
},
}

fakeUser := &apiv1.Secret{
fakeUser := &core.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "user", Namespace: "bar"},
Data: map[string][]byte{
api.ACMEUserEmail: []byte(os.Getenv("TEST_ACME_USER_EMAIL")),
api.ACMEServerURL: []byte(LetsEncryptStagingURL),
},
}

fakeSecret := &apiv1.Secret{
fakeSecret := &core.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "fakesecret",
Namespace: "bar",
Expand Down
24 changes: 12 additions & 12 deletions pkg/certificate/store.go
Expand Up @@ -14,7 +14,7 @@ import (
vu "github.com/appscode/voyager/client/typed/voyager/v1beta1/util"
vault "github.com/hashicorp/vault/api"
"github.com/xenolf/lego/acme"
apiv1 "k8s.io/api/core/v1"
core "k8s.io/api/core/v1"
k8serror "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -60,32 +60,32 @@ func (s *CertStore) Get(crd *api.Certificate) (pemCrt, pemKey []byte, err error)
return nil, nil, nil
}

if data, found := secret.Data[apiv1.TLSCertKey]; !found {
if data, found := secret.Data[core.TLSCertKey]; !found {
err = fmt.Errorf("secret %s/%s is missing tls.crt", crd.Namespace, crd.SecretName())
return
} else {
pemCrt = []byte(data.(string))
}
if data, found := secret.Data[apiv1.TLSPrivateKeyKey]; !found {
if data, found := secret.Data[core.TLSPrivateKeyKey]; !found {
err = fmt.Errorf("secret %s/%s is missing tls.key", crd.Namespace, crd.SecretName())
return
} else {
pemKey = []byte(data.(string))
}
} else {
var secret *apiv1.Secret
var secret *core.Secret
secret, err = s.KubeClient.CoreV1().Secrets(crd.Namespace).Get(crd.SecretName(), metav1.GetOptions{})
if k8serror.IsNotFound(err) {
return nil, nil, nil
}
if err == nil {
if data, found := secret.Data[apiv1.TLSCertKey]; !found {
if data, found := secret.Data[core.TLSCertKey]; !found {
err = fmt.Errorf("secret %s/%s is missing tls.crt", crd.Namespace, crd.SecretName())
return
} else {
pemCrt = data
}
if data, found := secret.Data[apiv1.TLSPrivateKeyKey]; !found {
if data, found := secret.Data[core.TLSPrivateKeyKey]; !found {
err = fmt.Errorf("secret %s/%s is missing tls.key", crd.Namespace, crd.SecretName())
return
} else {
Expand All @@ -99,8 +99,8 @@ func (s *CertStore) Get(crd *api.Certificate) (pemCrt, pemKey []byte, err error)
func (s *CertStore) Save(crd *api.Certificate, cert acme.CertificateResource) error {
if crd.Spec.Storage.Vault != nil {
data := map[string]interface{}{
apiv1.TLSCertKey: string(cert.Certificate),
apiv1.TLSPrivateKeyKey: string(cert.PrivateKey),
core.TLSCertKey: string(cert.Certificate),
core.TLSPrivateKeyKey: string(cert.PrivateKey),
}
_, err := s.VaultClient.Logical().Write(path.Join(crd.Spec.Storage.Vault.Prefix, crd.Namespace, crd.SecretName()), data)
if err != nil {
Expand All @@ -109,13 +109,13 @@ func (s *CertStore) Save(crd *api.Certificate, cert acme.CertificateResource) er
} else {
_, err := v1u.CreateOrPatchSecret(s.KubeClient,
metav1.ObjectMeta{Namespace: crd.Namespace, Name: crd.SecretName()},
func(in *apiv1.Secret) *apiv1.Secret {
in.Type = apiv1.SecretTypeTLS
func(in *core.Secret) *core.Secret {
in.Type = core.SecretTypeTLS
if in.Data == nil {
in.Data = make(map[string][]byte)
}
in.Data[apiv1.TLSCertKey] = cert.Certificate
in.Data[apiv1.TLSPrivateKeyKey] = cert.PrivateKey
in.Data[core.TLSCertKey] = cert.Certificate
in.Data[core.TLSPrivateKeyKey] = cert.PrivateKey
return in
})
if err != nil {
Expand Down

0 comments on commit 976badf

Please sign in to comment.