func NewBareMetalMachineScope(params BareMetalMachineScopeParams) (*BareMetalMachineScope, error) {
	if params.Machine == nil {
		return nil, errors.New("failed to generate new scope from nil Machine")
	}
	if params.BareMetalMachine == nil {
		return nil, errors.New("failed to generate new scope from nil BareMetalMachine")
	}
	cs, err := NewClusterScope(params.ClusterScopeParams)
	if err != nil {
		return nil, errors.Wrap(err, "failed to init patch helper")
	}
	cs.patchHelper, err = patch.NewHelper(params.BareMetalMachine, params.Client)
	if err != nil {
		return nil, errors.Wrap(err, "failed to init patch helper")
	}
	return &BareMetalMachineScope{
		ClusterScope:     *cs,
		Machine:          params.Machine,
		BareMetalMachine: params.BareMetalMachine,
	}, nil
}
NewClusterScope creates a new Scope from the supplied parameters.
This is meant to be called for each reconcile iteration.
package scope
import (
	"context"
	infrav1 "github.com/cluster-api-provider-hcloud/cluster-api-provider-hcloud/api/v1alpha3"
	"github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/utils/pointer"
	clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
	capierrors "sigs.k8s.io/cluster-api/errors"
	"sigs.k8s.io/cluster-api/util/patch"
)
type BareMetalMachineScopeParams struct {
	ClusterScopeParams
	Machine          *clusterv1.Machine
	BareMetalMachine *infrav1.BareMetalMachine
}