Skip to content

Commit ebe0b19

Browse files
authored
Add basic conf command to output dotlekko (#403)
1 parent 0f83d91 commit ebe0b19

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

cmd/lekko/conf.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2022 Lekko Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"encoding/json"
19+
"fmt"
20+
"os"
21+
22+
"github.com/lekkodev/cli/pkg/dotlekko"
23+
"github.com/spf13/cobra"
24+
)
25+
26+
func confCmd() *cobra.Command {
27+
cmd := &cobra.Command{
28+
Use: "conf",
29+
Short: "parse a .lekko-like configuration file in the working directory",
30+
RunE: func(cmd *cobra.Command, args []string) error {
31+
// By default, read dotlekko and output as JSON
32+
wd, err := os.Getwd()
33+
if err != nil {
34+
return err
35+
}
36+
dot, err := dotlekko.ReadDotLekko(wd)
37+
if err != nil {
38+
return err
39+
}
40+
b, err := json.MarshalIndent(dot, "", " ")
41+
if err != nil {
42+
return err
43+
}
44+
fmt.Println(string(b))
45+
46+
return nil
47+
},
48+
}
49+
return cmd
50+
}

cmd/lekko/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func main() {
6161
rootCmd.AddCommand(namespaceCmd())
6262
rootCmd.AddCommand(apikeyCmd())
6363
rootCmd.AddCommand(upgradeCmd())
64+
rootCmd.AddCommand(confCmd())
6465
// auth
6566
rootCmd.AddCommand(authCmd())
6667
// exp

0 commit comments

Comments
 (0)