func (c *Config) GetInjectionConfig(key string) (*InjectionConfig, error) {
	c.RLock()
	defer c.RUnlock()
	name, version, err := configNameFields(key)
	if err != nil {
		return nil, err
	}
	fullKey := canonicalizeConfigName(name, version)
	i, ok := c.Injections[fullKey]
	if !ok {
		return nil, fmt.Errorf("no injection config found for annotation %s", fullKey)
	}
	return i, nil
}
GetInjectionConfig returns the InjectionConfig given a requested key
package config
import (
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"github.com/ghodss/yaml"
	"github.com/golang/glog"
	corev1 "k8s.io/api/core/v1"
)
const (
	annotationNamespaceDefault = "injector.tumblr.com"
	defaultVersion             = "latest"
)
var (
	ErrMissingName = fmt.Errorf(`name field is required for an injection config`)
	ErrNoConfigurationLoaded = fmt.Errorf(`at least one config must be present in the --config-directory`)
	ErrCannotMergeNilInjectionConfig = fmt.Errorf("cannot merge nil InjectionConfig")
	ErrUnsupportedNameVersionFormat = fmt.Errorf(`not a valid name or name:version format`)
)
type InjectionConfig struct {
	Name               string               `json:"name"`
	Inherits           string               `json:"inherits"`
	Containers         []corev1.Container   `json:"containers"`
	Volumes            []corev1.Volume      `json:"volumes"`
	Environment        []corev1.EnvVar      `json:"env"`
	VolumeMounts       []corev1.VolumeMount `json:"volumeMounts"`
	HostAliases        []corev1.HostAlias   `json:"hostAliases"`
	HostNetwork        bool                 `json:"hostNetwork"`
	HostPID            bool                 `json:"hostPID"`
	InitContainers     []corev1.Container   `json:"initContainers"`
	ServiceAccountName string               `json:"serviceAccountName"`
	version string
}
type Config struct {
	sync.RWMutex
	AnnotationNamespace string                      `yaml:"annotationnamespace"`
	Injections          map[string]*InjectionConfig `yaml:"injections"`
}
func (c *InjectionConfig) String() string {
	inheritsString := ""
	if c.Inherits != "" {
		inheritsString = fmt.Sprintf(" (inherits %s)", c.Inherits)
	}
	saString := ""
	if c.ServiceAccountName != "" {
		saString = fmt.Sprintf(", serviceAccountName %s", c.ServiceAccountName)
	}
	return fmt.Sprintf("%s%s: %d containers, %d init containers, %d volumes, %d environment vars, %d volume mounts, %d host aliases%s",
		c.FullName(),
		inheritsString,
		len(c.Containers),
		len(c.InitContainers),
		len(c.Volumes),
		len(c.Environment),
		len(c.VolumeMounts),
		len(c.HostAliases),
		saString)
}
func (c *InjectionConfig) Version() string {
	if c.version == "" {
		return defaultVersion
	}
	return c.version
}
func (c *InjectionConfig) FullName() string {
	return canonicalizeConfigName(c.Name, c.Version())
}
func (c *Config) ReplaceInjectionConfigs(replacementConfigs []*InjectionConfig) {
	c.Lock()
	defer c.Unlock()
	c.Injections = map[string]*InjectionConfig{}
	for _, r := range replacementConfigs {
		c.Injections[r.FullName()] = r
	}
}
func (c *Config) HasInjectionConfig(key string) bool {
	c.RLock()
	defer c.RUnlock()
	name, version, err := configNameFields(key)
	if err != nil {
		return false
	}
	fullKey := canonicalizeConfigName(name, version)
	_, ok := c.Injections[fullKey]
	return ok
}