Skip to content

Commit

Permalink
api: adds tls check at flags for https detection
Browse files Browse the repository at this point in the history
its possible only at best effort. https certificates must be valid.

#994
Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Jul 2, 2024
1 parent a5d295b commit 4e0df3c
Show file tree
Hide file tree
Showing 5 changed files with 448 additions and 423 deletions.
3 changes: 2 additions & 1 deletion api/operator/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ func (cr VMAgent) GetNSName() string {
return cr.GetNamespace()
}

// AsURL - returns url for http access
func (cr *VMAgent) AsURL() string {
port := cr.Spec.Port
if port == "" {
Expand All @@ -708,7 +709,7 @@ func (cr *VMAgent) AsURL() string {
}
}
}
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
}

func (cr VMAgent) STSUpdateStrategy() appsv1.StatefulSetUpdateStrategyType {
Expand Down
2 changes: 1 addition & 1 deletion api/operator/v1beta1/vmalert_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func (cr *VMAlert) AsURL() string {
}
}
}
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
}

// AsCRDOwner implements interface
Expand Down
6 changes: 3 additions & 3 deletions api/operator/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ func (cr *VMCluster) VMSelectURL() string {
}
}
}
return fmt.Sprintf("http://%s.%s.svc:%s", cr.Spec.VMSelect.GetNameWithPrefix(cr.Name), cr.Namespace, port)
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.VMSelect.ExtraArgs), cr.Spec.VMSelect.GetNameWithPrefix(cr.Name), cr.Namespace, port)
}

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

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

// AsCRDOwner implements interface
Expand Down
2 changes: 1 addition & 1 deletion api/operator/v1beta1/vmsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (cr *VMSingle) AsURL() string {
}
}
}
return fmt.Sprintf("http://%s.%s.svc:%s", cr.PrefixedName(), cr.Namespace, port)
return fmt.Sprintf("%s://%s.%s.svc:%s", protoFromFlags(cr.Spec.ExtraArgs), cr.PrefixedName(), cr.Namespace, port)
}

// AsCRDOwner implements interface
Expand Down
Loading

0 comments on commit 4e0df3c

Please sign in to comment.