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

Commit

Permalink
Switch from norman utilities to wrangler
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Feb 5, 2020
1 parent 0d3f61c commit e8ab31a
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package apply
import (
"os"

"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/rio/cli/cmd/util"
"github.com/rancher/wrangler/pkg/data/convert"
"github.com/rancher/wrangler/pkg/yaml"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/stacks/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package stacks
import (
"fmt"

"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/rio/cli/pkg/clicontext"
"github.com/rancher/rio/cli/pkg/table"
riov1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
"github.com/rancher/wrangler/pkg/data/convert"
)

type info struct {
Expand Down
2 changes: 1 addition & 1 deletion cli/pkg/table/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/Masterminds/sprig"
"github.com/davecgh/go-spew/spew"
"github.com/docker/go-units"
"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/rio/cli/pkg/types"
"github.com/rancher/wrangler/pkg/data/convert"
"gopkg.in/yaml.v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
12 changes: 6 additions & 6 deletions cli/pkg/up/questions/questions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty"
"github.com/pkg/errors"
"github.com/rancher/norman/pkg/parse/builder"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/convert"
v1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
"github.com/rancher/wrangler/pkg/data/convert"
"github.com/rancher/wrangler/pkg/kv"
"github.com/rancher/wrangler/pkg/schemas"
"github.com/rancher/wrangler/pkg/schemas/validation"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down Expand Up @@ -221,7 +221,7 @@ func (q *question) prompt() (string, error) {
}

func validate(val string, q v1.Question) error {
field := &types.Field{}
field := &schemas.Field{}
err := convert.ToObj(q, field)
if err != nil {
return err
Expand All @@ -231,12 +231,12 @@ func validate(val string, q v1.Question) error {
field.Type = "string"
}

converted, err := builder.ConvertSimple(field.Type, val, builder.Create)
converted, err := validation.ConvertSimple(field.Type, val)
if err != nil {
return err
}

return builder.CheckFieldCriteria(q.Variable, *field, converted)
return validation.CheckFieldCriteria(q.Variable, *field, converted)
}

type condition struct {
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"os"

"github.com/rancher/rio/pkg/config"

"github.com/rancher/norman/pkg/debug"
"github.com/rancher/rio/pkg/debug"
"github.com/rancher/rio/pkg/server"
"github.com/rancher/rio/pkg/version"
"github.com/rancher/wrangler/pkg/signals"
Expand Down
72 changes: 72 additions & 0 deletions pkg/debug/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package debug

import (
"flag"
"fmt"

"github.com/sirupsen/logrus"
"github.com/urfave/cli"
cliv2 "github.com/urfave/cli/v2"
"k8s.io/klog"
)

type Config struct {
Debug bool
DebugLevel int
}

func (c *Config) MustSetupDebug() {
err := c.SetupDebug()
if err != nil {
panic("failed to setup debug logging: " + err.Error())
}
}

func (c *Config) SetupDebug() error {
logging := flag.NewFlagSet("", flag.PanicOnError)
klog.InitFlags(logging)
if c.Debug {
logrus.SetLevel(logrus.DebugLevel)
if err := logging.Parse([]string{
fmt.Sprintf("-v=%d", c.DebugLevel),
}); err != nil {
return err
}
} else {
if err := logging.Parse([]string{
"-v=0",
}); err != nil {
return err
}
}

return nil
}

func Flags(config *Config) []cli.Flag {
return []cli.Flag{
cli.BoolFlag{
Name: "debug",
Destination: &config.Debug,
},
cli.IntFlag{
Name: "debug-level",
Value: 7,
Destination: &config.DebugLevel,
},
}
}

func FlagsV2(config *Config) []cliv2.Flag {
return []cliv2.Flag{
&cliv2.BoolFlag{
Name: "debug",
Destination: &config.Debug,
},
&cliv2.IntFlag{
Name: "debug-level",
Value: 7,
Destination: &config.DebugLevel,
},
}
}
8 changes: 4 additions & 4 deletions pkg/riofile/mappers/configmap.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package mappers

import (
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/wrangler/pkg/data"
"github.com/rancher/wrangler/pkg/data/convert"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
)

type ConfigMapMapper struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/riofile/mappers/duration.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package mappers

import (
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/rio/pkg/riofile/stringers"
"github.com/rancher/wrangler/pkg/data"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/riofile/mappers/envmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/wrangler/pkg/data"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
)

type EnvMapper struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/riofile/mappers/hostnetwork.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package mappers

import (
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/wrangler/pkg/data"
types "github.com/rancher/wrangler/pkg/schemas"
)

type HostNetwork struct {
Expand Down
9 changes: 4 additions & 5 deletions pkg/riofile/mappers/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package mappers
import (
"strings"

"github.com/rancher/norman/pkg/types/mapper"

"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/wrangler/pkg/data"
types "github.com/rancher/wrangler/pkg/schemas"
"github.com/rancher/wrangler/pkg/schemas/mappers"
)

type LabelCleaner struct {
mapper.DefaultMapper
mappers.DefaultMapper
}

func (d LabelCleaner) FromInternal(data data.Object) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/riofile/mappers/object.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package mappers

import (
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/mapper"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
)

func NewObject(kind, apiVersion string) types.Mapper {
Expand Down
8 changes: 4 additions & 4 deletions pkg/riofile/mappers/objects_to_slice.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package mappers

import (
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/wrangler/pkg/data"
"github.com/rancher/wrangler/pkg/data/convert"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
"github.com/sirupsen/logrus"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/riofile/mappers/quantity.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package mappers

import (
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/rio/pkg/riofile/stringers"
"github.com/rancher/wrangler/pkg/data"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
)

type QuantityMapper struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/riofile/mappers/shlex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package mappers

import (
"github.com/mattn/go-shellwords"
"github.com/rancher/norman/pkg/data"
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/norman/pkg/types/mapper"
"github.com/rancher/wrangler/pkg/data"
"github.com/rancher/wrangler/pkg/data/convert"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
)

type Shlex struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/riofile/riofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"encoding/json"
"strings"

"github.com/rancher/norman/pkg/types/convert"
"github.com/rancher/rio/cli/pkg/table"
riov1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
"github.com/rancher/rio/pkg/riofile/schema"
"github.com/rancher/rio/pkg/template"
"github.com/rancher/wrangler/pkg/data/convert"
"github.com/rancher/wrangler/pkg/gvk"
"github.com/rancher/wrangler/pkg/yaml"
v1 "k8s.io/api/core/v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/riofile/schema/schema.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package schema

import (
"github.com/rancher/norman/pkg/types"
"github.com/rancher/norman/pkg/types/mapper"
v1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
m "github.com/rancher/rio/pkg/riofile/mappers"
"github.com/rancher/rio/pkg/riofile/stringers"
types "github.com/rancher/wrangler/pkg/schemas"
mapper "github.com/rancher/wrangler/pkg/schemas/mappers"
corev1 "k8s.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/server/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"strconv"
"strings"

"github.com/rancher/norman/pkg/openapi"
rioadminv1 "github.com/rancher/rio/pkg/apis/admin.rio.cattle.io/v1"
v1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
"github.com/rancher/wrangler/pkg/crd"
"github.com/rancher/wrangler/pkg/kv"
"github.com/rancher/wrangler/pkg/schemas/openapi"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
)

Expand Down

0 comments on commit e8ab31a

Please sign in to comment.