-
Notifications
You must be signed in to change notification settings - Fork 607
feat: add generateUploadUrl to api #4601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8dd8b27
feat: add generateUploadUrl to api
ogzhanolguncu e3f01bb
chore: update openapi spec
ogzhanolguncu 286ef83
refactor: remove redundant checks
ogzhanolguncu 25c4037
refactor: add missing project_id check
ogzhanolguncu f950c51
refactor: Remove expiresIn from response
ogzhanolguncu 52e4b80
chore: cleanup
ogzhanolguncu 78e72dc
Merge branch 'main' into generate-upload-url-api
Flo4604 7f37539
fix: PR comments
ogzhanolguncu bd79991
Merge branch 'main' into generate-upload-url-api
ogzhanolguncu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| load("@rules_go//go:def.bzl", "go_library") | ||
|
|
||
| go_library( | ||
| name = "ctrlclient", | ||
| srcs = ["errors.go"], | ||
| importpath = "github.com/unkeyed/unkey/svc/api/internal/ctrlclient", | ||
| visibility = ["//svc/api:__subpackages__"], | ||
| deps = [ | ||
| "//pkg/codes", | ||
| "//pkg/fault", | ||
| "@com_connectrpc_connect//:connect", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package ctrlclient | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "connectrpc.com/connect" | ||
| "github.com/unkeyed/unkey/pkg/codes" | ||
| "github.com/unkeyed/unkey/pkg/fault" | ||
| ) | ||
|
|
||
| // HandleError converts Connect RPC errors from ctrl services to fault errors | ||
| // with appropriate error codes and user-facing messages. | ||
| // | ||
| // The context parameter should describe the operation being performed (e.g., "create deployment", | ||
| // "generate upload URL") and will be used to generate user-facing error messages. | ||
| func HandleError(err error, context string) error { | ||
| // Convert Connect errors to fault errors | ||
| var connectErr *connect.Error | ||
| if !errors.As(err, &connectErr) { | ||
| // Non-Connect errors | ||
| return fault.Wrap(err, | ||
| fault.Code(codes.App.Internal.ServiceUnavailable.URN()), | ||
| fault.Public(fmt.Sprintf("Failed to %s.", context)), | ||
| ) | ||
| } | ||
|
|
||
| //nolint:exhaustive // Default case handles all other Connect error codes | ||
| switch connectErr.Code() { | ||
| case connect.CodeNotFound: | ||
| return fault.Wrap(err, | ||
| fault.Code(codes.Data.Project.NotFound.URN()), | ||
| fault.Public("Project not found."), | ||
| ) | ||
| case connect.CodeInvalidArgument: | ||
| return fault.Wrap(err, | ||
| fault.Code(codes.App.Validation.InvalidInput.URN()), | ||
| fault.Public(fmt.Sprintf("Invalid request for %s.", context)), | ||
| ) | ||
| case connect.CodeUnauthenticated: | ||
| return fault.Wrap(err, | ||
| fault.Code(codes.App.Internal.ServiceUnavailable.URN()), | ||
| fault.Public("Failed to authenticate with service."), | ||
| ) | ||
| default: | ||
| // All other Connect errors (Internal, Unavailable, etc.) | ||
| return fault.Wrap(err, | ||
| fault.Code(codes.App.Internal.ServiceUnavailable.URN()), | ||
| fault.Public(fmt.Sprintf("Failed to %s.", context)), | ||
| ) | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
.../openapi/spec/paths/v2/deploy/generateUploadUrl/V2DeployGenerateUploadUrlRequestBody.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| type: object | ||
| required: | ||
| - projectId | ||
| properties: | ||
| projectId: | ||
| type: string | ||
| minLength: 1 | ||
| description: Unkey project ID for which to generate the upload URL | ||
| example: "proj_123abc" |
9 changes: 9 additions & 0 deletions
9
...openapi/spec/paths/v2/deploy/generateUploadUrl/V2DeployGenerateUploadUrlResponseBody.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| type: object | ||
| required: | ||
| - meta | ||
| - data | ||
| properties: | ||
| meta: | ||
| $ref: "../../../../common/Meta.yaml" | ||
| data: | ||
| $ref: "./V2DeployGenerateUploadUrlResponseData.yaml" |
13 changes: 13 additions & 0 deletions
13
...openapi/spec/paths/v2/deploy/generateUploadUrl/V2DeployGenerateUploadUrlResponseData.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| type: object | ||
| required: | ||
| - uploadUrl | ||
| - context | ||
| properties: | ||
| uploadUrl: | ||
| type: string | ||
| description: Presigned PUT URL for uploading the build context tar file | ||
| example: "https://s3.amazonaws.com/bucket/path?signature=..." | ||
| context: | ||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type: string | ||
| description: S3 path to use in the createDeployment request when building from source | ||
| example: "proj_123abc/ctx_456def.tar.gz" | ||
49 changes: 49 additions & 0 deletions
49
svc/api/openapi/spec/paths/v2/deploy/generateUploadUrl/index.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| post: | ||
| tags: | ||
| - deploy | ||
| summary: Generate upload URL | ||
| description: | | ||
| Generates a presigned S3 URL for uploading build context archives. | ||
|
|
||
| **Authentication**: Requires a valid root key with appropriate permissions. | ||
| operationId: deploy.generateUploadUrl | ||
| x-speakeasy-name-override: generateUploadUrl | ||
| security: | ||
| - rootKey: [] | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "./V2DeployGenerateUploadUrlRequestBody.yaml" | ||
| responses: | ||
| "200": | ||
| description: Upload URL generated successfully | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "./V2DeployGenerateUploadUrlResponseBody.yaml" | ||
| "400": | ||
| description: Bad request | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "../../../../error/BadRequestErrorResponse.yaml" | ||
| "401": | ||
| description: Unauthorized | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "../../../../error/UnauthorizedErrorResponse.yaml" | ||
| "404": | ||
| description: Not found | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "../../../../error/NotFoundErrorResponse.yaml" | ||
| "500": | ||
| description: Internal server error | ||
| content: | ||
| application/json: | ||
| schema: | ||
| "$ref": "../../../../error/InternalServerErrorResponse.yaml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.