-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
@@ -41,7 +41,6 @@ import ( | |||
|
|||
const ( | |||
autoscalingListenerContainerName = "autoscaler" | |||
autoscalingListenerOwnerKey = ".metadata.controller" |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
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.