59b8422318
this makes the distinction between an "access name" and an "access value" and talks about which is expected for commands. most are "access name or value". Change-Id: I43c0043a17d37e89ab5f87388ae9e890a8b59958
38 lines
748 B
Go
38 lines
748 B
Go
// Copyright (C) 2021 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/zeebo/clingy"
|
|
|
|
"storj.io/storj/cmd/uplinkng/ulext"
|
|
)
|
|
|
|
type cmdAccessRestrict struct {
|
|
ex ulext.External
|
|
am accessMaker
|
|
|
|
access string
|
|
}
|
|
|
|
func newCmdAccessRestrict(ex ulext.External) *cmdAccessRestrict {
|
|
return &cmdAccessRestrict{ex: ex}
|
|
}
|
|
|
|
func (c *cmdAccessRestrict) Setup(params clingy.Parameters) {
|
|
c.access = params.Flag("access", "Access name or value to restrict", "").(string)
|
|
|
|
params.Break()
|
|
c.am.Setup(params, c.ex, amSaveDefaultFalse)
|
|
}
|
|
|
|
func (c *cmdAccessRestrict) Execute(ctx clingy.Context) error {
|
|
access, err := c.ex.OpenAccess(c.access)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.am.Execute(ctx, access)
|
|
}
|