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
1,129 changes: 1,129 additions & 0 deletions commands/s3/bucket/cbor_gen.go

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions commands/s3/bucket/create.go
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"))
17 changes: 17 additions & 0 deletions commands/s3/bucket/delete.go
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"))
48 changes: 48 additions & 0 deletions commands/s3/bucket/gen/main.go
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)
}
}
Comment thread
alanshaw marked this conversation as resolved.

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)
}
13 changes: 13 additions & 0 deletions commands/s3/bucket/info.go
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"))
Loading
Loading