Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

chore: simplify properties. #404

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 16 additions & 80 deletions properties/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,153 +24,89 @@ var (

// GetDownstreamRemoteAddress returns the remote address of the downstream connection.
func GetDownstreamRemoteAddress() (string, error) {
result, err := getPropertyString(sourceAddress)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(sourceAddress)
}

// GetDownstreamRemotePort returns the remote port of the downstream connection.
func GetDownstreamRemotePort() (uint64, error) {
result, err := getPropertyUint64(sourcePort)
if err != nil {
return 0, err
}
return result, nil
return getPropertyUint64(sourcePort)
}

// GetDownstreamLocalAddress returns the local address of the downstream connection.
func GetDownstreamLocalAddress() (string, error) {
result, err := getPropertyString(destinationAddress)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(destinationAddress)
}

// GetDownstreamLocalPort returns the local port of the downstream connection.
func GetDownstreamLocalPort() (uint64, error) {
result, err := getPropertyUint64(destinationPort)
if err != nil {
return 0, err
}
return result, nil
return getPropertyUint64(destinationPort)
}

// GetDownstreamConnectionID returns the connection ID of the downstream connection.
func GetDownstreamConnectionID() (uint64, error) {
result, err := getPropertyUint64(connectionID)
if err != nil {
return 0, err
}
return result, nil
return getPropertyUint64(connectionID)
}

// IsDownstreamConnectionTls returns true if the downstream connection is TLS.
func IsDownstreamConnectionTls() (bool, error) {
result, err := getPropertyBool(connectionMtls)
if err != nil {
return false, err
}
return result, nil
return getPropertyBool(connectionMtls)
}

// GetDownstreamRequestedServerName returns the requested server name of the
// downstream connection.
func GetDownstreamRequestedServerName() (string, error) {
result, err := getPropertyString(connectionRequestedServerName)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionRequestedServerName)
}

// GetDownstreamTlsVersion returns the TLS version of the downstream connection.
func GetDownstreamTlsVersion() (string, error) {
result, err := getPropertyString(connectionTlsVersion)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionTlsVersion)
}

// GetDownstreamSubjectLocalCertificate returns the subject field of the local
// certificate in the downstream TLS connection.
func GetDownstreamSubjectLocalCertificate() (string, error) {
result, err := getPropertyString(connectionSubjectLocalCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionSubjectLocalCert)
}

// GetDownstreamSubjectPeerCertificate returns the subject field of the peer certificate
// in the downstream TLS connection.
func GetDownstreamSubjectPeerCertificate() (string, error) {
result, err := getPropertyString(connectionSubjectPeerCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionSubjectPeerCert)
}

// GetDownstreamDnsSanLocalCertificate returns The first DNS entry in the SAN field of
// the local certificate in the downstream TLS connection.
func GetDownstreamDnsSanLocalCertificate() (string, error) {
result, err := getPropertyString(connectionDnsSanLocalCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionDnsSanLocalCert)
}

// GetDownstreamDnsSanPeerCertificate returns The first DNS entry in the SAN field of the
// peer certificate in the downstream TLS connection.
func GetDownstreamDnsSanPeerCertificate() (string, error) {
result, err := getPropertyString(connectionDnsSanPeerCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionDnsSanPeerCert)
}

// GetDownstreamUriSanLocalCertificate returns the first URI entry in the SAN field of the
// local certificate in the downstream TLS connection
func GetDownstreamUriSanLocalCertificate() (string, error) {
result, err := getPropertyString(connectionUriSanLocalCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionUriSanLocalCert)
}

// GetDownstreamUriSanPeerCertificate returns The first URI entry in the SAN field of the
// peer certificate in the downstream TLS connection.
func GetDownstreamUriSanPeerCertificate() (string, error) {
result, err := getPropertyString(connectionUriSanPeerCert)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionUriSanPeerCert)
}

// GetDownstreamSha256PeerCertificateDigest returns the SHA256 digest of a peer certificate
// digest of the downstream connection.
func GetDownstreamSha256PeerCertificateDigest() (string, error) {
result, err := getPropertyString(connectionSha256PeerCertDigest)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionSha256PeerCertDigest)
}

// GetDownstreamTerminationDetails returns the internal termination details of the connection
// (subject to change).
func GetDownstreamTerminationDetails() (string, error) {
result, err := getPropertyString(connectionTerminationDetails)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(connectionTerminationDetails)
}
108 changes: 18 additions & 90 deletions properties/pilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,33 @@ var (

// GetNodeMetaAnnotations returns the node annotations
func GetNodeMetaAnnotations() (map[string]string, error) {
result, err := getPropertyStringMap(nodeMetaAnnotations)
if err != nil {
return make(map[string]string), err
}
return result, nil
return getPropertyStringMap(nodeMetaAnnotations)
}

// GetNodeMetaAppContainers returns the app containers of the node
func GetNodeMetaAppContainers() (string, error) {
result, err := getPropertyString(nodeMetaAppContainers)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaAppContainers)
}

