Skip to content

Commit

Permalink
pkg/manifests: move cluster_k8s_io to manifests from machines.
Browse files Browse the repository at this point in the history
This is to break an import loop between pkg/assets/machines and
pkg/assets/manifests.
  • Loading branch information
squeed committed Nov 12, 2018
1 parent 31b78ea commit 687ff31
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 75 deletions.
73 changes: 0 additions & 73 deletions pkg/asset/machines/cluster_k8s_io.go

This file was deleted.

65 changes: 65 additions & 0 deletions pkg/asset/manifests/cluster_k8s_io.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package manifests

import (
"github.com/ghodss/yaml"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
clusterv1a1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

// This file was originally in pkg/assets/machines, but is now in
// /manifests due to an import loop.

// ClusterK8sIO generates the `Cluster.cluster.k8s.io/v1alpha1` object.
type ClusterK8sIO struct {
Raw []byte
}

var _ asset.Asset = (*ClusterK8sIO)(nil)

// Name returns a human friendly name for the ClusterK8sIO Asset.
func (c *ClusterK8sIO) Name() string {
return "Cluster.cluster.k8s.io/v1alpha1"
}

// Dependencies returns all of the dependencies directly needed by the
// ClusterK8sIO asset
func (c *ClusterK8sIO) Dependencies() []asset.Asset {
return []asset.Asset{
&installconfig.InstallConfig{},
&Networking{},
}
}

// Generate generates the Worker asset.
func (c *ClusterK8sIO) Generate(dependencies asset.Parents) error {
installconfig := &installconfig.InstallConfig{}
dependencies.Get(installconfig)

net := &Networking{}
dependencies.Get(net)
clusterNet, err := net.ClusterNetwork()
if err != nil {
return errors.Wrapf(err, "Could not generate ClusterNetworkingConfig")
}

cluster := clusterv1a1.Cluster{
TypeMeta: metav1.TypeMeta{
APIVersion: "cluster.k8s.io/v1alpha1",
Kind: "Cluster",
},
ObjectMeta: metav1.ObjectMeta{
Name: installconfig.Config.ObjectMeta.Name,
Namespace: "openshift-cluster-api",
},
Spec: clusterv1a1.ClusterSpec{
ClusterNetwork: *clusterNet,
},
}

c.Raw, err = yaml.Marshal(cluster)
return err
}
4 changes: 2 additions & 2 deletions pkg/asset/manifests/tectonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (t *Tectonic) Dependencies() []asset.Asset {
&installconfig.InstallConfig{},
&tls.IngressCertKey{},
&tls.KubeCA{},
&machines.ClusterK8sIO{},
&ClusterK8sIO{},
&machines.Worker{},
&machines.Master{},
&kubeAddonOperator{},
Expand All @@ -67,7 +67,7 @@ func (t *Tectonic) Dependencies() []asset.Asset {
// Generate generates the respective operator config.yml files
func (t *Tectonic) Generate(dependencies asset.Parents) error {
installConfig := &installconfig.InstallConfig{}
clusterk8sio := &machines.ClusterK8sIO{}
clusterk8sio := &ClusterK8sIO{}
worker := &machines.Worker{}
master := &machines.Master{}
addon := &kubeAddonOperator{}
Expand Down

0 comments on commit 687ff31

Please sign in to comment.