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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/moby/buildkit v0.11.6
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230425114903-9de7ce5b674f
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230428130141-a5694ebc2375
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230425114903-9de7ce5b674f h1:h/skrTv7wKdxr88CjkD2cdVLaWqarBwXRQTE1XCraKg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230425114903-9de7ce5b674f/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230428130141-a5694ebc2375 h1:evSSWPPV1KO5/CmJ6BRdhHl0xxa9GwQWfQYTmsqSCfE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.16.0.20230428130141-a5694ebc2375/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down
123 changes: 59 additions & 64 deletions internal/namespaces/ipfs/v1alpha1/ipfs_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ func GetGeneratedCommands() *core.Commands {
ipfsRoot(),
ipfsIpfs(),
ipfsVolume(),
ipfsToken(),
ipfsVolumeCreate(),
ipfsVolumeGet(),
ipfsVolumeList(),
ipfsVolumeUpdate(),
ipfsVolumeDelete(),
ipfsIpfsAddURL(),
ipfsIpfsAddCid(),
ipfsIpfsAddFile(),
ipfsIpfsGetPinID(),
ipfsIpfsListPins(),
ipfsIpfsRmPinID(),
)
}
Expand All @@ -45,8 +44,8 @@ func ipfsRoot() *core.Command {

func ipfsIpfs() *core.Command {
return &core.Command{
Short: `add content in s3 bucket`,
Long: `add content in s3 bucket.`,
Short: `add content by cid or url and manage pins`,
Long: `add content by cid or url and manage pins.`,
Namespace: "ipfs",
Resource: "ipfs",
}
Expand All @@ -61,19 +60,10 @@ func ipfsVolume() *core.Command {
}
}

func ipfsToken() *core.Command {
return &core.Command{
Short: `manage token in ipfs cli`,
Long: `manage token in ipfs cli.`,
Namespace: "ipfs",
Resource: "token",
}
}

func ipfsVolumeCreate() *core.Command {
return &core.Command{
Short: `Create volume in S3 bucket`,
Long: `Create volume in S3 bucket.`,
Short: `Create volume`,
Long: `Create volume.`,
Namespace: "ipfs",
Resource: "volume",
Verb: "create",
Expand Down Expand Up @@ -212,8 +202,8 @@ func ipfsVolumeUpdate() *core.Command {

func ipfsVolumeDelete() *core.Command {
return &core.Command{
Short: `Delete volume in S3 bucket`,
Long: `Delete volume in S3 bucket.`,
Short: `Delete volume`,
Long: `Delete volume.`,
Namespace: "ipfs",
Resource: "volume",
Verb: "delete",
Expand Down Expand Up @@ -247,8 +237,8 @@ func ipfsVolumeDelete() *core.Command {

func ipfsIpfsAddURL() *core.Command {
return &core.Command{
Short: `Add content in s3 bucket`,
Long: `Add content in s3 bucket.`,
Short: `Add content in volume by url`,
Long: `Add content in volume by url.`,
Namespace: "ipfs",
Resource: "ipfs",
Verb: "add-url",
Expand Down Expand Up @@ -300,8 +290,8 @@ func ipfsIpfsAddURL() *core.Command {

func ipfsIpfsAddCid() *core.Command {
return &core.Command{
Short: `Add content in s3 bucket`,
Long: `Add content in s3 bucket.`,
Short: `Add content in volume by cid`,
Long: `Add content in volume by cid.`,
Namespace: "ipfs",
Resource: "ipfs",
Verb: "add-cid",
Expand Down Expand Up @@ -363,15 +353,15 @@ func ipfsIpfsAddCid() *core.Command {
}
}

func ipfsIpfsAddFile() *core.Command {
func ipfsIpfsGetPinID() *core.Command {
return &core.Command{
Short: `Add content in s3 bucket`,
Long: `Add content in s3 bucket.`,
Short: `Get pin id in volume`,
Long: `Get pin id in volume.`,
Namespace: "ipfs",
Resource: "ipfs",
Verb: "add-file",
Verb: "get-pin-id",
// Deprecated: false,
ArgsType: reflect.TypeOf(ipfs.CreatePinByRawRequest{}),
ArgsType: reflect.TypeOf(ipfs.GetPinRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "volume-id",
Expand All @@ -380,57 +370,33 @@ func ipfsIpfsAddFile() *core.Command {
Positional: false,
},
{
Name: "content",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "mime-type",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pin-options.required-zones.{index}",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pin-options.replication-count",
Required: false,
Name: "pin-id",
Required: true,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*ipfs.CreatePinByRawRequest)
request := args.(*ipfs.GetPinRequest)

client := core.ExtractClient(ctx)
api := ipfs.NewAPI(client)
return api.CreatePinByRaw(request)
return api.GetPin(request)

},
}
}

func ipfsIpfsGetPinID() *core.Command {
func ipfsIpfsListPins() *core.Command {
return &core.Command{
Short: `Get pin id create when content is add in s3 bucket`,
Long: `Get pin id create when content is add in s3 bucket.`,
Short: `List pins in specific volume`,
Long: `List pins in specific volume.`,
Namespace: "ipfs",
Resource: "ipfs",
Verb: "get-pin-id",
Verb: "list-pins",
// Deprecated: false,
ArgsType: reflect.TypeOf(ipfs.GetPinRequest{}),
ArgsType: reflect.TypeOf(ipfs.ListPinsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "volume-id",
Expand All @@ -439,19 +405,48 @@ func ipfsIpfsGetPinID() *core.Command {
Positional: false,
},
{
Name: "pin-id",
Required: true,
Name: "project-id",
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
{
Name: "order-by",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc"},
},
{
Name: "status",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_status", "queued", "pinning", "failed", "pinned"},
},
{
Name: "organization-id",
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw, scw.Region(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*ipfs.GetPinRequest)
request := args.(*ipfs.ListPinsRequest)

client := core.ExtractClient(ctx)
api := ipfs.NewAPI(client)
return api.GetPin(request)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Region == scw.Region(core.AllLocalities) {
opts = append(opts, scw.WithRegions(api.Regions()...))
request.Region = ""
}
resp, err := api.ListPins(request, opts...)
if err != nil {
return nil, err
}
return resp.Pins, nil

},
}
Expand Down