-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from phillc/master
Remove deprecated annotation for tls and protocol
- Loading branch information
Showing
6 changed files
with
20 additions
and
1,419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,5 @@ | ||
package linode | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
const ( | ||
annLinodeProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-protocol" | ||
annLinodeLoadBalancerTLSDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-tls" | ||
annLinodeProxyProtocol = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol" | ||
annLinodeProxyProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol" | ||
) | ||
|
||
type tlsAnnotationDeprecated struct { | ||
TLSSecretName string `json:"tls-secret-name"` | ||
Port int `json:"port"` | ||
} | ||
|
||
func tryDeprecatedTLSAnnotation(service *v1.Service, port int) (portConfigAnnotation, error) { | ||
annotation := portConfigAnnotation{} | ||
tlsAnnotation, err := getTLSAnnotationDeprecated(service, port) | ||
if err != nil { | ||
return annotation, err | ||
} | ||
|
||
if tlsAnnotation != nil { | ||
annotation.Protocol = "https" | ||
annotation.TLSSecretName = tlsAnnotation.TLSSecretName | ||
} else if protocol, ok := service.Annotations[annLinodeProtocolDeprecated]; ok { | ||
annotation.Protocol = protocol | ||
} | ||
return annotation, nil | ||
} | ||
|
||
func getTLSAnnotationDeprecated(service *v1.Service, port int) (*tlsAnnotationDeprecated, error) { | ||
annotationJSON, ok := service.Annotations[annLinodeLoadBalancerTLSDeprecated] | ||
if !ok { | ||
return nil, nil | ||
} | ||
tlsAnnotations := make([]*tlsAnnotationDeprecated, 0) | ||
err := json.Unmarshal([]byte(annotationJSON), &tlsAnnotations) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, tlsAnnotation := range tlsAnnotations { | ||
if tlsAnnotation.Port == port { | ||
return tlsAnnotation, nil | ||
} | ||
} | ||
return nil, nil | ||
} |
Oops, something went wrong.