Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Jan 16, 2025
1 parent c1f7308 commit 4d4f041
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_bmcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: bmcs.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_bmcsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: bmcsecrets.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: endpoints.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: serverbootconfigurations.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_serverclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: serverclaims.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/metal.ironcore.dev_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.3
controller-gen.kubebuilder.io/version: v0.17.1
name: servers.metal.ironcore.dev
spec:
group: metal.ironcore.dev
Expand Down
11 changes: 5 additions & 6 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
Expand Down Expand Up @@ -567,11 +566,11 @@ func generateSSHKeyPairAndPassword() ([]byte, []byte, []byte, error) {
return nil, nil, nil, fmt.Errorf("failed to generate private key: %w", err)
}

privateKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)
privateKeyPem := pem.EncodeToMemory(&pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: privateKeyBytes,
})
privateKeyBlock, err := ssh.MarshalPrivateKey(privateKey, "")
if err != nil {
return nil, nil, nil, err
}
privateKeyPem := pem.EncodeToMemory(privateKeyBlock)

sshPubKey, err := ssh.NewPublicKey(&privateKey.PublicKey)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions internal/controller/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
)

var _ = FDescribe("Server Controller", func() {
var _ = Describe("Server Controller", func() {
ns := SetupTest()

It("Should initialize a Server from Endpoint", func(ctx SpecContext) {
Expand Down Expand Up @@ -306,6 +306,10 @@ var _ = FDescribe("Server Controller", func() {
HaveField("Data", HaveKeyWithValue(SSHKeyPairSecretPrivateKeyName, Not(BeEmpty()))),
HaveField("Data", HaveKeyWithValue(SShKeyPairSecretPasswordKeyName, Not(BeEmpty()))),
))
_, err := ssh.ParsePrivateKey(sshSecret.Data[SSHKeyPairSecretPrivateKeyName])
Expect(err).NotTo(HaveOccurred())
_, _, _, _, err = ssh.ParseAuthorizedKey(sshSecret.Data[SSHKeyPairSecretPublicKeyName])
Expect(err).NotTo(HaveOccurred())

By("Ensuring that the default ignition configuration has been created")
ignitionSecret := &v1.Secret{
Expand Down Expand Up @@ -339,7 +343,7 @@ var _ = FDescribe("Server Controller", func() {
ignitionData, err := ignition.GenerateDefaultIgnitionData(ignition.Config{
Image: "foo:latest",
Flags: "--registry-url=http://localhost:30000 --server-uuid=38947555-7742-3448-3784-823347823834",
SSHPublicKey: string(sshSecret.Data["public"]),
SSHPublicKey: string(sshSecret.Data[SSHKeyPairSecretPublicKeyName]),
PasswordHash: passwordHash,
})
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 4d4f041

Please sign in to comment.