Skip to content

Commit

Permalink
cleanup after generate
Browse files Browse the repository at this point in the history
  • Loading branch information
liangwei committed Sep 26, 2018
1 parent e645048 commit d812d62
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 166 deletions.
85 changes: 0 additions & 85 deletions pkg/cluster/config/deepcopy.go

This file was deleted.

77 changes: 0 additions & 77 deletions pkg/cluster/config/deepcopy_test.go

This file was deleted.

12 changes: 11 additions & 1 deletion pkg/cluster/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

// New returns a new default Config
func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
return RegisterDefaults(scheme)
}

func SetDefaults_Config(obj *Config) {
Expand All @@ -34,3 +34,13 @@ func SetDefaults_Config(obj *Config) {
obj.NumNodes = 1
}
}

func (c *Config) ApplyDefaults() {
SetDefaults_Config(c)
}

func New() *Config {
cfg := &Config{}
cfg.ApplyDefaults()
return cfg
}
6 changes: 3 additions & 3 deletions pkg/cluster/config/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func detectVersion(raw []byte) (version string, err error) {
}
switch c.APIVersion {
// default to the current api version if unspecified, or explicitly specified
case config.APIVersion, "":
return config.APIVersion, nil
case config.SchemeGroupVersion.String(), "":
return config.SchemeGroupVersion.String(), nil
}
return "", fmt.Errorf("invalid version: %v", c.APIVersion)
}
Expand All @@ -92,7 +92,7 @@ func Unmarshal(raw []byte) (config.Any, error) {
// load version
var cfg config.Any
switch version {
case config.APIVersion:
case config.SchemeGroupVersion.String():
cfg = &config.Config{}
}
err = yaml.Unmarshal(raw, cfg)
Expand Down
33 changes: 33 additions & 0 deletions pkg/cluster/config/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package config

// APIVersion is the kubernetes-style API apiVersion for this Config package
const APIVersion = "kind.sigs.k8s.io/v1alpha1"

// ConfigKind is the kubernetes-style API kind identifier for Config
const ConfigKind = "Config"

// Kind returns the `kind:` for Config
func (c *Config) Kind() string {
return ConfigKind
}

// APIVersion returns the `apiVersion:` for Config
func (c *Config) APIVersion() string {
return SchemeGroupVersion.String()
}

0 comments on commit d812d62

Please sign in to comment.