Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LocalObejctReference to v1alpha1 api #244

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1alpha1

import (
v1 "k8s.io/api/core/v1"
k8sresource "k8s.io/apimachinery/pkg/api/resource"
)

Expand All @@ -22,14 +21,24 @@ type MonitoringConfig struct {
Enabled bool `json:"enabled"`
}

// LocalObjectReference contains enough information to let you locate the
// referenced object inside the same namespace.
// +structType=atomic
type LocalObjectReference struct {
// Name of the referent.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
// +required
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
}

// SecretKeySelector selects a key of a Secret.
// +structType=atomic
type SecretKeySelector struct {
// The name of the secret in the pod's namespace to select from.
v1.LocalObjectReference `json:",inline" protobuf:"bytes,1,opt,name=localObjectReference"`
LocalObjectReference `json:",inline" protobuf:"bytes,1,opt,name=localObjectReference"`
// The key of the secret to select from. Must be a valid secret key.
//+required
//+kubebuilder:validation:Pattern:="[-._a-zA-Z0-9]+"
//+kubebuilder:validation:Pattern:="^[-._a-zA-Z0-9]+$"
Key string `json:"key" protobuf:"bytes,2,opt,name=key"`
}

Expand Down
11 changes: 5 additions & 6 deletions api/v1alpha1/ctlog_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1alpha1

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

Expand Down Expand Up @@ -39,11 +38,11 @@ type CTlogSpec struct {

// CTlogStatus defines the observed state of CTlog component
type CTlogStatus struct {
ServerConfigRef *v1.LocalObjectReference `json:"serverConfigRef,omitempty"`
PrivateKeyRef *SecretKeySelector `json:"privateKeyRef,omitempty"`
PrivateKeyPasswordRef *SecretKeySelector `json:"privateKeyPasswordRef,omitempty"`
PublicKeyRef *SecretKeySelector `json:"publicKeyRef,omitempty"`
RootCertificates []SecretKeySelector `json:"rootCertificates,omitempty"`
ServerConfigRef *LocalObjectReference `json:"serverConfigRef,omitempty"`
PrivateKeyRef *SecretKeySelector `json:"privateKeyRef,omitempty"`
PrivateKeyPasswordRef *SecretKeySelector `json:"privateKeyPasswordRef,omitempty"`
PublicKeyRef *SecretKeySelector `json:"publicKeyRef,omitempty"`
RootCertificates []SecretKeySelector `json:"rootCertificates,omitempty"`
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
Expand Down
13 changes: 6 additions & 7 deletions api/v1alpha1/ctlog_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
. "github.com/onsi/gomega"
"golang.org/x/net/context"
_ "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -48,7 +47,7 @@ var _ = Describe("CTlog", func() {
invalidObject := generateCTlogObject("public-key-invalid")
invalidObject.Spec.PublicKeyRef = &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{Name: "name"},
LocalObjectReference: LocalObjectReference{Name: "name"},
}

Expect(apierrors.IsInvalid(k8sClient.Create(context.Background(), invalidObject))).To(BeTrue())
Expand All @@ -60,7 +59,7 @@ var _ = Describe("CTlog", func() {
invalidObject := generateCTlogObject("private-key-password-invalid")
invalidObject.Spec.PublicKeyRef = &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{Name: "name"},
LocalObjectReference: LocalObjectReference{Name: "name"},
}

Expect(apierrors.IsInvalid(k8sClient.Create(context.Background(), invalidObject))).To(BeTrue())
Expand Down Expand Up @@ -108,26 +107,26 @@ var _ = Describe("CTlog", func() {
TreeID: &tree,
PublicKeyRef: &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "name",
},
},
PrivateKeyRef: &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "name",
},
},
PrivateKeyPasswordRef: &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "name",
},
},
RootCertificates: []SecretKeySelector{
{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "name",
},
},
Expand Down
7 changes: 3 additions & 4 deletions api/v1alpha1/fulcio_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1alpha1

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

