Skip to content

Commit

Permalink
Merge pull request #108 from alejandrox1/config-code-cleanup
Browse files Browse the repository at this point in the history
clean up pkg/cluster/config
  • Loading branch information
k8s-ci-robot authored Nov 14, 2018
2 parents 1a1bbac + ebf42b0 commit 200294e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions pkg/cluster/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

// DefaultImage is the default for the Config.Image field, aka the default node image
// DefaultImage is the default for the Config.Image field, aka the default node
// image.
const DefaultImage = "kindest/node:v1.12.2@sha256:6ac1dc1750fc0efd13d4e294115f9012a21282957e4380a5535bd32154193d4d"

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

func SetDefaults_Config(obj *Config) {
// SetDefaultsConfig sets uninitialized fields to their default value.
func SetDefaultsConfig(obj *Config) {
if obj.Image == "" {
obj.Image = DefaultImage
}
}

// ApplyDefaults sets the defaults to a Config.
func (c *Config) ApplyDefaults() {
SetDefaults_Config(c)
SetDefaultsConfig(c)
}

// New returns a new default Config.
func New() *Config {
cfg := &Config{}
cfg.ApplyDefaults()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/config/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

// Package config implements the current apiVersion of the `kind` Config
// along with some common abstractions

//
// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=sigs.k8s.io/kind/pkg/cluster/config
// +k8s:defaulter-gen=TypeMeta
Expand Down
12 changes: 8 additions & 4 deletions pkg/cluster/config/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName is the group name used in this package
// GroupName is the group name used in this package.
const GroupName = "kind.sigs.k8s.io"

var (
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects.
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
// SchemeBuilder is a type to collect functions that add data to an API
// object through a scheme.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
// AddToScheme applies all the stored functions in the localSchemeBuilder
// to the scheme.
AddToScheme = localSchemeBuilder.AddToScheme
)

// Kind takes an unqualified kind and returns a Group qualified GroupKind
// Kind takes an unqualified kind and returns a Group qualified GroupKind.
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Config struct {
ControlPlane *ControlPlane `json:"ControlPlane,omitempty"`
}

// ControlPlane holds configurations specific to the control plane nodes
// (currently the only node).
type ControlPlane struct {
// NodeLifecycle contains LifecycleHooks for phases of node provisioning
NodeLifecycle *NodeLifecycle `json:"nodeLifecycle,omitempty"`
Expand Down

0 comments on commit 200294e

Please sign in to comment.