Skip to content

Commit

Permalink
Merge pull request #4538 from justinsb/addons_schema_tweak
Browse files Browse the repository at this point in the history
Make addon specification into an object
  • Loading branch information
k8s-ci-robot authored Feb 28, 2018
2 parents 6ff0a64 + f4990e6 commit 65ba539
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type ClusterList struct {
type ClusterSpec struct {
// The Channel we are following
Channel string `json:"channel,omitempty"`
// Additional addons that should be installed on the cluster
Addons []AddonSpec `json:"addons,omitempty"`
// ConfigBase is the path where we store configuration for the cluster
// This might be different than the location where the cluster spec itself is stored,
// both because this must be accessible to the cluster,
Expand Down Expand Up @@ -164,6 +166,12 @@ type ClusterSpec struct {
Target *TargetSpec `json:"target,omitempty"`
}

// AddonSpec defines an addon that we want to install in the cluster
type AddonSpec struct {
// Manifest is a path to the manifest that defines the addon
Manifest string `json:"manifest,omitempty"`
}

// FileAssetSpec defines the structure for a file asset
type FileAssetSpec struct {
// Name is a shortened reference to the asset
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/kops/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type ClusterList struct {
type ClusterSpec struct {
// Channel we are following
Channel string `json:"channel,omitempty"`
// Additional addons that should be installed on the cluster
Addons []AddonSpec `json:"addons,omitempty"`
// ConfigBase is the path where we store configuration for the cluster
// This might be different that the location when the cluster spec itself is stored,
// both because this must be accessible to the cluster,
Expand Down Expand Up @@ -163,6 +165,12 @@ type ClusterSpec struct {
Target *TargetSpec `json:"target,omitempty"`
}

// AddonSpec defines an addon that we want to install in the cluster
type AddonSpec struct {
// Manifest is a path to the manifest that defines the addon
Manifest string `json:"manifest,omitempty"`
}

// FileAssetSpec defines the structure for a file asset
type FileAssetSpec struct {
// Name is a shortened reference to the asset
Expand Down
44 changes: 44 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1alpha1_AccessSpec_To_kops_AccessSpec,
Convert_kops_AccessSpec_To_v1alpha1_AccessSpec,
Convert_v1alpha1_AddonSpec_To_kops_AddonSpec,
Convert_kops_AddonSpec_To_v1alpha1_AddonSpec,
Convert_v1alpha1_AlwaysAllowAuthorizationSpec_To_kops_AlwaysAllowAuthorizationSpec,
Convert_kops_AlwaysAllowAuthorizationSpec_To_v1alpha1_AlwaysAllowAuthorizationSpec,
Convert_v1alpha1_AmazonVPCNetworkingSpec_To_kops_AmazonVPCNetworkingSpec,
Expand Down Expand Up @@ -202,6 +204,26 @@ func Convert_kops_AccessSpec_To_v1alpha1_AccessSpec(in *kops.AccessSpec, out *Ac
return autoConvert_kops_AccessSpec_To_v1alpha1_AccessSpec(in, out, s)
}

func autoConvert_v1alpha1_AddonSpec_To_kops_AddonSpec(in *AddonSpec, out *kops.AddonSpec, s conversion.Scope) error {
out.Manifest = in.Manifest
return nil
}

// Convert_v1alpha1_AddonSpec_To_kops_AddonSpec is an autogenerated conversion function.
func Convert_v1alpha1_AddonSpec_To_kops_AddonSpec(in *AddonSpec, out *kops.AddonSpec, s conversion.Scope) error {
return autoConvert_v1alpha1_AddonSpec_To_kops_AddonSpec(in, out, s)
}

func autoConvert_kops_AddonSpec_To_v1alpha1_AddonSpec(in *kops.AddonSpec, out *AddonSpec, s conversion.Scope) error {
out.Manifest = in.Manifest
return nil
}

// Convert_kops_AddonSpec_To_v1alpha1_AddonSpec is an autogenerated conversion function.
func Convert_kops_AddonSpec_To_v1alpha1_AddonSpec(in *kops.AddonSpec, out *AddonSpec, s conversion.Scope) error {
return autoConvert_kops_AddonSpec_To_v1alpha1_AddonSpec(in, out, s)
}

func autoConvert_v1alpha1_AlwaysAllowAuthorizationSpec_To_kops_AlwaysAllowAuthorizationSpec(in *AlwaysAllowAuthorizationSpec, out *kops.AlwaysAllowAuthorizationSpec, s conversion.Scope) error {
return nil
}
Expand Down Expand Up @@ -604,6 +626,17 @@ func Convert_kops_ClusterList_To_v1alpha1_ClusterList(in *kops.ClusterList, out

func autoConvert_v1alpha1_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out *kops.ClusterSpec, s conversion.Scope) error {
out.Channel = in.Channel
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]kops.AddonSpec, len(*in))
for i := range *in {
if err := Convert_v1alpha1_AddonSpec_To_kops_AddonSpec(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Addons = nil
}
out.ConfigBase = in.ConfigBase
out.CloudProvider = in.CloudProvider
out.KubernetesVersion = in.KubernetesVersion
Expand Down Expand Up @@ -849,6 +882,17 @@ func autoConvert_v1alpha1_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out *

func autoConvert_kops_ClusterSpec_To_v1alpha1_ClusterSpec(in *kops.ClusterSpec, out *ClusterSpec, s conversion.Scope) error {
out.Channel = in.Channel
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]AddonSpec, len(*in))
for i := range *in {
if err := Convert_kops_AddonSpec_To_v1alpha1_AddonSpec(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Addons = nil
}
out.ConfigBase = in.ConfigBase
out.CloudProvider = in.CloudProvider
out.KubernetesVersion = in.KubernetesVersion
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ func (in *AccessSpec) DeepCopy() *AccessSpec {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AddonSpec) DeepCopyInto(out *AddonSpec) {
*out = *in
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec.
func (in *AddonSpec) DeepCopy() *AddonSpec {
if in == nil {
return nil
}
out := new(AddonSpec)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AlwaysAllowAuthorizationSpec) DeepCopyInto(out *AlwaysAllowAuthorizationSpec) {
*out = *in
Expand Down Expand Up @@ -521,6 +537,11 @@ func (in *ClusterList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
*out = *in
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]AddonSpec, len(*in))
copy(*out, *in)
}
if in.Zones != nil {
in, out := &in.Zones, &out.Zones
*out = make([]*ClusterZoneSpec, len(*in))
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type ClusterList struct {
type ClusterSpec struct {
// The Channel we are following
Channel string `json:"channel,omitempty"`
// Additional addons that should be installed on the cluster
Addons []AddonSpec `json:"addons,omitempty"`
// ConfigBase is the path where we store configuration for the cluster
// This might be different that the location when the cluster spec itself is stored,
// both because this must be accessible to the cluster,
Expand Down Expand Up @@ -164,6 +166,12 @@ type ClusterSpec struct {
Target *TargetSpec `json:"target,omitempty"`
}

// AddonSpec defines an addon that we want to install in the cluster
type AddonSpec struct {
// Manifest is a path to the manifest that defines the addon
Manifest string `json:"manifest,omitempty"`
}

// FileAssetSpec defines the structure for a file asset
type FileAssetSpec struct {
// Name is a shortened reference to the asset
Expand Down
44 changes: 44 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1alpha2_AccessSpec_To_kops_AccessSpec,
Convert_kops_AccessSpec_To_v1alpha2_AccessSpec,
Convert_v1alpha2_AddonSpec_To_kops_AddonSpec,
Convert_kops_AddonSpec_To_v1alpha2_AddonSpec,
Convert_v1alpha2_AlwaysAllowAuthorizationSpec_To_kops_AlwaysAllowAuthorizationSpec,
Convert_kops_AlwaysAllowAuthorizationSpec_To_v1alpha2_AlwaysAllowAuthorizationSpec,
Convert_v1alpha2_AmazonVPCNetworkingSpec_To_kops_AmazonVPCNetworkingSpec,
Expand Down Expand Up @@ -216,6 +218,26 @@ func Convert_kops_AccessSpec_To_v1alpha2_AccessSpec(in *kops.AccessSpec, out *Ac
return autoConvert_kops_AccessSpec_To_v1alpha2_AccessSpec(in, out, s)
}

func autoConvert_v1alpha2_AddonSpec_To_kops_AddonSpec(in *AddonSpec, out *kops.AddonSpec, s conversion.Scope) error {
out.Manifest = in.Manifest
return nil
}

// Convert_v1alpha2_AddonSpec_To_kops_AddonSpec is an autogenerated conversion function.
func Convert_v1alpha2_AddonSpec_To_kops_AddonSpec(in *AddonSpec, out *kops.AddonSpec, s conversion.Scope) error {
return autoConvert_v1alpha2_AddonSpec_To_kops_AddonSpec(in, out, s)
}

func autoConvert_kops_AddonSpec_To_v1alpha2_AddonSpec(in *kops.AddonSpec, out *AddonSpec, s conversion.Scope) error {
out.Manifest = in.Manifest
return nil
}

// Convert_kops_AddonSpec_To_v1alpha2_AddonSpec is an autogenerated conversion function.
func Convert_kops_AddonSpec_To_v1alpha2_AddonSpec(in *kops.AddonSpec, out *AddonSpec, s conversion.Scope) error {
return autoConvert_kops_AddonSpec_To_v1alpha2_AddonSpec(in, out, s)
}

func autoConvert_v1alpha2_AlwaysAllowAuthorizationSpec_To_kops_AlwaysAllowAuthorizationSpec(in *AlwaysAllowAuthorizationSpec, out *kops.AlwaysAllowAuthorizationSpec, s conversion.Scope) error {
return nil
}
Expand Down Expand Up @@ -640,6 +662,17 @@ func Convert_kops_ClusterList_To_v1alpha2_ClusterList(in *kops.ClusterList, out

func autoConvert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out *kops.ClusterSpec, s conversion.Scope) error {
out.Channel = in.Channel
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]kops.AddonSpec, len(*in))
for i := range *in {
if err := Convert_v1alpha2_AddonSpec_To_kops_AddonSpec(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Addons = nil
}
out.ConfigBase = in.ConfigBase
out.CloudProvider = in.CloudProvider
out.KubernetesVersion = in.KubernetesVersion
Expand Down Expand Up @@ -901,6 +934,17 @@ func Convert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out *kops

func autoConvert_kops_ClusterSpec_To_v1alpha2_ClusterSpec(in *kops.ClusterSpec, out *ClusterSpec, s conversion.Scope) error {
out.Channel = in.Channel
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]AddonSpec, len(*in))
for i := range *in {
if err := Convert_kops_AddonSpec_To_v1alpha2_AddonSpec(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Addons = nil
}
out.ConfigBase = in.ConfigBase
out.CloudProvider = in.CloudProvider
out.KubernetesVersion = in.KubernetesVersion
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ func (in *AccessSpec) DeepCopy() *AccessSpec {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AddonSpec) DeepCopyInto(out *AddonSpec) {
*out = *in
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec.
func (in *AddonSpec) DeepCopy() *AddonSpec {
if in == nil {
return nil
}
out := new(AddonSpec)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AlwaysAllowAuthorizationSpec) DeepCopyInto(out *AlwaysAllowAuthorizationSpec) {
*out = *in
Expand Down Expand Up @@ -521,6 +537,11 @@ func (in *ClusterList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
*out = *in
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]AddonSpec, len(*in))
copy(*out, *in)
}
if in.Subnets != nil {
in, out := &in.Subnets, &out.Subnets
*out = make([]ClusterSubnetSpec, len(*in))
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ func (in *AccessSpec) DeepCopy() *AccessSpec {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AddonSpec) DeepCopyInto(out *AddonSpec) {
*out = *in
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec.
func (in *AddonSpec) DeepCopy() *AddonSpec {
if in == nil {
return nil
}
out := new(AddonSpec)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AlwaysAllowAuthorizationSpec) DeepCopyInto(out *AlwaysAllowAuthorizationSpec) {
*out = *in
Expand Down Expand Up @@ -626,6 +642,11 @@ func (in *ClusterList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
*out = *in
if in.Addons != nil {
in, out := &in.Addons, &out.Addons
*out = make([]AddonSpec, len(*in))
copy(*out, *in)
}
if in.Subnets != nil {
in, out := &in.Subnets, &out.Subnets
*out = make([]ClusterSubnetSpec, len(*in))
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/conversion/minimal/v1alpha0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
spec:
additionalSans:
- proxy.api.minimal.example.com
addons:
- manifest: s3://somebucket/example.yaml
adminAccess:
- 0.0.0.0/0
channel: stable
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/conversion/minimal/v1alpha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
spec:
additionalSans:
- proxy.api.minimal.example.com
addons:
- manifest: s3://somebucket/example.yaml
adminAccess:
- 0.0.0.0/0
api:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/conversion/minimal/v1alpha2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
spec:
additionalSans:
- proxy.api.minimal.example.com
addons:
- manifest: s3://somebucket/example.yaml
api:
dns: {}
authorization:
Expand Down
4 changes: 4 additions & 0 deletions upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,10 @@ func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, i
configBase.Join("addons", "bootstrap-channel.yaml").Path(),
}

for i := range c.Cluster.Spec.Addons {
channels = append(channels, c.Cluster.Spec.Addons[i].Manifest)
}

role := ig.Spec.Role
if role == "" {
return nil, fmt.Errorf("cannot determine role for instance group: %v", ig.ObjectMeta.Name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
creationTimestamp: "2016-12-10T22:42:27Z"
name: minimal.example.com
spec:
addons:
- manifest: s3://somebucket/example.yaml
kubernetesApiAccess:
- 0.0.0.0/0
channel: stable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
creationTimestamp: "2016-12-10T22:42:27Z"
name: minimal.example.com
spec:
addons:
- manifest: s3://somebucket/example.yaml
kubernetesApiAccess:
- 0.0.0.0/0
channel: stable
Expand Down

0 comments on commit 65ba539

Please sign in to comment.