Skip to content
Open
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
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ AfterAll
SME
uptodate
enbale
lifecyle
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ $(MOCKGEN): ${TOOLS_DIR}/go.mod
$(VERIFY_API_DEPS): $(TOOLS_DIR)/go.mod $(VERIFY_API_DEPS_SRC) # Build verify-api-deps tool
cd $(TOOLS_DIR); $(GO) build -o $(BIN_DIR)/verify-api-deps ./verify-api-deps

$(CRD_SCHEMA_CHECK): $(TOOLS_DIR)/go.mod # Build crd-schema-check tool
$(CRD_SCHEMA_CHECK): $(TOOLS_DIR)/go.mod $(wildcard $(TOOLS_DIR)/crd-schema-check/*.go) # Build crd-schema-check tool
cd $(TOOLS_DIR); $(GO) build -o $(BIN_DIR)/crd-schema-check ./crd-schema-check

.PHONY: generate
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/openshift/hypershift/api
go 1.26.0

require (
github.com/openshift/api v0.0.0-20260922100147-3a6e03c5a473
github.com/openshift/api v0.0.0-20261028095540-9af1f7b4730c
k8s.io/api v0.37.1
k8s.io/apimachinery v0.37.1
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3
Expand Down
8 changes: 4 additions & 4 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ github.com/go-openapi/swag/conv v0.27.1 h1:8wi9ZG+olmY1wXphl93EWniPtbSPkXM/feH7F
github.com/go-openapi/swag/conv v0.27.1/go.mod h1:QbqMivkpKhC3g1B1GGGOJ6ANewI3S62dbzYu3Duowqs=
github.com/go-openapi/swag/fileutils v0.27.1 h1:QQqBSoi5mW4XpU85nS0mLcA+zAE6vLzrb0QkmLKf9oM=
github.com/go-openapi/swag/fileutils v0.27.1/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8=
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
github.com/go-openapi/swag/jsonutils v0.27.1 h1:SVgK3i4USzCU5mibOOS/l4ea2h9UQXy7J7RNLTjuXjU=
github.com/go-openapi/swag/jsonutils v0.27.1/go.mod h1:tdlEpZqdcQ17uj6J4YdK9vd8It5qWMwjWXOs0tjpRlk=
github.com/go-openapi/swag/loading v0.27.1 h1:/DxUgDXKbBX4bcn7r9uEXfJyzN5XpiJmZplzQTjrRCY=
Expand Down Expand Up @@ -56,6 +54,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/moby/spdystream v0.5.1 h1:9sNYeYZUcci9R6/w7KDaFWEWeV4LStVG78Mpyq/Zm/Y=
github.com/moby/spdystream v0.5.1/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand All @@ -68,8 +68,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/openshift/api v0.0.0-20260922100147-3a6e03c5a473 h1:/sDj4rzzTkN8i3Vug/+PxIjp1duKft9GdnhK5hb/yRk=
github.com/openshift/api v0.0.0-20260922100147-3a6e03c5a473/go.mod h1:k6qH5QOVa5GDln2VVm8Jz4NV3Z7R2SATHFLwGS6Wh3M=
github.com/openshift/api v0.0.0-20261028095540-9af1f7b4730c h1:htIaa9XrrcLWrDZIhIbSHA3GBjRbirC+0BVwHRhPrFI=
github.com/openshift/api v0.0.0-20261028095540-9af1f7b4730c/go.mod h1:2oI3aXQFDjjl7l4xA9ZPSkB+l+lyfWLg7P2sWg9yEvM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
74 changes: 74 additions & 0 deletions api/hypershift/v1beta1/kms_serialization_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package v1beta1

import (
"encoding/json"
"testing"

configv1 "github.com/openshift/api/config/v1"
)

func TestClusterConfigurationKMSPluginConfigRoundTrip(t *testing.T) {
tests := []struct {
name string
kind string
}{
{
name: "When HostedCluster has a KMS pluginConfig reference, it should preserve it through typed JSON round trips",
kind: "HostedCluster",
},
{
name: "When HostedControlPlane has a KMS pluginConfig reference, it should preserve it through typed JSON round trips",
kind: "HostedControlPlane",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
input := []byte(`{"spec":{"configuration":{"apiServer":{"encryption":{"type":"KMS","kms":{"pluginConfig":{"apiVersion":"config.openshift.io/v1","resource":"vaultkmsconfigs","name":"cluster"}}}}}}}`)
var original, roundTrip any
var configuration **ClusterConfiguration
if test.kind == "HostedCluster" {
original = &HostedCluster{}
cluster := &HostedCluster{}
roundTrip = cluster
configuration = &cluster.Spec.Configuration
} else {
original = &HostedControlPlane{}
controlPlane := &HostedControlPlane{}
roundTrip = controlPlane
configuration = &controlPlane.Spec.Configuration
}
if err := json.Unmarshal(input, original); err != nil {
t.Fatalf("decode typed resource: %v", err)
}
encoded, err := json.Marshal(original)
if err != nil {
t.Fatalf("encode typed resource: %v", err)
}
if err := json.Unmarshal(encoded, roundTrip); err != nil {
t.Fatalf("decode round trip: %v", err)
}
if *configuration == nil || (*configuration).APIServer == nil {
t.Fatal("round trip lost API server configuration")
}
encryption := (*configuration).APIServer.Encryption
if encryption.Type != configv1.EncryptionType("KMS") {
t.Fatalf("unexpected encryption type: %q", encryption.Type)
}
expected := configv1.KMSPluginConfigReference{
APIVersion: "config.openshift.io/v1",
Resource: "vaultkmsconfigs",
Name: "cluster",
}
if encryption.KMS.PluginConfig != expected {
t.Fatalf("unexpected pluginConfig: got %#v, want %#v", encryption.KMS.PluginConfig, expected)
}
kmsJSON, err := json.Marshal(encryption.KMS)
if err != nil {
t.Fatalf("encode KMS configuration: %v", err)
}
if string(kmsJSON) != `{"pluginConfig":{"apiVersion":"config.openshift.io/v1","resource":"vaultkmsconfigs","name":"cluster"}}` {
t.Fatalf("unexpected KMS wire format: %s", kmsJSON)
}
})
}
}
Loading