Skip to content

Commit 6e2822c

Browse files
authored
api: adds tls check at flags for https detection (#1005)
its possible only at best effort. https certificates must be valid. #994 Signed-off-by: f41gh7 <[email protected]>
1 parent a5d295b commit 6e2822c

File tree

5 files changed

+448
-423
lines changed

5 files changed

+448
-423
lines changed

api/operator/v1beta1/vmagent_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ func (cr VMAgent) GetNSName() string {
695695
return cr.GetNamespace()
696696
}
697697

698+
// AsURL - returns url for http access
698699
func (cr *VMAgent) AsURL() string {
699700
port := cr.Spec.Port
700701
if port == "" {
@@ -708,7 +709,7 @@ func (cr *VMAgent) AsURL() string {
708709
}
709710
}
710711
}
711-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
712+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
712713
}
713714

714715
func (cr VMAgent) STSUpdateStrategy() appsv1.StatefulSetUpdateStrategyType {

api/operator/v1beta1/vmalert_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func (cr *VMAlert) AsURL() string {
533533
}
534534
}
535535
}
536-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
536+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
537537
}
538538

539539
// AsCRDOwner implements interface

api/operator/v1beta1/vmcluster_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ func (cr *VMCluster) VMSelectURL() string {
10831083
}
10841084
}
10851085
}
1086-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.Spec.VMSelect.GetNameWithPrefix(cr.Name), cr.Namespace, port)
1086+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.VMSelect.ExtraArgs), cr.Spec.VMSelect.GetNameWithPrefix(cr.Name), cr.Namespace, port)
10871087
}
10881088

10891089
func (cr *VMCluster) VMInsertURL() string {
@@ -1101,7 +1101,7 @@ func (cr *VMCluster) VMInsertURL() string {
11011101
}
11021102
}
11031103
}
1104-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.Spec.VMInsert.GetNameWithPrefix(cr.Name), cr.Namespace, port)
1104+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.VMSelect.ExtraArgs), cr.Spec.VMInsert.GetNameWithPrefix(cr.Name), cr.Namespace, port)
11051105
}
11061106

11071107
func (cr *VMCluster) VMStorageURL() string {
@@ -1119,7 +1119,7 @@ func (cr *VMCluster) VMStorageURL() string {
11191119
}
11201120
}
11211121
}
1122-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.Spec.VMStorage.GetNameWithPrefix(cr.Name), cr.Namespace, port)
1122+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.VMSelect.ExtraArgs), cr.Spec.VMStorage.GetNameWithPrefix(cr.Name), cr.Namespace, port)
11231123
}
11241124

11251125
// AsCRDOwner implements interface

api/operator/v1beta1/vmsingle_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func (cr *VMSingle) AsURL() string {
387387
}
388388
}
389389
}
390-
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
390+
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
391391
}
392392

393393
// AsCRDOwner implements interface

0 commit comments

Comments
 (0)