Skip to content

Commit

Permalink
Re-vendor for openshift/cluster-api#40
Browse files Browse the repository at this point in the history
Also fix build after new cluster-api vendor
  • Loading branch information
mandre committed Jun 13, 2019
1 parent 5fdea0b commit 97a1434
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ required = [

[[override]]
name = "github.com/openshift/cluster-api"
branch = "openshift-4.0-cluster-api-0.0.0-alpha.4"
branch = "openshift-4.2-cluster-api-0.0.0-alpha.4"

[[override]]
name = "k8s.io/code-generator"
Expand Down
5 changes: 3 additions & 2 deletions pkg/cloud/openstack/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

clustercommon "github.com/openshift/cluster-api/pkg/apis/cluster/common"
clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1"
machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
"github.com/openshift/cluster-api/pkg/util"
"k8s.io/klog"
Expand All @@ -45,7 +46,7 @@ func NewDeploymentClient() *DeploymentClient {
return &DeploymentClient{}
}

func (*DeploymentClient) GetIP(cluster *machinev1.Cluster, machine *machinev1.Machine) (string, error) {
func (*DeploymentClient) GetIP(cluster *clusterv1.Cluster, machine *machinev1.Machine) (string, error) {
if machine.ObjectMeta.Annotations != nil {
if ip, ok := machine.ObjectMeta.Annotations[OpenstackIPAnnotationKey]; ok {
klog.Infof("Returning IP from machine annotation %s", ip)
Expand All @@ -56,7 +57,7 @@ func (*DeploymentClient) GetIP(cluster *machinev1.Cluster, machine *machinev1.Ma
return "", errors.New("could not get IP")
}

func (d *DeploymentClient) GetKubeConfig(cluster *machinev1.Cluster, master *machinev1.Machine) (string, error) {
func (d *DeploymentClient) GetKubeConfig(cluster *clusterv1.Cluster, master *machinev1.Machine) (string, error) {
ip, err := d.GetIP(cluster, master)
if err != nil {
return "", err
Expand Down
18 changes: 11 additions & 7 deletions pkg/cloud/openstack/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"k8s.io/apimachinery/pkg/api/equality"

clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1"
machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
apierrors "github.com/openshift/cluster-api/pkg/errors"
"github.com/openshift/cluster-api/pkg/util"
Expand Down Expand Up @@ -86,7 +87,7 @@ func getTimeout(name string, timeout int) time.Duration {
return time.Duration(timeout)
}

func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error {
func (oc *OpenstackClient) Create(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error {
if cluster == nil {
return fmt.Errorf("The cluster is nil, check your cluster configuration")
}
Expand Down Expand Up @@ -154,7 +155,9 @@ func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluste

var userDataRendered string
if len(userData) > 0 && !disableTemplating {
if machine.Spec.Versions.ControlPlane != "" {
// if machine.Spec.Versions.ControlPlane != "" {
// FIXME(mandre) not sure this is right
if machine.ObjectMeta.Name != "" {
userDataRendered, err = masterStartupScript(cluster, machine, string(userData))
if err != nil {
return oc.handleMachineError(machine, apierrors.CreateMachine(
Expand Down Expand Up @@ -251,7 +254,7 @@ func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluste
return oc.updateAnnotation(machine, instance.ID)
}

func (oc *OpenstackClient) Delete(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error {
func (oc *OpenstackClient) Delete(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error {
machineService, err := clients.NewInstanceServiceFromMachine(oc.params.KubeClient, machine)
if err != nil {
return err
Expand All @@ -277,7 +280,7 @@ func (oc *OpenstackClient) Delete(ctx context.Context, cluster *machinev1.Cluste
return nil
}

func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error {
func (oc *OpenstackClient) Update(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error {
if cluster == nil {
return fmt.Errorf("The cluster is nil, check your cluster configuration")
}
Expand Down Expand Up @@ -305,7 +308,9 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluste
return nil
}

if currentMachine.Spec.Versions.ControlPlane != "" {
// if currentMachine.Spec.Versions.ControlPlane != "" {
// FIXME(mandre) not sure this is right
if currentMachine.ObjectMeta.Name != "" {
// TODO: add master inplace
klog.Errorf("master inplace update failed: not support master in place update now")
} else {
Expand Down Expand Up @@ -339,7 +344,7 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluste
return nil
}

func (oc *OpenstackClient) Exists(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) (bool, error) {
func (oc *OpenstackClient) Exists(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) (bool, error) {
instance, err := oc.instanceExists(machine)
if err != nil {
return false, err
Expand Down Expand Up @@ -447,7 +452,6 @@ func (oc *OpenstackClient) requiresUpdate(a *machinev1.Machine, b *machinev1.Mac
// Do not want status changes. Do want changes that impact machine provisioning
return !reflect.DeepEqual(a.Spec.ObjectMeta, b.Spec.ObjectMeta) ||
!reflect.DeepEqual(a.Spec.ProviderSpec, b.Spec.ProviderSpec) ||
!reflect.DeepEqual(a.Spec.Versions, b.Spec.Versions) ||
a.ObjectMeta.Name != b.ObjectMeta.Name
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/cloud/openstack/machine/machineScript.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import (

"fmt"

clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1"
machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
openstackconfigv1 "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1"
)

type setupParams struct {
Token string
Cluster *machinev1.Cluster
Cluster *clusterv1.Cluster
Machine *machinev1.Machine
MachineSpec *openstackconfigv1.OpenstackProviderSpec

Expand All @@ -41,7 +42,7 @@ type setupParams struct {
func init() {
}

func masterStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, script string) (string, error) {
func masterStartupScript(cluster *clusterv1.Cluster, machine *machinev1.Machine, script string) (string, error) {
machineSpec, err := openstackconfigv1.MachineSpecFromProviderSpec(machine.Spec.ProviderSpec)
if err != nil {
return "", err
Expand All @@ -67,7 +68,7 @@ func masterStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine,
return buf.String(), nil
}

func nodeStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, token, script string) (string, error) {
func nodeStartupScript(cluster *clusterv1.Cluster, machine *machinev1.Machine, token, script string) (string, error) {
machineSpec, err := openstackconfigv1.MachineSpecFromProviderSpec(machine.Spec.ProviderSpec)
if err != nil {
return "", err
Expand Down Expand Up @@ -104,12 +105,12 @@ func nodeStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, t
return buf.String(), nil
}

func getEndpoint(apiEndpoint machinev1.APIEndpoint) string {
func getEndpoint(apiEndpoint clusterv1.APIEndpoint) string {
return fmt.Sprintf("%s:%d", apiEndpoint.Host, apiEndpoint.Port)
}

// Just a temporary hack to grab a single range from the config.
func getSubnet(netRange machinev1.NetworkRanges) string {
func getSubnet(netRange clusterv1.NetworkRanges) string {
if len(netRange.CIDRBlocks) == 0 {
return ""
}
Expand Down
15 changes: 13 additions & 2 deletions vendor/github.com/openshift/cluster-api/cmd/manager/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97a1434

Please sign in to comment.