Skip to content

Commit 49edc0d

Browse files
Merge pull request #175 from dciabrin/memcached-tls
Add TLS support for memcached
2 parents 99face7 + be5ad8d commit 49edc0d

24 files changed

+463
-77
lines changed

apis/bases/memcached.openstack.org_memcacheds.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ spec:
5353
description: Size of the memcached cluster
5454
format: int32
5555
type: integer
56+
tls:
57+
description: TLS settings for memcached service
58+
properties:
59+
caBundleSecretName:
60+
description: CaBundleSecretName - holding the CA certs in a pre-created
61+
bundle file
62+
type: string
63+
secretName:
64+
description: SecretName - holding the cert, key for the service
65+
type: string
66+
type: object
5667
required:
5768
- containerImage
5869
type: object
@@ -102,6 +113,11 @@ spec:
102113
- type
103114
type: object
104115
type: array
116+
hash:
117+
additionalProperties:
118+
type: string
119+
description: Map of hashes to track input changes
120+
type: object
105121
readyCount:
106122
description: ReadyCount of Memcached instances
107123
format: int32

apis/memcached/v1beta1/memcached_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
21+
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
2122
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
)
@@ -39,10 +40,18 @@ type MemcachedSpec struct {
3940
// +kubebuilder:default=1
4041
// Size of the memcached cluster
4142
Replicas *int32 `json:"replicas"`
43+
44+
// +kubebuilder:validation:Optional
45+
// +operator-sdk:csv:customresourcedefinitions:type=spec
46+
// TLS settings for memcached service
47+
TLS tls.SimpleService `json:"tls,omitempty"`
4248
}
4349

4450
// MemcachedStatus defines the observed state of Memcached
4551
type MemcachedStatus struct {
52+
// Map of hashes to track input changes
53+
Hash map[string]string `json:"hash,omitempty"`
54+
4655
// ReadyCount of Memcached instances
4756
ReadyCount int32 `json:"readyCount,omitempty"`
4857

apis/memcached/v1beta1/memcached_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (r *Memcached) ValidateCreate() (admission.Warnings, error) {
8585
}
8686

8787
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
88-
func (r *Memcached) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
88+
func (r *Memcached) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
8989
memcachedlog.Info("validate update", "name", r.Name)
9090

9191
// TODO(user): fill in your validation logic upon object update.

apis/memcached/v1beta1/zz_generated.deepcopy.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/network/v1beta1/common_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
)
3939

4040
func getNetConfig(
41-
c client.Client,
41+
_ client.Client,
4242
obj metav1.Object,
4343
) (*NetConfig, error) {
4444
// check if NetConfig is available
@@ -62,7 +62,7 @@ func getNetConfig(
6262
}
6363

6464
func getIPSets(
65-
c client.Client,
65+
_ client.Client,
6666
obj metav1.Object,
6767
) (*IPSetList, error) {
6868
// check if IPSet is available

apis/network/v1beta1/dnsmasq_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (r *DNSMasq) ValidateCreate() (admission.Warnings, error) {
7979
}
8080

8181
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
82-
func (r *DNSMasq) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
82+
func (r *DNSMasq) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
8383
dnsmasqlog.Info("validate update", "name", r.Name)
8484

8585
// TODO(user): fill in your validation logic upon object update.

apis/network/v1beta1/ipset_webhook_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
"testing"
2121

22-
. "github.com/onsi/gomega"
22+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -448,7 +448,7 @@ func TestIPSetUpdateValidation(t *testing.T) {
448448
g := NewWithT(t)
449449
basePath := field.NewPath("spec")
450450

451-
new := &IPSet{
451+
newCfg := &IPSet{
452452
ObjectMeta: metav1.ObjectMeta{
453453
Namespace: "foo",
454454
},
@@ -459,12 +459,12 @@ func TestIPSetUpdateValidation(t *testing.T) {
459459

460460
allErrs := valiateIPSetNetwork(tt.newSpec.Networks, basePath, &tt.n)
461461
if len(allErrs) > 0 {
462-
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), new.Name, allErrs)
462+
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), newCfg.Name, allErrs)
463463
}
464464

465465
allErrs = valiateIPSetChanged(tt.newSpec.Networks, tt.oldSpec.Networks, basePath)
466466
if len(allErrs) > 0 {
467-
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), new.Name, allErrs)
467+
err = apierrors.NewInvalid(GroupVersion.WithKind("IPSet").GroupKind(), newCfg.Name, allErrs)
468468
}
469469

470470
if tt.expectErr {

apis/network/v1beta1/netconfig_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ func valiateUniqElement(
265265
}
266266

267267
// CIDRs must be uniq, while its possible to have same CIDR on different VLANs, we exlude this config
268+
//
269+
//lint:ignore U1000 valiateUniqCIDR
268270
func valiateUniqCIDR(
269271
netCIDRs map[int]map[string]field.Path,
270272
vlan *int,

apis/network/v1beta1/netconfig_webhook_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package v1beta1
1919
import (
2020
"testing"
2121

22-
. "github.com/onsi/gomega"
22+
. "github.com/onsi/gomega" //revive:disable:dot-imports
2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -1554,10 +1554,9 @@ func TestNetConfigValidation(t *testing.T) {
15541554
basePath := field.NewPath("spec")
15551555

15561556
if tt.expectErr {
1557-
g.Expect(len(valiateNetworks(tt.c.Spec.Networks, basePath))).Should(BeNumerically(">", 0))
1557+
g.Expect(valiateNetworks(tt.c.Spec.Networks, basePath)).ShouldNot(BeEmpty())
15581558
} else {
1559-
g.Expect(len(valiateNetworks(tt.c.Spec.Networks, basePath))).Should(BeNumerically("==", 0))
1560-
1559+
g.Expect(valiateNetworks(tt.c.Spec.Networks, basePath)).Should(BeEmpty())
15611560
}
15621561
})
15631562
}
@@ -1781,7 +1780,7 @@ func TestNetConfigUpdateValidation(t *testing.T) {
17811780
g := NewWithT(t)
17821781
basePath := field.NewPath("spec")
17831782

1784-
new := &NetConfig{
1783+
newCfg := &NetConfig{
17851784
ObjectMeta: metav1.ObjectMeta{
17861785
Namespace: "foo",
17871786
},
@@ -1792,12 +1791,12 @@ func TestNetConfigUpdateValidation(t *testing.T) {
17921791

17931792
allErrs := valiateNetworks(tt.newSpec.Networks, basePath)
17941793
if len(allErrs) > 0 {
1795-
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), new.Name, allErrs)
1794+
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), newCfg.Name, allErrs)
17961795
}
17971796

17981797
allErrs = valiateNetworksChanged(tt.newSpec.Networks, tt.oldSpec.Networks, basePath)
17991798
if len(allErrs) > 0 {
1800-
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), new.Name, allErrs)
1799+
err = apierrors.NewInvalid(GroupVersion.WithKind("NetConfig").GroupKind(), newCfg.Name, allErrs)
18011800
}
18021801

18031802
if tt.expectErr {

apis/network/v1beta1/reservation_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (r *Reservation) ValidateCreate() (admission.Warnings, error) {
6161
}
6262

6363
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
64-
func (r *Reservation) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
64+
func (r *Reservation) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6565
reservationlog.Info("validate update", "name", r.Name)
6666

6767
// TODO(user): fill in your validation logic upon object update.

0 commit comments

Comments
 (0)