2021-06-22 23:41:22 +01:00
|
|
|
// 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) {
|
2021-06-25 17:51:05 +01:00
|
|
|
c.access = params.Flag("access", "Access name or value to restrict", "").(string)
|
2021-06-22 23:41:22 +01:00
|
|
|
|
|
|
|
params.Break()
|
2021-06-25 17:51:05 +01:00
|
|
|
c.am.Setup(params, c.ex, amSaveDefaultFalse)
|
2021-06-22 23:41:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|