-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- cli / admin api bug fixes - add secret resource - performance - raft updates (snapshots disabled) - add metrics
- Loading branch information
Showing
75 changed files
with
1,906 additions
and
1,160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/dgate-io/dgate/pkg/dgclient" | ||
"github.com/dgate-io/dgate/pkg/spec" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func SecretCommand(client *dgclient.DGateClient) *cli.Command { | ||
return &cli.Command{ | ||
Name: "secret", | ||
Aliases: []string{"sec"}, | ||
Args: true, | ||
ArgsUsage: "<command> <name>", | ||
Usage: "secret commands", | ||
Subcommands: []*cli.Command{ | ||
{ | ||
Name: "create", | ||
Aliases: []string{"mk"}, | ||
Usage: "create a secret", | ||
Action: func(ctx *cli.Context) error { | ||
sec, err := createMapFromArgs[spec.Secret]( | ||
ctx.Args().Slice(), "name", "data", | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
err = client.CreateSecret(sec) | ||
if err != nil { | ||
return err | ||
} | ||
// redact the data field | ||
sec.Data = "**redacted**" | ||
return jsonPrettyPrint(sec) | ||
}, | ||
}, | ||
{ | ||
Name: "delete", | ||
Aliases: []string{"rm"}, | ||
Usage: "delete a secret", | ||
Action: func(ctx *cli.Context) error { | ||
sec, err := createMapFromArgs[spec.Secret]( | ||
ctx.Args().Slice(), "name", | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
err = client.DeleteSecret( | ||
sec.Name, sec.NamespaceName) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
}, | ||
{ | ||
Name: "list", | ||
Aliases: []string{"ls"}, | ||
Usage: "list services", | ||
Action: func(ctx *cli.Context) error { | ||
nsp, err := createMapFromArgs[dgclient.NamespacePayload]( | ||
ctx.Args().Slice(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
sec, err := client.ListSecret(nsp.Namespace) | ||
if err != nil { | ||
return err | ||
} | ||
return jsonPrettyPrint(sec) | ||
}, | ||
}, | ||
{ | ||
Name: "get", | ||
Usage: "get a secret", | ||
Action: func(ctx *cli.Context) error { | ||
s, err := createMapFromArgs[spec.Secret]( | ||
ctx.Args().Slice(), "name", | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
sec, err := client.GetSecret( | ||
s.Name, s.NamespaceName, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
return jsonPrettyPrint(sec) | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.