// GetNodeMetaClusterId returns the cluster ID of the node, which defines the
// cluster the node belongs to
func GetNodeMetaClusterId() (string, error) {
result, err := getPropertyString(nodeMetaClusterId)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaClusterId)
}

// GetNodeMetaEnvoyPrometheusPort returns the Envoy Prometheus port of the node
func GetNodeMetaEnvoyPrometheusPort() (float64, error) {
result, err := getPropertyFloat64(nodeMetaEnvoyPrometheusPort)
if err != nil {
return 0, err
}
return result, nil
return getPropertyFloat64(nodeMetaEnvoyPrometheusPort)
}

// GetNodeMetaEnvoyStatusPort returns the Envoy status port of the node
func GetNodeMetaEnvoyStatusPort() (float64, error) {
result, err := getPropertyFloat64(nodeMetaEnvoyStatusPort)
if err != nil {
return 0, err
}
return result, nil
return getPropertyFloat64(nodeMetaEnvoyStatusPort)
}

// GetNodeMetaInstanceIps returns the instance IPs of the node
func GetNodeMetaInstanceIps() (string, error) {
result, err := getPropertyString(nodeMetaInstanceIps)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaInstanceIps)
}

// GetNodeMetaInterceptionMode returns the interception mode of the node
Expand Down Expand Up @@ -110,109 +86,61 @@ func GetNodeMetaInterceptionMode() (IstioTrafficInterceptionMode, error) {

// GetNodeMetaIstioProxySha returns the Istio proxy SHA of the node
func GetNodeMetaIstioProxySha() (string, error) {
result, err := getPropertyString(nodeMetaIstioProxySha)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaIstioProxySha)
}

// GetNodeMetaIstioVersion returns the Istio version of the node
func GetNodeMetaIstioVersion() (string, error) {
result, err := getPropertyString(nodeMetaIstioVersion)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaIstioVersion)
}

// GetNodeMetaLabels returns the labels of the node
func GetNodeMetaLabels() (map[string]string, error) {
result, err := getPropertyStringMap(nodeMetaLabels)
if err != nil {
return make(map[string]string), err
}
return result, nil
return getPropertyStringMap(nodeMetaLabels)
}

// GetNodeMetaMeshId returns the mesh ID of the node
func GetNodeMetaMeshId() (string, error) {
result, err := getPropertyString(nodeMetaMeshId)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaMeshId)
}

// GetNodeMetaName returns the name of the node
func GetNodeMetaName() (string, error) {
result, err := getPropertyString(nodeMetaName)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaName)
}

// GetNodeMetaNamespace returns the namespace of the node
func GetNodeMetaNamespace() (string, error) {
result, err := getPropertyString(nodeMetaNamespace)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaNamespace)
}

// GetNodeMetaNodeName returns the node name of the node
func GetNodeMetaNodeName() (string, error) {
result, err := getPropertyString(nodeMetaNodeName)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaNodeName)
}

// GetNodeMetaOwner returns the owner of the node (opaque string). Typically, this is the
// owning controller of of the workload instance (ex: k8s deployment for a k8s pod)
func GetNodeMetaOwner() (string, error) {
result, err := getPropertyString(nodeMetaOwner)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaOwner)
}

// GetNodeMetaPilotSan returns the pilot SAN (subject alternate names) of the node's xDS server
func GetNodeMetaPilotSan() ([]string, error) {
result, err := getPropertyStringSlice(nodeMetaPilotSan)
if err != nil {
return make([]string, 0), err
}
return result, nil
return getPropertyStringSlice(nodeMetaPilotSan)
}

// GetNodeMetaPodPorts returns the pod ports of the node. This is used to lookup named ports
func GetNodeMetaPodPorts() (string, error) {
result, err := getPropertyString(nodeMetaPodPorts)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaPodPorts)
}

// GetNodeMetaServiceAccount returns the service account of the node
func GetNodeMetaServiceAccount() (string, error) {
result, err := getPropertyString(nodeMetaServiceAccount)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaServiceAccount)
}

// GetNodeMetaWorkloadName returns the workload name of the node
func GetNodeMetaWorkloadName() (string, error) {
result, err := getPropertyString(nodeMetaWorkloadName)
if err != nil {
return "", err
}
return result, nil
return getPropertyString(nodeMetaWorkloadName)
}
Loading