Skip to content

Commit a3978ae

Browse files
committed
fix: implement review feedback for configurable ports
Signed-off-by: Jared Watts <[email protected]>
1 parent 1948ce1 commit a3978ae

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

cmd/crossplane/core/core.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ type startCommand struct {
103103
MaxReconcileRate int `default:"100" help:"The global maximum rate per second at which resources may checked for drift from the desired state."`
104104
MaxConcurrentPackageEstablishers int `default:"10" help:"The the maximum number of goroutines to use for establishing Providers, Configurations and Functions."`
105105

106-
WebhookEnabled bool `default:"true" env:"WEBHOOK_ENABLED" help:"Enable webhook configuration."`
106+
WebhookEnabled bool `default:"true" env:"WEBHOOK_ENABLED" help:"Enable webhook configuration."`
107107
AutomaticDependencyDowngradeEnabled bool `default:"false" env:"AUTOMATIC_DEPENDENCY_DOWNGRADE_ENABLED" help:"Enable automatic dependency version downgrades. This configuration requires the 'EnableDependencyVersionUpgrades' feature flag to be enabled."`
108108

109-
WebhookPort int `default:"9443" env:"WEBHOOK_PORT" help:"The port the webhook server listens on."`
110-
MetricsPort int `default:"8080" env:"METRICS_PORT" help:"The port the metrics server listens on."`
109+
WebhookPort int `default:"9443" env:"WEBHOOK_PORT" help:"The port the webhook server listens on."`
110+
MetricsPort int `default:"8080" env:"METRICS_PORT" help:"The port the metrics server listens on."`
111111
HealthProbePort int `default:"8081" env:"HEALTH_PROBE_PORT" help:"The port the health probe endpoint listens on."`
112112

113113
TLSServerSecretName string `env:"TLS_SERVER_SECRET_NAME" help:"The name of the TLS Secret that will store Crossplane's server certificate."`

internal/controller/pkg/revision/runtime_defaults.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,16 @@ func deploymentFromRuntimeConfig(tmpl *v1beta1.DeploymentTemplate) *appsv1.Deplo
6565
func serviceFromRuntimeConfig(tmpl *v1beta1.ServiceTemplate) *corev1.Service {
6666
svc := &corev1.Service{}
6767

68-
if tmpl == nil {
68+
if tmpl == nil || tmpl.Metadata == nil {
6969
return svc
7070
}
7171

72-
if meta := tmpl.Metadata; meta != nil {
73-
if meta.Name != nil {
74-
svc.Name = *meta.Name
75-
}
76-
77-
svc.Annotations = meta.Annotations
78-
svc.Labels = meta.Labels
72+
if tmpl.Metadata.Name != nil {
73+
svc.Name = *tmpl.Metadata.Name
7974
}
8075

76+
svc.Annotations = tmpl.Metadata.Annotations
77+
svc.Labels = tmpl.Metadata.Labels
78+
8179
return svc
8280
}

internal/controller/pkg/revision/runtime_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ func TestRuntimeManifestBuilderService(t *testing.T) {
473473
want want
474474
}{
475475
"ProviderServiceNoRuntimeConfig": {
476-
reason: "No overrides should result in a deployment with default values",
476+
reason: "No runtime config on the builder should result in a service with default values",
477477
args: args{
478478
builder: &RuntimeManifestBuilder{
479479
revision: providerRevision,
@@ -484,10 +484,10 @@ func TestRuntimeManifestBuilderService(t *testing.T) {
484484
ServiceWithSelectors(providerSelectors(&pkgmetav1.Provider{ObjectMeta: metav1.ObjectMeta{Name: providerMetaName}}, providerRevision)),
485485
ServiceWithAdditionalPorts([]corev1.ServicePort{
486486
{
487-
Name: grpcPortName,
487+
Name: webhookPortName,
488488
Protocol: corev1.ProtocolTCP,
489489
Port: servicePort,
490-
TargetPort: intstr.FromString(grpcPortName),
490+
TargetPort: intstr.FromString(webhookPortName),
491491
},
492492
}),
493493
},
@@ -514,9 +514,9 @@ func TestRuntimeManifestBuilderService(t *testing.T) {
514514
},
515515
Ports: []corev1.ServicePort{
516516
{
517-
Name: grpcPortName,
517+
Name: webhookPortName,
518518
Port: int32(servicePort),
519-
TargetPort: intstr.FromString(grpcPortName),
519+
TargetPort: intstr.FromString(webhookPortName),
520520
Protocol: corev1.ProtocolTCP,
521521
},
522522
},

0 commit comments

Comments
 (0)