Skip to content
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
73 changes: 72 additions & 1 deletion openapi/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.0
info:
title: HyperFleet API
version: 1.0.9
version: 1.0.10
contact:
name: HyperFleet Team
license:
Expand Down Expand Up @@ -500,6 +500,7 @@ paths:
- name: nodepool_id
in: path
required: true
description: Nodepool ID
schema:
type: string
responses:
Expand All @@ -521,6 +522,45 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
security:
- BearerAuth: []
put:
operationId: putNodePoolStatuses
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summary: Adapter creates or updates resource nodepool status
Comment on lines +527 to +529
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will do. I'll add this update when I remove the post in the following PR. Since it will requiring making another change in the api-spec repo first

parameters:
- name: cluster_id
in: path
required: true
description: Cluster ID
schema:
type: string
- name: nodepool_id
in: path
required: true
description: Nodepool ID
schema:
type: string
responses:
'201':
description: The request has succeeded and a new resource has been created as a result.
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatus'
'400':
description: The server could not understand the request due to invalid syntax.
'404':
description: The server cannot find the requested resource.
'409':
description: The request conflicts with the current state of the server.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
Comment on lines +527 to +561
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add BearerAuth to the new nodepool status PUT operation.

plugins/clusters/plugin.go, Lines 89-90, protects all /clusters routes with auth middleware, but this new operation is published without security. That makes the OpenAPI contract and generated docs/client surface claim the endpoint is unauthenticated when it is not.

Suggested spec fix
     put:
       operationId: putNodePoolStatuses
       summary: Adapter creates or updates resource nodepool status
       parameters:
         - name: cluster_id
           in: path
           required: true
           description: Cluster ID
           schema:
             type: string
         - name: nodepool_id
           in: path
           required: true
           schema:
             type: string
       responses:
         '201':
           description: The request has succeeded and a new resource has been created as a result.
           content:
             application/json:
               schema:
                 $ref: '#/components/schemas/AdapterStatus'
         '400':
           description: The server could not understand the request due to invalid syntax.
         '404':
           description: The server cannot find the requested resource.
         '409':
           description: The request conflicts with the current state of the server.
       requestBody:
         required: true
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/AdapterStatusCreateRequest'
+      security:
+        - BearerAuth: []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
put:
operationId: putNodePoolStatuses
summary: Adapter creates or updates resource nodepool status
parameters:
- name: cluster_id
in: path
required: true
description: Cluster ID
schema:
type: string
- name: nodepool_id
in: path
required: true
schema:
type: string
responses:
'201':
description: The request has succeeded and a new resource has been created as a result.
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatus'
'400':
description: The server could not understand the request due to invalid syntax.
'404':
description: The server cannot find the requested resource.
'409':
description: The request conflicts with the current state of the server.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
put:
operationId: putNodePoolStatuses
summary: Adapter creates or updates resource nodepool status
parameters:
- name: cluster_id
in: path
required: true
description: Cluster ID
schema:
type: string
- name: nodepool_id
in: path
required: true
schema:
type: string
responses:
'201':
description: The request has succeeded and a new resource has been created as a result.
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatus'
'400':
description: The server could not understand the request due to invalid syntax.
'404':
description: The server cannot find the requested resource.
'409':
description: The request conflicts with the current state of the server.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
security:
- BearerAuth: []
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi/openapi.yaml` around lines 518 - 551, The new PUT operation
(operationId putNodePoolStatuses) is missing the OpenAPI security declaration;
add a security block referencing the existing BearerAuth scheme (e.g., security:
- BearerAuth: []) to the operation so the generated docs/clients show it
requires authentication and aligns with the middleware protecting the /clusters
routes.

Comment on lines +543 to +561
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Document the 204 No Content success case for these PUT upserts.

These endpoints already return 204 for valid no-op/discarded updates; test/integration/adapter_status_test.go, Lines 495-501 and 566-572, asserts that behavior. Leaving 204 out here makes a normal successful outcome undocumented in the generated client and API docs.

Also applies to: 637-656

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi/openapi.yaml` around lines 533 - 551, The OpenAPI spec omits the
documented 204 No Content success response for the PUT upsert endpoints; update
the responses block for the PUT endpoints that currently reference
AdapterStatus/AdapterStatusCreateRequest to include a '204' response entry
(description: successful no-op/discarded update, content: none) so the generated
client/docs reflect the actual behavior (e.g., where AdapterStatus and
AdapterStatusCreateRequest are used); apply the same change to the other
occurrence noted (around the second block at lines 637-656).

security:
- BearerAuth: []
Comment on lines +527 to +563
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Plan cross-repo migration steps before POST removal.

Given linked architecture and adapter docs/fixtures still describe POST status reporting, keep tracking a coordinated deprecation plan (docs, dry-run fixtures, and adapter guidance) before phase 2 removes POST.

Also applies to: 638-668

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openapi/openapi.yaml` around lines 527 - 563, The OpenAPI change
replaces/removes POST-based status reporting so prepare and document cross-repo
migration steps before removing POST: update API consumers and adapter
docs/fixtures to use the put operation (operationId putNodePoolStatuses) and the
AdapterStatusCreateRequest schema, publish a deprecation schedule and
compatibility notes, add dry-run fixtures and adapter guidance for transitioning
from POST to PUT, and coordinate changes across repos that reference
AdapterStatus/AdapterStatusCreateRequest to avoid breaking clients (also apply
same plan to the related block at lines 638-668).

get:
operationId: getNodePoolsStatuses
summary: List all adapter statuses for nodepools
Expand Down Expand Up @@ -595,6 +635,37 @@ paths:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
security:
- BearerAuth: []
put:
operationId: putClusterStatuses
summary: Adapter creates or updates resource cluster status
parameters:
Comment on lines +638 to +641
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new PUT operations only have a summary and no description. Since PUT
will eventually replace POST, it should carry the same (or better) documentation.

- name: cluster_id
in: path
required: true
description: Cluster ID
schema:
type: string
responses:
'201':
description: The request has succeeded and a new resource has been created as a result.
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatus'
'400':
description: The server could not understand the request due to invalid syntax.
'404':
description: The server cannot find the requested resource.
'409':
description: The request conflicts with the current state of the server.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AdapterStatusCreateRequest'
security:
- BearerAuth: []
get:
operationId: getClusterStatuses
summary: List all adapter statuses for cluster
Expand Down
2 changes: 2 additions & 0 deletions plugins/clusters/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func init() {
clusterStatusHandler := handlers.NewClusterStatusHandler(adapterStatus.Service(envServices), Service(envServices))
clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.List).Methods(http.MethodGet)
clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.Create).Methods(http.MethodPost)
clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.Create).Methods(http.MethodPut)

// Nested resource: cluster nodepools
clusterNodePoolsHandler := handlers.NewClusterNodePoolsHandler(
Expand All @@ -83,6 +84,7 @@ func init() {
nodepoolStatusHandler := handlers.NewNodePoolStatusHandler(adapterStatus.Service(envServices), nodePools.Service(envServices))
clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.List).Methods(http.MethodGet)
clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.Create).Methods(http.MethodPost)
clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.Create).Methods(http.MethodPut)

clustersRouter.Use(authMiddleware.AuthenticateAccountJWT)
})
Expand Down
Loading