cmd/uplink: Add revoke command
Change-Id: I8ae74da5c9171429b970d76598793a3227ed4d11
This commit is contained in:
parent
4ce1c099b1
commit
cad21f11e5
51
cmd/uplink/cmd/revoke.go
Normal file
51
cmd/uplink/cmd/revoke.go
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"storj.io/uplink"
|
||||
)
|
||||
|
||||
func init() {
|
||||
addCmd(&cobra.Command{
|
||||
Use: "revoke access_here",
|
||||
Short: "Revoke an access",
|
||||
RunE: revokeAccess,
|
||||
Args: cobra.ExactArgs(1),
|
||||
}, RootCmd)
|
||||
}
|
||||
|
||||
func revokeAccess(cmd *cobra.Command, args []string) error {
|
||||
ctx, _ := withTelemetry(cmd)
|
||||
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("no access specified for revocation")
|
||||
}
|
||||
|
||||
accessRaw := args[0]
|
||||
access, err := uplink.ParseAccess(accessRaw)
|
||||
if err != nil {
|
||||
return errors.New("invalid access provided")
|
||||
}
|
||||
|
||||
project, err := cfg.getProject(ctx, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closeProject(project)
|
||||
|
||||
if err = project.RevokeAccess(ctx, access); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("=========== SUCCESSFULLY REVOKED =========================================================")
|
||||
fmt.Println("NOTE: It may take the satellite several minutes to process the revocation request,")
|
||||
fmt.Println(" depending on its caching policies.")
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user