-
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.
* add new resource secret, fix bugs, add tests and misc performance improvements * bugfix: squash error, and cleanup code * misc fixes and features - cli / admin api bug fixes - add secret resource - performance - raft updates (snapshots disabled) - add metrics * fix nil deref * add more verbose metrics improve metric error handling add reverse proxy tests * add new async sleep add imple retry timeout add disable metrics opt refactor module logic
- Loading branch information
Showing
106 changed files
with
3,486 additions
and
1,728 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ dist/ | |
.dgate*/ | ||
cov.out | ||
go.work.sum | ||
.env |
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
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
Oops, something went wrong.