Skip to content

Commit

Permalink
fix api definition (optional mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkb0318 committed Jun 16, 2024
1 parent 074738f commit 25ae093
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 23 deletions.
7 changes: 5 additions & 2 deletions api/v1alpha1/irsasetup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ type IRSASetupSpec struct {
// +required
Cleanup bool `json:"cleanup"`

// Mode specifies the mode of operation. Can be either "selfhosted" or "eks".
Mode string `json:"mode"`
// Mode (Optional, Future Feature) Defines how the controller will operate once this feature is enabled.
// Currently unused. Planned values:
// - "selfhosted": For self-managed Kubernetes clusters.
// - "eks": For Amazon EKS environments.
Mode string `json:"mode,omitempty"`

// Discovery configures the IdP Discovery process, essential for setting up IRSA by locating
// the OIDC provider information.
Expand Down
8 changes: 5 additions & 3 deletions charts/irsa-manager/crds/irsasetup-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ spec:
type: object
type: object
mode:
description: Mode specifies the mode of operation. Can be either "selfhosted"
or "eks".
description: |-
Mode (Optional, Future Feature) Defines how the controller will operate once this feature is enabled.
Currently unused. Planned values:
- "selfhosted": For self-managed Kubernetes clusters.
- "eks": For Amazon EKS environments.
type: string
required:
- cleanup
- discovery
- mode
type: object
status:
description: IRSASetupStatus defines the observed state of IRSASetup
Expand Down
1 change: 1 addition & 0 deletions charts/irsa-manager/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ spec:
secretKeyRef:
key: aws-role-arn
name: aws-secret
optional: true
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ spec:
type: object
type: object
mode:
description: Mode specifies the mode of operation. Can be either "selfhosted"
or "eks".
description: |-
Mode (Optional, Future Feature) Defines how the controller will operate once this feature is enabled.
Currently unused. Planned values:
- "selfhosted": For self-managed Kubernetes clusters.
- "eks": For Amazon EKS environments.
type: string
required:
- cleanup
- discovery
- mode
type: object
status:
description: IRSASetupStatus defines the observed state of IRSASetup
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
secretKeyRef:
name: aws-secret
key: aws-role-arn
# optional: true
optional: true
name: manager
securityContext:
allowPrivilegeEscalation: false
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `cleanup` _boolean_ | Cleanup, when enabled, allows the IRSASetup to perform garbage collection<br />of resources that are no longer needed or managed. | | |
| `mode` _string_ | Mode specifies the mode of operation. Can be either "selfhosted" or "eks". | | |
| `mode` _string_ | Mode (Optional, Future Feature) Defines how the controller will operate once this feature is enabled.<br />Currently unused. Planned values:<br /> - "selfhosted": For self-managed Kubernetes clusters.<br /> - "eks": For Amazon EKS environments. | | |
| `discovery` _[Discovery](#discovery)_ | Discovery configures the IdP Discovery process, essential for setting up IRSA by locating<br />the OIDC provider information. | | |


Expand Down
1 change: 0 additions & 1 deletion examples/selfhosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
namespace: irsa-manager-system
spec:
cleanup: false
mode: selfhosted
discovery:
s3:
region: ap-northeast-1
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/irsasetup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("IRSASetup Controller", func() {
},
Spec: irsav1alpha1.IRSASetupSpec{
Cleanup: true,
Mode: "selfhosted",
// Mode: "selfhosted",
Discovery: irsav1alpha1.Discovery{
S3: irsav1alpha1.S3Discovery{
Region: "ap-northeast-1",
Expand Down Expand Up @@ -134,7 +134,7 @@ var _ = Describe("IRSASetup Controller", func() {
},
Spec: irsav1alpha1.IRSASetupSpec{
Cleanup: true,
Mode: "selfhoted",
// Mode: "selfhoted",
Discovery: irsav1alpha1.Discovery{
S3: irsav1alpha1.S3Discovery{
Region: "ap-northeast-1",
Expand Down Expand Up @@ -219,7 +219,7 @@ var _ = Describe("IRSASetup Controller", func() {
},
Spec: irsav1alpha1.IRSASetupSpec{
Cleanup: false,
Mode: "selfhoted",
// Mode: "selfhoted",
Discovery: irsav1alpha1.Discovery{
S3: irsav1alpha1.S3Discovery{
Region: "ap-northeast-1",
Expand Down
22 changes: 13 additions & 9 deletions internal/selfhosted/webhook/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ func TestCreateTlsCredentials(t *testing.T) {
}

certBlock, _ := pem.Decode(creds.certificate)
var cert *x509.Certificate
if certBlock == nil {
t.Fatal("Failed to decode PEM block containing the certificate")
} else {
cert, err = x509.ParseCertificate(certBlock.Bytes)
if err != nil {
t.Fatalf("Failed to parse certificate: %v", err)
}
}
cert, err := x509.ParseCertificate(certBlock.Bytes)
if err != nil {
t.Fatalf("Failed to parse certificate: %v", err)
}

var key *rsa.PrivateKey
keyBlock, _ := pem.Decode(creds.privateKey)
if keyBlock == nil {
t.Fatal("Failed to decode PEM block containing the private key")
}
key, err := x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
if err != nil {
t.Fatalf("Failed to parse private key: %v", err)
} else {
key, err = x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
if err != nil {
t.Fatalf("Failed to parse private key: %v", err)
}

}

// Verify public keys are equivalent
Expand Down

0 comments on commit 25ae093

Please sign in to comment.