Exemple #1
0
func getConfig(in io.Reader) (*overridesapi.BuildOverridesConfig, error) {
	overridesConfig := &overridesapi.BuildOverridesConfig{}
	err := buildadmission.ReadPluginConfig(in, overridesConfig)
	if err != nil {
		return nil, err
	}
	errs := validation.ValidateBuildOverridesConfig(overridesConfig)
	if len(errs) > 0 {
		return nil, errs.ToAggregate()
	}
	return overridesConfig, nil
}
Exemple #2
0
// NewBuildOverrides creates a new BuildOverrides that will apply the overrides specified in the plugin config
func NewBuildOverrides(pluginConfig map[string]configapi.AdmissionPluginConfig) (BuildOverrides, error) {
	config := &overridesapi.BuildOverridesConfig{}
	err := buildadmission.ReadPluginConfig(pluginConfig, overridesapi.BuildOverridesPlugin, config)
	if err != nil {
		return BuildOverrides{}, err
	}
	errs := validation.ValidateBuildOverridesConfig(config)
	if len(errs) > 0 {
		return BuildOverrides{}, errs.ToAggregate()
	}
	glog.V(4).Infof("Initialized build overrides plugin with config: %#v", *config)
	return BuildOverrides{config: config}, nil
}