7a5c8dc1eb
* copyright headers for agent folder * Ignore test data files * fix proto files and remove headers in agent/uiserver folder * ignore deep-copy files * copyright headers for agent folder * Copyright headers for command folder * fix merge conflicts
30 lines
785 B
Go
30 lines
785 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package intention
|
|
|
|
import (
|
|
"github.com/hashicorp/consul/api"
|
|
)
|
|
|
|
// FormatSource returns the namespace/name format for the source. This is
|
|
// different from (*api.Intention).SourceString in that the default namespace
|
|
// is not omitted.
|
|
func FormatSource(i *api.Intention) string {
|
|
return partString(i.SourceNS, i.SourceName)
|
|
}
|
|
|
|
// FormatDestination returns the namespace/name format for the destination.
|
|
// This is different from (*api.Intention).DestinationString in that the
|
|
// default namespace is not omitted.
|
|
func FormatDestination(i *api.Intention) string {
|
|
return partString(i.DestinationNS, i.DestinationName)
|
|
}
|
|
|
|
func partString(ns, n string) string {
|
|
if ns == "" {
|
|
return n
|
|
}
|
|
return ns + "/" + n
|
|
}
|