Skip to content

Commit

Permalink
More comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Nov 5, 2024
1 parent 86b8c32 commit b96b96e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions internal/contract/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ type Int32 struct {
paths []Path
}

// Path returns the path to the int64 value.
// Path returns the path to the int32 value.
func (i *Int32) Path() []Path {
return i.paths
}

// Get gets the int64 value.
// Get gets the int32 value.
// If more than one path is defined, path are checked in order and the first value reported is used
// (e.g. in case when we are reading from a preferred location first, and then from one or more fallback locations).
func (i *Int32) Get(obj *unstructured.Unstructured) (*int32, error) {
paths := []string{}
for _, path := range i.paths {
Expand All @@ -130,7 +132,10 @@ func (i *Int32) Get(obj *unstructured.Unstructured) (*int32, error) {
return nil, errors.Wrapf(ErrFieldNotFound, "path %s", strings.Join(paths, ", "))
}

// Set sets the int64 value in the path.
// Set sets the int32 value in the path.
// If more than one path is defined, only the first path will be set.
// (the first path is considered the preferred location).
// Note: Cluster API should never Set values on external objects owner by providers; however this method is useful for writing tests.
func (i *Int32) Set(obj *unstructured.Unstructured, value int64) error {
if err := unstructured.SetNestedField(obj.UnstructuredContent(), value, i.paths[0]...); err != nil {
return errors.Wrapf(err, "failed to set path %s of object %v", "."+strings.Join(i.paths[0], "."), obj.GroupVersionKind())
Expand Down
4 changes: 1 addition & 3 deletions internal/controllers/cluster/cluster_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr
// If the infrastructure ref is not set, no-op.
if s.cluster.Spec.InfrastructureRef == nil {
// if the cluster is not deleted, and the cluster is not using a ClusterClass, mark the infrastructure as ready to unblock other provisioning workflows.
// NOTE: if the cluster is not deleted and it is using a ClusterClass, the infrastructure will be set as soon as the topology is reconciled; in this
// case we should wait for the field to be se (and not unblock other provisioning workflows).
if s.cluster.DeletionTimestamp.IsZero() && cluster.Spec.Topology == nil {
if s.cluster.DeletionTimestamp.IsZero() {
cluster.Status.InfrastructureReady = true
conditions.MarkTrue(cluster, clusterv1.InfrastructureReadyCondition)
}
Expand Down

0 comments on commit b96b96e

Please sign in to comment.