Skip to content

Commit

Permalink
add rotate key cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
AshutoshPatole committed Sep 7, 2024
1 parent 837160b commit 0a94f92
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
48 changes: 48 additions & 0 deletions cmd/rotateKey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// package cmd
package cmd

import (
"github.com/spf13/cobra"
)

var (
rotateAll bool
rotateGroup string
rotateHost string
)

// rotateKeyCmd represents the rotateKey command
var rotateKeyCmd = &cobra.Command{
Use: "rotate-key",
Short: "Rotate the encryption key for added security",
Long: `The rotate-key command allows you to rotate the ssh key used by the servers.
This is an important security practice that helps protect your servers by regularly changing the key.
`,
Run: func(cmd *cobra.Command, args []string) {
if rotateAll {
rotateKeysForAll()
} else if rotateGroup != "" {
rotateKeysForGroup(rotateGroup)
} else if rotateHost != "" {
rotateKeysForHost(rotateHost)
} else {
cmd.Printf("Please specify --all, --group, or --host\n")
}
},
}

func init() {
rootCmd.AddCommand(rotateKeyCmd)
}

func rotateKeysForAll() {
// Implementation
}

func rotateKeysForGroup(group string) {
// Implementation
}

func rotateKeysForHost(host string) {
// Implementation
}
15 changes: 9 additions & 6 deletions internal/store/model.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package store

import "time"

type Server struct {
HostName string `yaml:"hostname"`
IP string `yaml:"ip"`
Alias string `yaml:"alias"`
User string `yaml:"user"`
Password string `yaml:"password,omitempty"`
IsRDP bool `yaml:"isRDP,omitempty"`
HostName string `yaml:"hostname"`
IP string `yaml:"ip"`
Alias string `yaml:"alias"`
User string `yaml:"user"`
Password string `yaml:"password,omitempty"`
IsRDP bool `yaml:"isRDP,omitempty"`
KeyRotatedAt time.Time `yaml:"keyRotatedAt,omitempty"`
}

type Env struct {
Expand Down

0 comments on commit 0a94f92

Please sign in to comment.