Skip to content

Commit

Permalink
feat: update mungectl API
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Jul 3, 2024
1 parent 117e885 commit b5495ec
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd
package key

import (
"fmt"
Expand All @@ -25,7 +25,7 @@ import (
key "mungectl/internal/key"
)

const generateHelp = "generate a new munge key"
const generateHelp = "Generate a new munge key"
const generateExample = `mungectl generate
Generate a new munge key and write to key file location
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd
package key

import (
"fmt"
Expand All @@ -25,9 +25,9 @@ import (
key "mungectl/internal/key"
)

const getHelp = "get current munge key"
const getHelp = "Get the current munge key"
const getExample = `
mungectl get > key.out
mungectl key get > key.out
Get current munge key, encode into a base64 string, and write to key.out.
`
Expand Down
32 changes: 32 additions & 0 deletions src/mungectl/cmd/mungectl/cmd/key/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2024 Canonical Ltd.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package key

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

const keyHelp = "Manage munge key file"

var KeyCmd = &cobra.Command{
Use: "key",
Short: keyHelp,
}

func init() {
KeyCmd.CompletionOptions.DisableDefaultCmd = true
KeyCmd.AddCommand(generateCmd, getCmd, setCmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package cmd
package key

import (
"fmt"
Expand All @@ -25,9 +25,9 @@ import (
key "mungectl/internal/key"
)

const setHelp = "set a new munge key"
const setHelp = "Set a new munge key"
const setExample = `
mungectl set < secret.key
mungectl key set < secret.key
Replace old munge key with one read from stdin
`
Expand Down
9 changes: 7 additions & 2 deletions src/mungectl/cmd/mungectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ import (
"os"

"github.com/spf13/cobra"

key "mungectl/cmd/mungectl/cmd/key"
)

const help = "Control the munge authentication daemon"

var rootCmd = &cobra.Command{
Use: "mungectl",
Use: "mungectl",
Short: help,
}

func init() {
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.AddCommand(generateCmd, getCmd, setCmd)
rootCmd.AddCommand(key.KeyCmd)
}

func Execute() {
Expand Down

0 comments on commit b5495ec

Please sign in to comment.