func (ids WorkloadEndpointIdentifiers) CalculateWorkloadEndpointName(allowPrefix bool) (string, error) {
	req, err := ids.getSegments()
	if err != nil {
		return "", err
	}
	parts := []string{}
	for _, s := range req {
		part := ""
		if len(s.value) == 0 {
			if !allowPrefix {
				return "", cerrors.ErrorValidation{
					ErroredFields: []cerrors.ErroredField{
						{Name: s.field, Value: s.value, Reason: "field should be assigned"},
					},
				}
			}
			return strings.Join(parts, "-") + "-", nil
		}
		part, ef := escapeDashes(s)
		if ef != nil {
			return "", cerrors.ErrorValidation{ErroredFields: []cerrors.ErroredField{*ef}}
		}
		parts = append(parts, part)
	}
	return strings.Join(parts, "-"), nil
}
CalculateWorkloadEndpointName calculates the expected name for a workload
endpoint given the supplied Spec.  Calico requires a precise naming convention
for workload endpoints that is based on orchestrator and various other orchestrator
specific parameters.

If allowPrefix is true, we construct the name prefix up to the last specified index
and terminate with a dash.
package names
import (
	"errors"
	"fmt"
	"reflect"
	"strings"
	cerrors "github.com/projectcalico/libcalico-go/lib/errors"
)
type WorkloadEndpointIdentifiers struct {
	Node         string
	Orchestrator string
	Endpoint     string
	Workload     string
	Pod          string
	ContainerID  string
}
func (ids WorkloadEndpointIdentifiers) NameMatches(name string) (bool, error) {
	req, err := ids.getSegments()
	if err != nil {
		return false, err
	}
	parts := ExtractDashSeparatedParms(name, len(req))
	if len(parts) == 0 {
		return false, nil
	}
	for i, r := range req {
		if r.value != "" && r.value != parts[i] {
			return false, nil
		}
	}
	return true, nil
}