Example #1
0
func getConfig(in io.Reader) (*overridesapi.BuildOverridesConfig, error) {
	overridesConfig := &overridesapi.BuildOverridesConfig{}
	err := buildadmission.ReadPluginConfig(in, overridesConfig)
	if err != nil {
		return nil, err
	}
	return overridesConfig, nil
}
Example #2
0
func getConfig(in io.Reader) (*defaultsapi.BuildDefaultsConfig, error) {
	defaultsConfig := &defaultsapi.BuildDefaultsConfig{}
	err := buildadmission.ReadPluginConfig(in, defaultsConfig)
	if err != nil {
		return nil, err
	}
	errs := validation.ValidateBuildDefaultsConfig(defaultsConfig)
	if len(errs) > 0 {
		return nil, errs.ToAggregate()
	}
	return defaultsConfig, nil
}
Example #3
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
}
Example #4
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
}