"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/secret/remove/remove.go" between
gh-cli-1.10.3.tar.gz and gh-cli-1.11.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

remove.go  (gh-cli-1.10.3):remove.go  (gh-cli-1.11.0)
skipping to change at line 23 skipping to change at line 23
) )
type RemoveOptions struct { type RemoveOptions struct {
HttpClient func() (*http.Client, error) HttpClient func() (*http.Client, error)
IO *iostreams.IOStreams IO *iostreams.IOStreams
Config func() (config.Config, error) Config func() (config.Config, error)
BaseRepo func() (ghrepo.Interface, error) BaseRepo func() (ghrepo.Interface, error)
SecretName string SecretName string
OrgName string OrgName string
EnvName string
} }
func NewCmdRemove(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co mmand { func NewCmdRemove(f *cmdutil.Factory, runF func(*RemoveOptions) error) *cobra.Co mmand {
opts := &RemoveOptions{ opts := &RemoveOptions{
IO: f.IOStreams, IO: f.IOStreams,
Config: f.Config, Config: f.Config,
HttpClient: f.HttpClient, HttpClient: f.HttpClient,
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "remove <secret-name>", Use: "remove <secret-name>",
Short: "Remove an organization or repository secret", Short: "Remove an organization, environment, or repository secret ",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
// support `-R, --repo` override // support `-R, --repo` override
opts.BaseRepo = f.BaseRepo opts.BaseRepo = f.BaseRepo
if err := cmdutil.MutuallyExclusive("specify only one of
`--org` or `--env`", opts.OrgName != "", opts.EnvName != ""); err != nil {
return err
}
opts.SecretName = args[0] opts.SecretName = args[0]
if runF != nil { if runF != nil {
return runF(opts) return runF(opts)
} }
return removeRun(opts) return removeRun(opts)
}, },
} }
cmd.Flags().StringVarP(&opts.OrgName, "org", "o", "", "List secrets for a cmd.Flags().StringVarP(&opts.OrgName, "org", "o", "", "Remove a secret fo
n organization") r an organization")
cmd.Flags().StringVarP(&opts.EnvName, "env", "e", "", "Remove a secret fo
r an environment")
return cmd return cmd
} }
func removeRun(opts *RemoveOptions) error { func removeRun(opts *RemoveOptions) error {
c, err := opts.HttpClient() c, err := opts.HttpClient()
if err != nil { if err != nil {
return fmt.Errorf("could not create http client: %w", err) return fmt.Errorf("could not create http client: %w", err)
} }
client := api.NewClientFromHTTP(c) client := api.NewClientFromHTTP(c)
orgName := opts.OrgName orgName := opts.OrgName
envName := opts.EnvName
var baseRepo ghrepo.Interface var baseRepo ghrepo.Interface
if orgName == "" { if orgName == "" {
baseRepo, err = opts.BaseRepo() baseRepo, err = opts.BaseRepo()
if err != nil { if err != nil {
return fmt.Errorf("could not determine base repo: %w", er r) return fmt.Errorf("could not determine base repo: %w", er r)
} }
} }
var path string var path string
if orgName == "" { if orgName != "" {
path = fmt.Sprintf("repos/%s/actions/secrets/%s", ghrepo.FullName
(baseRepo), opts.SecretName)
} else {
path = fmt.Sprintf("orgs/%s/actions/secrets/%s", orgName, opts.Se cretName) path = fmt.Sprintf("orgs/%s/actions/secrets/%s", orgName, opts.Se cretName)
} else if envName != "" {
path = fmt.Sprintf("repos/%s/environments/%s/secrets/%s", ghrepo.
FullName(baseRepo), envName, opts.SecretName)
} else {
path = fmt.Sprintf("repos/%s/actions/secrets/%s", ghrepo.FullName
(baseRepo), opts.SecretName)
} }
cfg, err := opts.Config() cfg, err := opts.Config()
if err != nil { if err != nil {
return err return err
} }
host, err := cfg.DefaultHost() host, err := cfg.DefaultHost()
if err != nil { if err != nil {
return err return err
skipping to change at line 99 skipping to change at line 108
if err != nil { if err != nil {
return fmt.Errorf("failed to delete secret %s: %w", opts.SecretNa me, err) return fmt.Errorf("failed to delete secret %s: %w", opts.SecretNa me, err)
} }
if opts.IO.IsStdoutTTY() { if opts.IO.IsStdoutTTY() {
target := orgName target := orgName
if orgName == "" { if orgName == "" {
target = ghrepo.FullName(baseRepo) target = ghrepo.FullName(baseRepo)
} }
cs := opts.IO.ColorScheme() cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.Out, "%s Removed secret %s from %s\n", cs.Suc if envName != "" {
cessIconWithColor(cs.Red), opts.SecretName, target) fmt.Fprintf(opts.IO.Out, "%s Removed secret %s from %s en
vironment on %s\n", cs.SuccessIconWithColor(cs.Red), opts.SecretName, envName, t
arget)
} else {
fmt.Fprintf(opts.IO.Out, "%s Removed secret %s from %s\n"
, cs.SuccessIconWithColor(cs.Red), opts.SecretName, target)
}
} }
return nil return nil
} }
 End of changes. 8 change blocks. 
9 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)