Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reordering methods and constants so it is easier to look it up #2501

Merged
merged 3 commits into from
Apr 12, 2023

Conversation

nikola-jokic
Copy link
Member

The purpose of this change is not to add any new functionality, but to make code easier to follow, remove some repetition and document the finalizer protecting resources.

@@ -41,7 +41,6 @@ import (

const (
autoscalingListenerContainerName = "autoscaler"
autoscalingListenerOwnerKey = ".metadata.controller"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to constants since the owner key is a field selector

@@ -246,65 +245,6 @@ func (r *AutoscalingListenerReconciler) Reconcile(ctx context.Context, req ctrl.
return ctrl.Result{}, nil
}

// SetupWithManager sets up the controller with the Manager.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to be the last method on the reconciler, just like for rest of the reconcilers

@@ -42,13 +42,10 @@ import (
)

const (
// TODO: Replace with shared image.
autoscalingRunnerSetOwnerKey = ".metadata.controller"
LabelKeyRunnerSpecHash = "runner-spec-hash"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed TODO and unexported LabelKeyRunnerSpecHash since it is only used in autoscalingrunnerset_controller

@@ -16,3 +18,47 @@ const (
EnvVarHTTPSProxy = "https_proxy"
EnvVarNoProxy = "no_proxy"
)

// Labels applied to resources
const (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved label constants from resource builder to constants where I think is more appropriate

@@ -84,6 +48,62 @@ func SetListenerImagePullPolicy(pullPolicy string) bool {

type resourceBuilder struct{}

func (b *resourceBuilder) newAutoScalingListener(autoscalingRunnerSet *v1alpha1.AutoscalingRunnerSet, ephemeralRunnerSet *v1alpha1.EphemeralRunnerSet, namespace, image string, imagePullSecrets []corev1.LocalObjectReference) (*v1alpha1.AutoscalingListener, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordered methods so that newX is close to its related methods.
It should follow the order of creation: listener, listener resources, ephemeral runner set, ephemeral runner, ephemeral runner resources...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no real code change other than moving methods around? (maybe changes to use new const)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes in the code logic, only renames in case I exported finalizer so it is documented in godoc if someone looks at the api there

I only moved things around and for 2 constants changed the visibility

@nikola-jokic nikola-jokic merged commit ba1ac09 into master Apr 12, 2023
13 checks passed
@nikola-jokic nikola-jokic deleted the nikola-jokic/reorder-code branch April 12, 2023 07:50
@Link- Link- added the gha-runner-scale-set Related to the gha-runner-scale-set mode label Jul 28, 2023
@Link- Link- added this to the gha-runner-scale-set-0.5.0 milestone Jul 28, 2023
@Link- Link- mentioned this pull request Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gha-runner-scale-set Related to the gha-runner-scale-set mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants