Skip to content

Commit

Permalink
Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Shvedunov committed Jun 12, 2018
1 parent 0677a9a commit 014fdc1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ exclude_patterns:
# CRI fields / consts, but make CodeClimate unhappy due to
# underscores and "Id" instead of "ID"
- "pkg/metadata/types/types.go"
# gofmt issue in the generated code
- "pkg/client/clientset/versioned/clientset.go"
4 changes: 2 additions & 2 deletions cmd/virtlet/virtlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func setLogLevel(config *v1.VirtletConfig) {
func main() {
utils.HandleNsFixReexec()
clientCfg := utils.BindFlags(flag.CommandLine)
var cb *config.ConfigBinder
cb = config.NewConfigBinder(flag.CommandLine)
var cb *config.Binder
cb = config.NewBinder(flag.CommandLine)
flag.Parse()
localConfig := cb.GetConfig()

Expand Down
1 change: 0 additions & 1 deletion pkg/api/virtlet.k8s/v1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ limitations under the License.

// Package v1 is the v1 version of the API.
// +groupName=virtlet.k8s

package v1
5 changes: 3 additions & 2 deletions pkg/api/virtlet.k8s/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ const (
)

var (
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
scheme = runtime.NewScheme()
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
scheme = runtime.NewScheme()
// SchemeGroupVersion is group version used to register the objects
SchemeGroupVersion = schema.GroupVersion{Group: groupName, Version: version}
AddToScheme = schemeBuilder.AddToScheme
)
Expand Down
20 changes: 10 additions & 10 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func mappingMatches(cm virtlet_v1.VirtletConfigMapping, nodeName string, nodeLab
return true
}

// MergeConfig merges several Virtlet configs together, with
// MergeConfigs merges several Virtlet configs together, with
// configs going later taking precedence.
func MergeConfigs(configs []*virtlet_v1.VirtletConfig) *virtlet_v1.VirtletConfig {
var cfg *virtlet_v1.VirtletConfig
Expand All @@ -152,23 +152,23 @@ func MergeConfigs(configs []*virtlet_v1.VirtletConfig) *virtlet_v1.VirtletConfig
return cfg
}

// ConfigBinder is used to extract Virtlet config from a FlagSet.
type ConfigBinder struct {
// Binder is used to extract Virtlet config from a FlagSet.
type Binder struct {
flagSet *flag.FlagSet
config *virtlet_v1.VirtletConfig
fieldSet *fieldSet
lookupEnv envLookup
}

// NewConfigBinder returns a new ConfigBinder.
func NewConfigBinder(flagSet *flag.FlagSet) *ConfigBinder {
// NewBinder returns a new Binder.
func NewBinder(flagSet *flag.FlagSet) *Binder {
config := &virtlet_v1.VirtletConfig{}
fs := configFieldSet(config)
fs.applyDefaults()
if flagSet != nil {
fs.addFlags(flagSet)
}
return &ConfigBinder{
return &Binder{
flagSet: flagSet,
config: config,
fieldSet: fs,
Expand All @@ -178,10 +178,10 @@ func NewConfigBinder(flagSet *flag.FlagSet) *ConfigBinder {
// GetConfig returns the config that only includes the fields that
// were explicitly set in the flags. It should be called after parsing
// the flags.
func (cb *ConfigBinder) GetConfig() *virtlet_v1.VirtletConfig {
cb.fieldSet.clearFieldsNotInFlagSet(cb.flagSet)
cb.fieldSet.setFromEnv(cb.lookupEnv)
return cb.config
func (b *Binder) GetConfig() *virtlet_v1.VirtletConfig {
b.fieldSet.clearFieldsNotInFlagSet(b.flagSet)
b.fieldSet.setFromEnv(b.lookupEnv)
return b.config
}

// configForNode gets virtlet_v1.VirtletConfig for the specified node name and labels.
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func verifyEnv(t *testing.T, c *virtlet_v1.VirtletConfig) {
fakeEnv[parts[1]] = subparts[0]
}
}
binder := NewConfigBinder(nil)
binder := NewBinder(nil)
binder.lookupEnv = func(name string) (string, bool) {
r, found := fakeEnv[name]
return r, found
Expand Down Expand Up @@ -153,7 +153,7 @@ func TestMergeConfigs(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
flags := flag.NewFlagSet("virtlet", flag.ContinueOnError)
configBinder := NewConfigBinder(flags)
configBinder := NewBinder(flags)
if err := flags.Parse(strings.Split(tc.args, " ")); err != nil {
t.Fatalf("error parsing flags: %v", err)
}
Expand Down

0 comments on commit 014fdc1

Please sign in to comment.