Skip to content

Commit bf29e77

Browse files
Kern WalsterKern--
authored andcommitted
Add soci-snapshotter-grpc config dump command
Signed-off-by: Kern Walster <walster@amazon.com>
1 parent df275a3 commit bf29e77

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright The Soci Snapshotter Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"context"
21+
"os"
22+
23+
"github.com/awslabs/soci-snapshotter/config"
24+
"github.com/containerd/log"
25+
"github.com/pelletier/go-toml/v2"
26+
"github.com/urfave/cli/v3"
27+
)
28+
29+
var ConfigCommand = &cli.Command{
30+
Name: "config",
31+
Usage: "Manage configuration",
32+
Commands: []*cli.Command{
33+
{
34+
Name: "dump",
35+
Usage: "Dump configuration",
36+
Action: func(ctx context.Context, cmd *cli.Command) error {
37+
cfg, err := config.NewConfigFromToml(cmd.String("config"))
38+
if err != nil {
39+
log.G(ctx).WithError(err).Fatal(err)
40+
}
41+
42+
toml.NewEncoder(os.Stdout).SetIndentTables(true).Encode(cfg)
43+
return nil
44+
},
45+
},
46+
},
47+
}

cmd/soci-snapshotter-grpc/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func main() {
112112
},
113113
},
114114
Version: fmt.Sprintf("%s %s", version.Version, version.Revision),
115+
Commands: []*cli.Command{
116+
ConfigCommand,
117+
},
115118
Action: func(ctx context.Context, cmd *cli.Command) error {
116119
lvl, err := logrus.ParseLevel(cmd.String("log-level"))
117120
if err != nil {

0 commit comments

Comments
 (0)