diff --git a/go.mod b/go.mod index 6432a60a..914fba66 100755 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 github.com/oapi-codegen/runtime v1.4.2 github.com/onsi/gomega v1.42.0 - github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.21 + github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.23 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/client_model v0.3.0 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index 5a81f206..60109ac4 100755 --- a/go.sum +++ b/go.sum @@ -274,6 +274,8 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJw github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.21 h1:+Vlr1GOldX+pWJdVVlHxiCuVRQjTlr1Q3ez+ON+To/Q= github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.21/go.mod h1:KITzIAd8HcMpH5lXdHFjgk45dvL6XLpP3wwz8iK+KCI= +github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.23 h1:HyOWpJfEonjpLFnMmmhiqaAD3EJSVIvAuaA7y5fZ4kE= +github.com/openshift-hyperfleet/hyperfleet-api-spec v1.0.23/go.mod h1:KITzIAd8HcMpH5lXdHFjgk45dvL6XLpP3wwz8iK+KCI= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= diff --git a/pkg/api/presenters/cluster.go b/pkg/api/presenters/cluster.go index 6821b680..32d91f95 100644 --- a/pkg/api/presenters/cluster.go +++ b/pkg/api/presenters/cluster.go @@ -7,7 +7,6 @@ import ( openapi_types "github.com/oapi-codegen/runtime/types" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api/openapi" - "github.com/openshift-hyperfleet/hyperfleet-api/pkg/util" ) const clusterKind = "Cluster" @@ -30,10 +29,9 @@ func ConvertCluster(req *openapi.ClusterCreateRequest) (*api.Cluster, error) { return nil, fmt.Errorf("failed to marshal cluster labels: %w", err) } - // Get Kind value, use default if not provided - kind := clusterKind - if req.Kind != nil { - kind = *req.Kind + kind := req.Kind + if kind == "" { + kind = clusterKind } return &api.Cluster{ @@ -114,7 +112,7 @@ func PresentCluster(cluster *api.Cluster) (openapi.Cluster, error) { Generation: cluster.Generation, Href: &href, Id: &cluster.ID, - Kind: util.PtrString(cluster.Kind), + Kind: cluster.Kind, Labels: &labels, Name: cluster.Name, Spec: spec, diff --git a/pkg/api/presenters/cluster_test.go b/pkg/api/presenters/cluster_test.go index 519bfe0c..7c2f2cdb 100644 --- a/pkg/api/presenters/cluster_test.go +++ b/pkg/api/presenters/cluster_test.go @@ -9,7 +9,6 @@ import ( . "github.com/onsi/gomega" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api/openapi" - "github.com/openshift-hyperfleet/hyperfleet-api/pkg/util" ) const ( @@ -23,7 +22,7 @@ func createTestClusterRequest() *openapi.ClusterCreateRequest { return &openapi.ClusterCreateRequest{ Labels: &labels, - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "test-cluster", Spec: map[string]interface{}{ "region": "us-central1", @@ -76,7 +75,7 @@ func TestConvertCluster_WithLabels(t *testing.T) { req := &openapi.ClusterCreateRequest{ Labels: &labels, - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "labeled-cluster", Spec: map[string]interface{}{"test": "spec"}, } @@ -97,7 +96,7 @@ func TestConvertCluster_WithoutLabels(t *testing.T) { req := &openapi.ClusterCreateRequest{ Labels: nil, // Nil labels - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "unlabeled-cluster", Spec: map[string]interface{}{"test": "spec"}, } @@ -128,7 +127,7 @@ func TestConvertCluster_SpecMarshaling(t *testing.T) { } req := &openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "complex-cluster", Spec: complexSpec, } @@ -203,7 +202,7 @@ func TestPresentCluster_Complete(t *testing.T) { // Verify basic fields Expect(*result.Id).To(Equal("cluster-abc123")) - Expect(*result.Kind).To(Equal("Cluster")) + Expect(result.Kind).To(Equal("Cluster")) Expect(*result.Href).To(Equal("/api/hyperfleet/v1/clusters/cluster-abc123")) Expect(result.Name).To(Equal("presented-cluster")) Expect(result.Generation).To(Equal(int32(10))) diff --git a/pkg/api/presenters/node_pool.go b/pkg/api/presenters/node_pool.go index ad1586f7..cee41fcb 100644 --- a/pkg/api/presenters/node_pool.go +++ b/pkg/api/presenters/node_pool.go @@ -28,9 +28,9 @@ func ConvertNodePool(req *openapi.NodePoolCreateRequest, ownerID string) (*api.N return nil, fmt.Errorf("failed to marshal nodepool labels: %w", err) } - kind := nodePoolKind - if req.Kind != nil { - kind = *req.Kind + kind := req.Kind + if kind == "" { + kind = nodePoolKind } return &api.NodePool{ @@ -96,7 +96,6 @@ func PresentNodePool(nodePool *api.NodePool) (openapi.NodePool, error) { } } - kind := nodePool.Kind result := openapi.NodePool{ CreatedBy: toEmail(nodePool.CreatedBy), CreatedTime: nodePool.CreatedTime, @@ -105,12 +104,12 @@ func PresentNodePool(nodePool *api.NodePool) (openapi.NodePool, error) { Generation: nodePool.Generation, Href: &href, Id: &nodePool.ID, - Kind: &kind, + Kind: nodePool.Kind, Labels: &labels, Name: nodePool.Name, OwnerReferences: openapi.ObjectReference{ Id: &nodePool.OwnerID, - Kind: &nodePool.OwnerKind, + Kind: nodePool.OwnerKind, Href: &ownerHref, }, Spec: spec, diff --git a/pkg/api/presenters/node_pool_test.go b/pkg/api/presenters/node_pool_test.go index 9c4c531d..b8cc3d07 100644 --- a/pkg/api/presenters/node_pool_test.go +++ b/pkg/api/presenters/node_pool_test.go @@ -14,10 +14,8 @@ import ( // Helper function to create test NodePoolCreateRequest func createTestNodePoolRequest() *openapi.NodePoolCreateRequest { labels := map[string]string{"env": "test"} - kind := "NodePool" - return &openapi.NodePoolCreateRequest{ - Kind: &kind, + Kind: "NodePool", Name: "test-nodepool", Spec: map[string]interface{}{ "replicas": 3, @@ -64,9 +62,8 @@ func TestConvertNodePool_Complete(t *testing.T) { func TestConvertNodePool_WithKind(t *testing.T) { RegisterTestingT(t) - customKind := "CustomNodePool" req := &openapi.NodePoolCreateRequest{ - Kind: &customKind, + Kind: "CustomNodePool", Name: "custom-nodepool", Spec: map[string]interface{}{"test": "spec"}, Labels: nil, @@ -83,7 +80,7 @@ func TestConvertNodePool_WithoutKind(t *testing.T) { RegisterTestingT(t) req := &openapi.NodePoolCreateRequest{ - Kind: nil, // Nil Kind + Kind: "", // empty Kind falls back to default in ConvertNodePool Name: "default-kind-nodepool", Spec: map[string]interface{}{"test": "spec"}, Labels: nil, @@ -192,7 +189,7 @@ func TestPresentNodePool_Complete(t *testing.T) { // Verify basic fields Expect(*result.Id).To(Equal("nodepool-xyz")) - Expect(*result.Kind).To(Equal("NodePool")) + Expect(result.Kind).To(Equal("NodePool")) Expect(*result.Href).To(Equal("/api/hyperfleet/v1/clusters/cluster-abc/nodepools/nodepool-xyz")) Expect(result.Name).To(Equal("presented-nodepool")) Expect(result.CreatedBy).To(Equal(openapi_types.Email("user123@example.com"))) @@ -206,7 +203,7 @@ func TestPresentNodePool_Complete(t *testing.T) { // Verify OwnerReferences Expect(*result.OwnerReferences.Id).To(Equal("cluster-abc")) - Expect(*result.OwnerReferences.Kind).To(Equal("Cluster")) + Expect(result.OwnerReferences.Kind).To(Equal("Cluster")) Expect(*result.OwnerReferences.Href).To(Equal("/api/hyperfleet/v1/clusters/cluster-abc")) // Verify Status @@ -281,8 +278,8 @@ func TestPresentNodePool_OwnerReferences(t *testing.T) { Expect(result.OwnerReferences.Id).ToNot(BeNil()) Expect(*result.OwnerReferences.Id).To(Equal("cluster-ref-123")) - Expect(result.OwnerReferences.Kind).ToNot(BeNil()) - Expect(*result.OwnerReferences.Kind).To(Equal("Cluster")) + Expect(result.OwnerReferences.Kind).ToNot(BeEmpty()) + Expect(result.OwnerReferences.Kind).To(Equal("Cluster")) Expect(result.OwnerReferences.Href).ToNot(BeNil()) } @@ -375,7 +372,7 @@ func TestConvertAndPresentNodePool_RoundTrip(t *testing.T) { // Verify data integrity Expect(*result.Id).To(Equal("nodepool-roundtrip-123")) - Expect(*result.Kind).To(Equal(*originalReq.Kind)) + Expect(result.Kind).To(Equal(originalReq.Kind)) Expect(result.Name).To(Equal(originalReq.Name)) // Verify Spec preserved @@ -387,7 +384,7 @@ func TestConvertAndPresentNodePool_RoundTrip(t *testing.T) { // Verify OwnerReferences set Expect(*result.OwnerReferences.Id).To(Equal(ownerID)) - Expect(*result.OwnerReferences.Kind).To(Equal("Cluster")) + Expect(result.OwnerReferences.Kind).To(Equal("Cluster")) // Status initialization is handled by the service layer on create, not presenters. Expect(len(result.Status.Conditions)).To(Equal(0)) diff --git a/pkg/api/presenters/presenter_test.go b/pkg/api/presenters/presenter_test.go index 56a8b65c..10bb3ad8 100644 --- a/pkg/api/presenters/presenter_test.go +++ b/pkg/api/presenters/presenter_test.go @@ -65,7 +65,7 @@ func createTestClusterList() openapi.ClusterList { Items: []openapi.Cluster{ { Id: &id1, - Kind: &kind, + Kind: kind, Name: "test-cluster", Generation: 1, Labels: &labels1, @@ -76,7 +76,7 @@ func createTestClusterList() openapi.ClusterList { }, { Id: &id2, - Kind: &kind, + Kind: kind, Name: "development-cluster", Generation: 2, Labels: &labels2, @@ -486,7 +486,7 @@ func createTestCluster() openapi.Cluster { return openapi.Cluster{ Id: &id, - Kind: &kind, + Kind: kind, Name: "test-cluster", Generation: 1, Labels: &labels, @@ -733,11 +733,11 @@ func createTestNodePool() openapi.NodePool { return openapi.NodePool{ Id: &id, - Kind: &kind, + Kind: kind, Name: "worker-pool", OwnerReferences: openapi.ObjectReference{ Id: &ownerID, - Kind: &ownerKind, + Kind: ownerKind, Href: &ownerHref, }, Spec: openapi.NodePoolSpec{"replicas": 3, "instanceType": "m5.large"}, diff --git a/pkg/api/presenters/resource.go b/pkg/api/presenters/resource.go index 152e79ee..888e9593 100644 --- a/pkg/api/presenters/resource.go +++ b/pkg/api/presenters/resource.go @@ -86,7 +86,7 @@ func PresentResource(r *api.Resource) openapi.Resource { }{ ObjectReference: openapi.ObjectReference{ Id: r.OwnerID, - Kind: r.OwnerKind, + Kind: util.NilToEmptyString(r.OwnerKind), Href: r.OwnerHref, }, } diff --git a/pkg/api/presenters/resource_test.go b/pkg/api/presenters/resource_test.go index 0341ccc7..eb2e2ae9 100644 --- a/pkg/api/presenters/resource_test.go +++ b/pkg/api/presenters/resource_test.go @@ -135,7 +135,7 @@ func TestPresentResource_WithOwner(t *testing.T) { resp := PresentResource(resource) Expect(resp.OwnerReferences).NotTo(BeNil()) Expect(*resp.OwnerReferences.Id).To(Equal("parent-id")) - Expect(*resp.OwnerReferences.Kind).To(Equal("Channel")) + Expect(resp.OwnerReferences.Kind).To(Equal("Channel")) } func TestPresentResource_EmptySpec(t *testing.T) { diff --git a/pkg/handlers/cluster_nodepools_test.go b/pkg/handlers/cluster_nodepools_test.go index 1617b922..70862faf 100644 --- a/pkg/handlers/cluster_nodepools_test.go +++ b/pkg/handlers/cluster_nodepools_test.go @@ -179,8 +179,8 @@ func TestClusterNodePoolsHandler_Get(t *testing.T) { err := json.Unmarshal(rr.Body.Bytes(), &response) Expect(err).NotTo(HaveOccurred()) Expect(*response.Id).To(Equal(nodePoolID)) - Expect(response.Kind).NotTo(BeNil()) - Expect(*response.Kind).To(Equal("NodePool")) + Expect(response.Kind).NotTo(BeEmpty()) + Expect(response.Kind).To(Equal("NodePool")) } }) } @@ -425,8 +425,8 @@ func TestClusterNodePoolsHandler_Create(t *testing.T) { err := json.Unmarshal(rr.Body.Bytes(), &response) Expect(err).NotTo(HaveOccurred()) Expect(*response.Id).To(Equal(nodePoolID)) - Expect(response.Kind).NotTo(BeNil()) - Expect(*response.Kind).To(Equal("NodePool")) + Expect(response.Kind).NotTo(BeEmpty()) + Expect(response.Kind).To(Equal("NodePool")) } if tt.expectedStatusCode == http.StatusConflict { @@ -581,8 +581,8 @@ func TestClusterNodePoolsHandler_Patch(t *testing.T) { err := json.Unmarshal(rr.Body.Bytes(), &response) Expect(err).NotTo(HaveOccurred()) Expect(*response.Id).To(Equal(nodePoolID)) - Expect(response.Kind).NotTo(BeNil()) - Expect(*response.Kind).To(Equal("NodePool")) + Expect(response.Kind).NotTo(BeEmpty()) + Expect(response.Kind).To(Equal("NodePool")) } if tt.expectedStatusCode == http.StatusConflict { diff --git a/pkg/handlers/validation_test.go b/pkg/handlers/validation_test.go index 8dfba05c..d7b44fe1 100644 --- a/pkg/handlers/validation_test.go +++ b/pkg/handlers/validation_test.go @@ -8,7 +8,6 @@ import ( . "github.com/onsi/gomega" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api/openapi" - "github.com/openshift-hyperfleet/hyperfleet-api/pkg/util" ) func TestValidateName_Valid(t *testing.T) { @@ -102,7 +101,7 @@ func TestValidateKind_Valid(t *testing.T) { RegisterTestingT(t) req := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", } validator := validateKind(&req, "Kind", "kind", "Cluster") err := validator() @@ -121,7 +120,7 @@ func TestValidateKind_Invalid(t *testing.T) { for _, kind := range invalidKinds { req := openapi.ClusterCreateRequest{ - Kind: &kind, + Kind: kind, } validator := validateKind(&req, "Kind", "kind", "Cluster") err := validator() @@ -133,7 +132,7 @@ func TestValidateKind_Empty(t *testing.T) { RegisterTestingT(t) req := openapi.ClusterCreateRequest{ - Kind: util.PtrString(""), + Kind: "", } validator := validateKind(&req, "Kind", "kind", "Cluster") err := validator() @@ -145,7 +144,7 @@ func TestValidateKind_WrongKind(t *testing.T) { RegisterTestingT(t) req := openapi.ClusterCreateRequest{ - Kind: util.PtrString("WrongKind"), + Kind: "WrongKind", } validator := validateKind(&req, "Kind", "kind", "Cluster") err := validator() diff --git a/test/integration/caller_identity_test.go b/test/integration/caller_identity_test.go index c1905e40..b1c93cb3 100644 --- a/test/integration/caller_identity_test.go +++ b/test/integration/caller_identity_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/gomega" "github.com/openshift-hyperfleet/hyperfleet-api/pkg/api/openapi" - "github.com/openshift-hyperfleet/hyperfleet-api/pkg/util" + "github.com/openshift-hyperfleet/hyperfleet-api/test" ) @@ -56,7 +56,7 @@ func TestCallerIdentityCreate(t *testing.T) { } clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName(tc.namePrefix, h.NewID()), Spec: map[string]interface{}{"test": "spec"}, } @@ -116,7 +116,7 @@ func TestCallerIdentityPatch(t *testing.T) { createCtx := h.NewAuthenticatedContext(createAccount) clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName(tc.namePrefix, h.NewID()), Spec: map[string]interface{}{"test": "spec"}, } @@ -168,7 +168,7 @@ func TestCallerIdentityMultiplePatches(t *testing.T) { ctxA := h.NewAuthenticatedContext(accountA) clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName("ci-multi", h.NewID()), Spec: map[string]interface{}{"version": "1"}, } @@ -234,7 +234,7 @@ func TestCallerIdentityDelete(t *testing.T) { ctx := h.NewAuthenticatedContext(account) clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName("ci-del", h.NewID()), Spec: map[string]interface{}{"test": "spec"}, } @@ -271,7 +271,7 @@ func TestCallerIdentityEmptyHeaderFallback(t *testing.T) { // Create with an empty identity header — should fall back to JWT claim. clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName("ci-empty", h.NewID()), Spec: map[string]interface{}{"test": "spec"}, } @@ -296,7 +296,7 @@ func TestCallerIdentityOversizedHeader(t *testing.T) { // Create with an oversized identity header (>256 chars) — should be rejected. clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: shortClusterName("ci-long", h.NewID()), Spec: map[string]interface{}{"test": "spec"}, } diff --git a/test/integration/clusters_test.go b/test/integration/clusters_test.go index 03f35139..d1e3aa73 100644 --- a/test/integration/clusters_test.go +++ b/test/integration/clusters_test.go @@ -48,7 +48,7 @@ func TestClusterGet(t *testing.T) { clusterOutput := resp.JSON200 Expect(clusterOutput).NotTo(BeNil()) Expect(*clusterOutput.Id).To(Equal(clusterModel.ID), "found object does not match test object") - Expect(*clusterOutput.Kind).To(Equal("Cluster")) + Expect(clusterOutput.Kind).To(Equal("Cluster")) Expect(*clusterOutput.Href).To(Equal(fmt.Sprintf("/api/hyperfleet/v1/clusters/%s", clusterModel.ID))) Expect(clusterOutput.CreatedTime).To(BeTemporally("~", clusterModel.CreatedTime)) Expect(clusterOutput.UpdatedTime).To(BeTemporally("~", clusterModel.UpdatedTime)) @@ -62,7 +62,7 @@ func TestClusterPost(t *testing.T) { // POST responses per openapi spec: 201, 409, 500 clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "test-name", Spec: map[string]interface{}{"test": "spec"}, } @@ -80,7 +80,7 @@ func TestClusterPost(t *testing.T) { Expect(len(*clusterOutput.Id)).To(Equal(36), "Expected UUID v7 length of 36 characters") Expect(*clusterOutput.Id). To(MatchRegexp(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`), "Expected UUID v7 format") - Expect(*clusterOutput.Kind).To(Equal("Cluster")) + Expect(clusterOutput.Kind).To(Equal("Cluster")) Expect(*clusterOutput.Href).To(Equal(fmt.Sprintf("/api/hyperfleet/v1/clusters/%s", *clusterOutput.Id))) // 400 bad request. posting junk json is one way to trigger 400. @@ -123,7 +123,7 @@ func TestClusterPatch(t *testing.T) { updated := patchResp.JSON200 Expect(updated).NotTo(BeNil()) Expect(*updated.Id).To(Equal(clusterModel.ID)) - Expect(*updated.Kind).To(Equal("Cluster")) + Expect(updated.Kind).To(Equal("Cluster")) Expect(updated.Generation).To(Equal(initialGeneration+1), "Generation should increment when spec changes") Expect(updated.Spec).To(HaveKeyWithValue("region", "us-east-1")) Expect(updated.Spec).To(HaveKeyWithValue("provider", "aws")) @@ -304,7 +304,7 @@ func TestClusterDuplicateNames(t *testing.T) { // Create first cluster with a specific name clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "duplicate-name-test", Spec: map[string]interface{}{"test": "spec1"}, } @@ -347,7 +347,7 @@ func TestClusterBoundaryValues(t *testing.T) { } longNameInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: longName, Spec: map[string]interface{}{"test": "spec"}, } @@ -362,7 +362,7 @@ func TestClusterBoundaryValues(t *testing.T) { // Test exceeding max length (54 characters should fail) tooLongName := longName + "a" tooLongInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: tooLongName, Spec: map[string]interface{}{"test": "spec"}, } @@ -375,7 +375,7 @@ func TestClusterBoundaryValues(t *testing.T) { // Test 2: Empty name emptyNameInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "", Spec: map[string]interface{}{"test": "spec"}, } @@ -394,7 +394,7 @@ func TestClusterBoundaryValues(t *testing.T) { } largeSpecInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "large-spec-test", Spec: largeSpec, } @@ -414,7 +414,7 @@ func TestClusterBoundaryValues(t *testing.T) { // Test 4: Unicode in name (should be rejected - pattern only allows [a-z0-9-]) unicodeNameInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "テスト-δοκιμή-🚀", Spec: map[string]interface{}{"test": "spec"}, } @@ -444,7 +444,7 @@ func TestClusterSchemaValidation(t *testing.T) { } validInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "schema-valid-test", Spec: validSpec, } @@ -488,7 +488,7 @@ func TestClusterSchemaValidation(t *testing.T) { // Test 3: Empty spec (should be valid as spec is optional in base schema) emptySpecInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "schema-empty-spec", Spec: map[string]interface{}{}, } @@ -534,7 +534,7 @@ func TestClusterSchemaValidationWithProviderSchema(t *testing.T) { } invalidInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: "provider-schema-invalid", Spec: invalidSpec, } @@ -642,7 +642,7 @@ func TestClusterList_DefaultSorting(t *testing.T) { var createdClusters []openapi.Cluster for i := 1; i <= 3; i++ { clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: fmt.Sprintf("sort-test-%d-%s", i, strings.ToLower(h.NewID())), Spec: map[string]interface{}{"test": fmt.Sprintf("value-%d", i)}, } @@ -705,7 +705,7 @@ func TestClusterList_OrderByName(t *testing.T) { for _, name := range names { clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: name, Spec: map[string]interface{}{"test": "value"}, } @@ -763,7 +763,7 @@ func TestClusterList_OrderByNameDesc(t *testing.T) { for _, name := range names { clusterInput := openapi.ClusterCreateRequest{ - Kind: util.PtrString("Cluster"), + Kind: "Cluster", Name: name, Spec: map[string]interface{}{"test": "value"}, } @@ -975,7 +975,7 @@ func TestClusterSoftDelete(t *testing.T) { cluster, err := h.Factories.NewClusters(h.NewID()) Expect(err).NotTo(HaveOccurred()) npInput := openapi.NodePoolCreateRequest{ - Kind: util.PtrString("NodePool"), + Kind: "NodePool", Name: "cascade-np", Spec: map[string]interface{}{"test": "spec"}, } @@ -1088,7 +1088,7 @@ func TestClusterSoftDelete(t *testing.T) { cluster, err := h.Factories.NewClusters(h.NewID()) Expect(err).NotTo(HaveOccurred()) npInput := openapi.NodePoolCreateRequest{ - Kind: util.PtrString("NodePool"), + Kind: "NodePool", Name: "idem-np", Spec: map[string]interface{}{"test": "spec"}, } @@ -1589,7 +1589,7 @@ func TestClusterCreateNodePoolUnderSoftDeleted(t *testing.T) { // Attempt to create a nodepool under the soft-deleted cluster npInput := openapi.NodePoolCreateRequest{ - Kind: util.PtrString("NodePool"), + Kind: "NodePool", Name: "should-fail-np", Spec: map[string]interface{}{"test": "spec"}, } diff --git a/test/integration/node_pools_test.go b/test/integration/node_pools_test.go index e3ee1e21..313f75c8 100644 --- a/test/integration/node_pools_test.go +++ b/test/integration/node_pools_test.go @@ -49,7 +49,7 @@ const ( // Expect(resp.StatusCode).To(Equal(http.StatusOK)) // // Expect(*nodePoolOutput.Id).To(Equal(nodePoolModel.ID), "found object does not match test object") -// Expect(*nodePoolOutput.Kind).To(Equal("NodePool")) +// Expect(nodePoolOutput.Kind).To(Equal("NodePool")) // Expect(*nodePoolOutput.Href).To(Equal(fmt.Sprintf("/api/hyperfleet/v1/node_pools/%s", nodePoolModel.ID))) // Expect(nodePoolOutput.CreatedAt).To(BeTemporally("~", nodePoolModel.CreatedAt)) // Expect(nodePoolOutput.UpdatedAt).To(BeTemporally("~", nodePoolModel.UpdatedAt)) @@ -68,7 +68,7 @@ func TestNodePoolPost(t *testing.T) { // POST responses per openapi spec: 201, 409, 500 kind := kindNodePool nodePoolInput := openapi.NodePoolCreateRequest{ - Kind: &kind, + Kind: kind, Name: "test-name", Spec: map[string]interface{}{"test": "spec"}, } @@ -86,7 +86,7 @@ func TestNodePoolPost(t *testing.T) { Expect(len(*nodePoolOutput.Id)).To(Equal(36), "Expected UUID v7 length of 36 characters") Expect(*nodePoolOutput.Id). To(MatchRegexp(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`), "Expected UUID v7 format") - Expect(*nodePoolOutput.Kind).To(Equal("NodePool")) + Expect(nodePoolOutput.Kind).To(Equal("NodePool")) Expect(*nodePoolOutput.Href). To(Equal(fmt.Sprintf("/api/hyperfleet/v1/clusters/%s/nodepools/%s", cluster.ID, *nodePoolOutput.Id))) @@ -117,7 +117,7 @@ func TestNodePoolPatch(t *testing.T) { createResp, err := client.CreateNodePoolWithResponse( ctx, cluster.ID, openapi.CreateNodePoolJSONRequestBody{ - Kind: &kind, + Kind: kind, Name: "patch-test-np", Spec: openapi.NodePoolSpec{"instance_type": "m5.large"}, }, @@ -163,7 +163,7 @@ func TestNodePoolPatch(t *testing.T) { updated := patchResp.JSON200 Expect(updated).NotTo(BeNil()) Expect(*updated.Id).To(Equal(nodePoolID)) - Expect(*updated.Kind).To(Equal("NodePool")) + Expect(updated.Kind).To(Equal("NodePool")) Expect(updated.Generation).To(Equal(initialGeneration+1), "Generation should increment when spec changes") Expect(updated.Spec).To(HaveKeyWithValue("instance_type", "m5.xlarge")) Expect(updated.Spec).To(HaveKeyWithValue("replicas", float64(3))) @@ -318,7 +318,7 @@ func TestGetNodePoolByClusterIdAndNodePoolId(t *testing.T) { // Create a nodepool for this cluster using the API kind := kindNodePool nodePoolInput := openapi.NodePoolCreateRequest{ - Kind: &kind, + Kind: kind, Name: "test-np-get", Spec: map[string]interface{}{"instance_type": "m5.large", "replicas": 2}, } @@ -339,7 +339,7 @@ func TestGetNodePoolByClusterIdAndNodePoolId(t *testing.T) { retrieved := getResp.JSON200 Expect(retrieved).NotTo(BeNil()) Expect(*retrieved.Id).To(Equal(nodePoolID), "Retrieved nodepool ID should match") - Expect(*retrieved.Kind).To(Equal("NodePool")) + Expect(retrieved.Kind).To(Equal("NodePool")) Expect(retrieved.Name).To(Equal("test-np-get")) // Test 2: Try to get with non-existent nodepool ID (404) @@ -460,7 +460,7 @@ func TestNodePoolDuplicateNames(t *testing.T) { // Create first nodepool with a specific name kind := kindNodePool nodePoolInput := openapi.NodePoolCreateRequest{ - Kind: &kind, + Kind: kind, Name: "test-duplicate", Spec: map[string]interface{}{"test": "spec"}, } @@ -572,7 +572,7 @@ func TestNodePoolPost_MissingSpec(t *testing.T) { func newNodePoolInput(name string) openapi.NodePoolCreateRequest { return openapi.NodePoolCreateRequest{ - Kind: util.PtrString("NodePool"), + Kind: "NodePool", Name: name, Spec: map[string]interface{}{"test": "spec"}, }