Expand Down Expand Up @@ -84,9 +83,9 @@ type OIDCIssuer struct {

// FulcioStatus defines the observed state of Fulcio
type FulcioStatus struct {
ServerConfigRef *v1.LocalObjectReference `json:"serverConfigRef,omitempty"`
Certificate *FulcioCert `json:"certificate,omitempty"`
Url string `json:"url,omitempty"`
ServerConfigRef *LocalObjectReference `json:"serverConfigRef,omitempty"`
Certificate *FulcioCert `json:"certificate,omitempty"`
Url string `json:"url,omitempty"`
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
Expand Down
9 changes: 4 additions & 5 deletions api/v1alpha1/fulcio_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
. "github.com/onsi/gomega"
"golang.org/x/net/context"
_ "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -119,7 +118,7 @@ var _ = Describe("Fulcio", func() {
invalidObject := generateFulcioObject("private-key-invalid")
invalidObject.Spec.Certificate.CARef = &SecretKeySelector{
Key: "key",
LocalObjectReference: corev1.LocalObjectReference{Name: "name"},
LocalObjectReference: LocalObjectReference{Name: "name"},
}

Expect(apierrors.IsInvalid(k8sClient.Create(context.Background(), invalidObject))).To(BeTrue())
Expand Down Expand Up @@ -196,9 +195,9 @@ var _ = Describe("Fulcio", func() {
CommonName: "CommonName",
OrganizationName: "OrganizationName",
OrganizationEmail: "OrganizationEmail",
CARef: &SecretKeySelector{Key: "key", LocalObjectReference: corev1.LocalObjectReference{Name: "name"}},
PrivateKeyRef: &SecretKeySelector{Key: "key", LocalObjectReference: corev1.LocalObjectReference{Name: "name"}},
PrivateKeyPasswordRef: &SecretKeySelector{Key: "key", LocalObjectReference: corev1.LocalObjectReference{Name: "name"}},
CARef: &SecretKeySelector{Key: "key", LocalObjectReference: LocalObjectReference{Name: "name"}},
PrivateKeyRef: &SecretKeySelector{Key: "key", LocalObjectReference: LocalObjectReference{Name: "name"}},
PrivateKeyPasswordRef: &SecretKeySelector{Key: "key", LocalObjectReference: LocalObjectReference{Name: "name"}},
},
},
}
Expand Down
11 changes: 5 additions & 6 deletions api/v1alpha1/rekor_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1alpha1

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

Expand Down Expand Up @@ -63,11 +62,11 @@ type BackFillRedis struct {

// RekorStatus defines the observed state of Rekor
type RekorStatus struct {
ServerConfigRef *v1.LocalObjectReference `json:"serverConfigRef,omitempty"`
Signer RekorSigner `json:"signer,omitempty"`
PvcName string `json:"pvcName,omitempty"`
Url string `json:"url,omitempty"`
RekorSearchUIUrl string `json:"rekorSearchUIUrl,omitempty"`
ServerConfigRef *LocalObjectReference `json:"serverConfigRef,omitempty"`
Signer RekorSigner `json:"signer,omitempty"`
PvcName string `json:"pvcName,omitempty"`
Url string `json:"url,omitempty"`
RekorSearchUIUrl string `json:"rekorSearchUIUrl,omitempty"`
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
Expand Down
5 changes: 2 additions & 3 deletions api/v1alpha1/rekor_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/securesign/operator/controllers/common/utils"
"golang.org/x/net/context"
_ "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
k8sresource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -228,13 +227,13 @@ var _ = Describe("Rekor", func() {
Signer: RekorSigner{
KMS: "secret",
KeyRef: &SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "secret",
},
Key: "key",
},
PasswordRef: &SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "secret",
},
Key: "key",
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/trillian_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

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

Expand All @@ -41,7 +40,7 @@ type TrillianDB struct {
// mysql-password: The password to connect to the MySQL server
// mysql-database: The database to connect to
//+optional
DatabaseSecretRef *v1.LocalObjectReference `json:"databaseSecretRef,omitempty"`
DatabaseSecretRef *LocalObjectReference `json:"databaseSecretRef,omitempty"`
// PVC configuration
//+kubebuilder:default:={size: "5Gi", retain: true}
Pvc Pvc `json:"pvc,omitempty"`
Expand Down
9 changes: 4 additions & 5 deletions api/v1alpha1/trillian_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/securesign/operator/controllers/common/utils"
"golang.org/x/net/context"
_ "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
k8sresource "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -46,7 +45,7 @@ var _ = Describe("Trillian", func() {

It("can be created with database secret", func() {
created := generateTrillianObject("trillian-database-secret")
created.Spec.Db.DatabaseSecretRef = &corev1.LocalObjectReference{
created.Spec.Db.DatabaseSecretRef = &LocalObjectReference{
Name: "database-secret-name",
}
Expect(k8sClient.Create(context.Background(), created)).To(Succeed())
Expand Down Expand Up @@ -154,7 +153,7 @@ var _ = Describe("Trillian", func() {
StorageClass: "storage-class",
Size: &storage,
},
DatabaseSecretRef: &corev1.LocalObjectReference{
DatabaseSecretRef: &LocalObjectReference{
Name: "secret",
},
},
Expand All @@ -179,14 +178,14 @@ var _ = Describe("Trillian", func() {
},
Spec: TrillianSpec{
Db: TrillianDB{
DatabaseSecretRef: &corev1.LocalObjectReference{
DatabaseSecretRef: &LocalObjectReference{
Name: "secret",
},
},
},
}

expectedTrillianInstance.Spec.Db.DatabaseSecretRef = &corev1.LocalObjectReference{
expectedTrillianInstance.Spec.Db.DatabaseSecretRef = &LocalObjectReference{
Name: "secret",
}

Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/tuf_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
. "github.com/onsi/gomega"
"golang.org/x/net/context"
_ "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -141,7 +140,7 @@ var _ = Describe("TUF", func() {
{
Name: "rekor.pub",
SecretRef: &SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
LocalObjectReference: LocalObjectReference{
Name: "object",
},
Key: "key",
Expand Down
Loading
Loading