-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add Hilt S3 commands #44
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
2 commits
Select commit
Hold shift + click to select a range
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
Large diffs are not rendered by default.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| //go:build !codegen | ||
|
|
||
| package bucket | ||
|
|
||
| import ( | ||
| "github.com/fil-forge/libforge/commands/s3/request" | ||
| "github.com/fil-forge/ucantone/binding" | ||
| "github.com/fil-forge/ucantone/ucan/command" | ||
| ) | ||
|
|
||
| // Create is the `/s3/bucket/create` command. Ingot invokes it on Hilt to | ||
| // create a bucket and provision it with Sprue. It returns the same structure | ||
| // as `/s3/request/authorize` ([request.AuthorizeOK]): the new bucket DID and | ||
| // any delegations that now have access to it. | ||
| var Create = binding.Bind[*CreateArguments, *request.AuthorizeOK](command.MustParse("/s3/bucket/create")) |
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,17 @@ | ||
| //go:build !codegen | ||
|
|
||
| package bucket | ||
|
|
||
| import ( | ||
| "github.com/fil-forge/libforge/commands" | ||
| "github.com/fil-forge/ucantone/binding" | ||
| "github.com/fil-forge/ucantone/ucan/command" | ||
| ) | ||
|
|
||
| // DeleteOK is the (empty) result of a successful `/s3/bucket/delete`. | ||
| type DeleteOK = commands.Unit | ||
|
|
||
| // Delete is the `/s3/bucket/delete` command. Ingot invokes it on Hilt to | ||
| // delete an empty bucket, removing it from Hilt's stores and revoking any | ||
| // delegations that grant access to it. | ||
| var Delete = binding.Bind[*DeleteArguments, *DeleteOK](command.MustParse("/s3/bucket/delete")) |
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,48 @@ | ||
| //go:generate go run -tags codegen . | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
|
|
||
| jsg "github.com/alanshaw/dag-json-gen" | ||
| "github.com/fil-forge/libforge/commands/s3/bucket" | ||
| cbg "github.com/whyrusleeping/cbor-gen" | ||
| ) | ||
|
|
||
| const buildTag = "//go:build !codegen\n\n" | ||
|
|
||
| func tag(path string) { | ||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| if err := os.WriteFile(path, append([]byte(buildTag), data...), 0644); err != nil { | ||
| panic(err) | ||
| } | ||
| } | ||
|
|
||
| func main() { | ||
| models := []any{ | ||
| bucket.CreateArguments{}, | ||
| bucket.DeleteArguments{}, | ||
| bucket.ListArguments{}, | ||
| bucket.InfoArguments{}, | ||
| bucket.InfoOK{}, | ||
| bucket.ListOK{}, | ||
| bucket.Bucket{}, | ||
| bucket.Owner{}, | ||
| } | ||
| const ( | ||
| cborFile = "../cbor_gen.go" | ||
| jsonFile = "../json_gen.go" | ||
| ) | ||
| if err := cbg.WriteMapEncodersToFile(cborFile, "bucket", models...); err != nil { | ||
| panic(err) | ||
| } | ||
| if err := jsg.WriteMapEncodersToFile(jsonFile, "bucket", models...); err != nil { | ||
| panic(err) | ||
| } | ||
| tag(cborFile) | ||
| tag(jsonFile) | ||
| } | ||
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 @@ | ||
| //go:build !codegen | ||
|
|
||
| package bucket | ||
|
|
||
| import ( | ||
| "github.com/fil-forge/ucantone/binding" | ||
| "github.com/fil-forge/ucantone/ucan/command" | ||
| ) | ||
|
|
||
| // Info is the `/s3/bucket/info` command. Ingot invokes it on Hilt to look up a | ||
| // bucket by global name, returning the bucket DID and the delegation chain | ||
| // from the bucket to the given access key. | ||
| var Info = binding.Bind[*InfoArguments, *InfoOK](command.MustParse("/s3/bucket/info")) |
Oops, something went wrong.
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.