Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
ci: unignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
eliobischof committed Nov 24, 2021
1 parent 5566591 commit e219724
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions cmd/orbctl/remove.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Inspired by https://samrapdev.com/capturing-sensitive-input-with-editor-in-golang-from-the-cli/

package main

import (
"errors"
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/caos/orbos/pkg/git"
)

func RemoveCommand(getRv GetRootValues) *cobra.Command {

cmd := &cobra.Command{
Use: "remove <filepath>",
Short: "Remove file from git repository",
Long: "If the file doesn't exist, the command completes successfully",
Args: cobra.MinimumNArgs(1),
Example: `orbctl file remove caos-internal/orbiter/current.yml`,
}

cmd.RunE = func(cmd *cobra.Command, args []string) error {

filesStr := strings.Join(args, ",")

rv, err := getRv("remove", "", map[string]interface{}{"files": filesStr})
if err != nil {
return err
}
defer rv.ErrFunc(err)

if !rv.Gitops {
return errors.New("remove command is only supported with the --gitops flag")
}

if err := initRepo(rv.OrbConfig, rv.GitClient); err != nil {
return err
}

files := make([]git.File, len(args))
for i := range args {
files[i] = git.File{
Path: args[i],
Content: nil,
}
}

return rv.GitClient.UpdateRemote(fmt.Sprintf("Remove %s", filesStr), func() []git.File { return files })
}

return cmd
}

0 comments on commit e219724

Please sign in to comment.