Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 51e59e4

Browse files
Switch from norman utilities to wrangler
1 parent 65a3a69 commit 51e59e4

File tree

18 files changed

+115
-45
lines changed

18 files changed

+115
-45
lines changed

cli/cmd/apply/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package apply
33
import (
44
"os"
55

6-
"github.com/rancher/norman/pkg/types/convert"
76
"github.com/rancher/rio/cli/cmd/util"
7+
"github.com/rancher/wrangler/pkg/data/convert"
88
"github.com/rancher/wrangler/pkg/yaml"
99
)
1010

cli/cmd/stacks/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package stacks
33
import (
44
"fmt"
55

6-
"github.com/rancher/norman/pkg/types/convert"
76
"github.com/rancher/rio/cli/pkg/clicontext"
87
"github.com/rancher/rio/cli/pkg/table"
98
riov1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
9+
"github.com/rancher/wrangler/pkg/data/convert"
1010
)
1111

1212
type info struct {

cli/pkg/table/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/Masterminds/sprig"
1414
"github.com/davecgh/go-spew/spew"
1515
"github.com/docker/go-units"
16-
"github.com/rancher/norman/pkg/types/convert"
1716
"github.com/rancher/rio/cli/pkg/types"
17+
"github.com/rancher/wrangler/pkg/data/convert"
1818
"gopkg.in/yaml.v2"
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020
"k8s.io/apimachinery/pkg/runtime"

cli/pkg/up/questions/questions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010

1111
"github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty"
1212
"github.com/pkg/errors"
13-
"github.com/rancher/norman/pkg/parse/builder"
14-
"github.com/rancher/norman/pkg/types"
15-
"github.com/rancher/norman/pkg/types/convert"
1613
v1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
14+
"github.com/rancher/wrangler/pkg/data/convert"
1715
"github.com/rancher/wrangler/pkg/kv"
16+
"github.com/rancher/wrangler/pkg/schemas"
17+
"github.com/rancher/wrangler/pkg/schemas/validation"
1818
"golang.org/x/crypto/ssh/terminal"
1919
)
2020

@@ -221,7 +221,7 @@ func (q *question) prompt() (string, error) {
221221
}
222222

223223
func validate(val string, q v1.Question) error {
224-
field := &types.Field{}
224+
field := &schemas.Field{}
225225
err := convert.ToObj(q, field)
226226
if err != nil {
227227
return err
@@ -231,12 +231,12 @@ func validate(val string, q v1.Question) error {
231231
field.Type = "string"
232232
}
233233

234-
converted, err := builder.ConvertSimple(field.Type, val, builder.Create)
234+
converted, err := validation.ConvertSimple(field.Type, val)
235235
if err != nil {
236236
return err
237237
}
238238

239-
return builder.CheckFieldCriteria(q.Variable, *field, converted)
239+
return validation.CheckFieldCriteria(q.Variable, *field, converted)
240240
}
241241

242242
type condition struct {

main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import (
1313
"os"
1414

1515
"github.com/rancher/rio/pkg/config"
16-
17-
"github.com/rancher/norman/pkg/debug"
16+
"github.com/rancher/rio/pkg/debug"
1817
"github.com/rancher/rio/pkg/server"
1918
"github.com/rancher/rio/pkg/version"
2019
"github.com/rancher/wrangler/pkg/signals"

pkg/debug/cli.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package debug
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
7+
"github.com/sirupsen/logrus"
8+
"github.com/urfave/cli"
9+
cliv2 "github.com/urfave/cli/v2"
10+
"k8s.io/klog"
11+
)
12+
13+
type Config struct {
14+
Debug bool
15+
DebugLevel int
16+
}
17+
18+
func (c *Config) MustSetupDebug() {
19+
err := c.SetupDebug()
20+
if err != nil {
21+
panic("failed to setup debug logging: " + err.Error())
22+
}
23+
}
24+
25+
func (c *Config) SetupDebug() error {
26+
logging := flag.NewFlagSet("", flag.PanicOnError)
27+
klog.InitFlags(logging)
28+
if c.Debug {
29+
logrus.SetLevel(logrus.DebugLevel)
30+
if err := logging.Parse([]string{
31+
fmt.Sprintf("-v=%d", c.DebugLevel),
32+
}); err != nil {
33+
return err
34+
}
35+
} else {
36+
if err := logging.Parse([]string{
37+
"-v=0",
38+
}); err != nil {
39+
return err
40+
}
41+
}
42+
43+
return nil
44+
}
45+
46+
func Flags(config *Config) []cli.Flag {
47+
return []cli.Flag{
48+
cli.BoolFlag{
49+
Name: "debug",
50+
Destination: &config.Debug,
51+
},
52+
cli.IntFlag{
53+
Name: "debug-level",
54+
Value: 7,
55+
Destination: &config.DebugLevel,
56+
},
57+
}
58+
}
59+
60+
func FlagsV2(config *Config) []cliv2.Flag {
61+
return []cliv2.Flag{
62+
&cliv2.BoolFlag{
63+
Name: "debug",
64+
Destination: &config.Debug,
65+
},
66+
&cliv2.IntFlag{
67+
Name: "debug-level",
68+
Value: 7,
69+
Destination: &config.DebugLevel,
70+
},
71+
}
72+
}

pkg/riofile/mappers/configmap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package mappers
22

33
import (
4-
"github.com/rancher/norman/pkg/data"
5-
"github.com/rancher/norman/pkg/types"
6-
"github.com/rancher/norman/pkg/types/convert"
7-
"github.com/rancher/norman/pkg/types/mapper"
4+
"github.com/rancher/wrangler/pkg/data"
5+
"github.com/rancher/wrangler/pkg/data/convert"
6+
types "github.com/rancher/wrangler/pkg/schemas"
7+
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
88
)
99

1010
type ConfigMapMapper struct {

pkg/riofile/mappers/duration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package mappers
22

33
import (
4-
"github.com/rancher/norman/pkg/data"
5-
"github.com/rancher/norman/pkg/types"
6-
"github.com/rancher/norman/pkg/types/mapper"
74
"github.com/rancher/rio/pkg/riofile/stringers"
5+
"github.com/rancher/wrangler/pkg/data"
6+
types "github.com/rancher/wrangler/pkg/schemas"
7+
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
88
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
)
1010

pkg/riofile/mappers/envmap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/rancher/norman/pkg/data"
8-
"github.com/rancher/norman/pkg/types"
9-
"github.com/rancher/norman/pkg/types/mapper"
7+
"github.com/rancher/wrangler/pkg/data"
8+
types "github.com/rancher/wrangler/pkg/schemas"
9+
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
1010
)
1111

1212
type EnvMapper struct {

pkg/riofile/mappers/hostnetwork.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package mappers
22

33
import (
4-
"github.com/rancher/norman/pkg/data"
5-
"github.com/rancher/norman/pkg/types"
4+
"github.com/rancher/wrangler/pkg/data"
5+
types "github.com/rancher/wrangler/pkg/schemas"
66
)
77

88
type HostNetwork struct {

0 commit comments

Comments
 (0)