b7ca2289e0
* improve setup wizard * added access grant file support * improved consistency across commands * a couple bug fixes * added access import and export Change-Id: I30ad9d4771f15430904a503a4d465bc40be471b5
41 lines
865 B
Go
41 lines
865 B
Go
// Copyright (C) 2021 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/zeebo/clingy"
|
|
"github.com/zeebo/errs"
|
|
|
|
"storj.io/storj/cmd/uplinkng/ulext"
|
|
)
|
|
|
|
type cmdAccessExport struct {
|
|
ex ulext.External
|
|
|
|
name string
|
|
filename string
|
|
}
|
|
|
|
func newCmdAccessExport(ex ulext.External) *cmdAccessExport {
|
|
return &cmdAccessExport{ex: ex}
|
|
}
|
|
|
|
func (c *cmdAccessExport) Setup(params clingy.Parameters) {
|
|
c.name = params.Arg("name", "Name of the access to export").(string)
|
|
c.filename = params.Arg("filename", "Name of the file to save to").(string)
|
|
}
|
|
|
|
func (c *cmdAccessExport) Execute(ctx clingy.Context) error {
|
|
if c.filename == "" {
|
|
return errs.New("Must specify a filename to write to.")
|
|
}
|
|
|
|
access, err := c.ex.OpenAccess(c.name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.ex.ExportAccess(ctx, access, c.filename)
|
|
}
|