Rename plugin package
This commit is contained in:
		
							parent
							
								
									cb2dfdd28a
								
							
						
					
					
						commit
						1f1947a80b
					
				|  | @ -11,7 +11,7 @@ import ( | |||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/base/resources" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/constants" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/groovy" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugin" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugins" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/log" | ||||
| 
 | ||||
| 	"github.com/bndr/gojenkins" | ||||
|  | @ -148,14 +148,14 @@ func (r *ReconcileJenkinsBaseConfiguration) verifyBasePlugins(jenkinsClient jenk | |||
| 	var installedPlugins []string | ||||
| 	for _, jenkinsPlugin := range allPluginsInJenkins.Raw.Plugins { | ||||
| 		if !jenkinsPlugin.Deleted { | ||||
| 			installedPlugins = append(installedPlugins, plugin.Plugin{Name: jenkinsPlugin.ShortName, Version: jenkinsPlugin.Version}.String()) | ||||
| 			installedPlugins = append(installedPlugins, plugins.Plugin{Name: jenkinsPlugin.ShortName, Version: jenkinsPlugin.Version}.String()) | ||||
| 		} | ||||
| 	} | ||||
| 	r.logger.V(log.VDebug).Info(fmt.Sprintf("Installed plugins '%+v'", installedPlugins)) | ||||
| 
 | ||||
| 	status := true | ||||
| 	for rootPluginName, p := range plugin.BasePluginsMap { | ||||
| 		rootPlugin, _ := plugin.New(rootPluginName) | ||||
| 	for rootPluginName, p := range plugins.BasePluginsMap { | ||||
| 		rootPlugin, _ := plugins.New(rootPluginName) | ||||
| 		if found, ok := isPluginInstalled(allPluginsInJenkins, *rootPlugin); !ok { | ||||
| 			r.logger.V(log.VWarn).Info(fmt.Sprintf("Missing plugin '%s', actual '%+v'", rootPlugin, found)) | ||||
| 			status = false | ||||
|  | @ -171,7 +171,7 @@ func (r *ReconcileJenkinsBaseConfiguration) verifyBasePlugins(jenkinsClient jenk | |||
| 	return status, nil | ||||
| } | ||||
| 
 | ||||
| func isPluginInstalled(plugins *gojenkins.Plugins, requiredPlugin plugin.Plugin) (gojenkins.Plugin, bool) { | ||||
| func isPluginInstalled(plugins *gojenkins.Plugins, requiredPlugin plugins.Plugin) (gojenkins.Plugin, bool) { | ||||
| 	p := plugins.Contains(requiredPlugin.Name) | ||||
| 	if p == nil { | ||||
| 		return gojenkins.Plugin{}, false | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ import ( | |||
| 
 | ||||
| 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/base/resources" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugin" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugins" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/log" | ||||
| 
 | ||||
| 	docker "github.com/docker/distribution/reference" | ||||
|  | @ -49,19 +49,19 @@ func (r *ReconcileJenkinsBaseConfiguration) Validate(jenkins *virtuslabv1alpha1. | |||
| 	return true, nil | ||||
| } | ||||
| 
 | ||||
| func (r *ReconcileJenkinsBaseConfiguration) validatePlugins(plugins map[string][]string) bool { | ||||
| func (r *ReconcileJenkinsBaseConfiguration) validatePlugins(pluginsWithVersions map[string][]string) bool { | ||||
| 	valid := true | ||||
| 	allPlugins := map[string][]plugin.Plugin{} | ||||
| 	allPlugins := map[string][]plugins.Plugin{} | ||||
| 
 | ||||
| 	for rootPluginName, dependentPluginNames := range plugins { | ||||
| 		if _, err := plugin.New(rootPluginName); err != nil { | ||||
| 	for rootPluginName, dependentPluginNames := range pluginsWithVersions { | ||||
| 		if _, err := plugins.New(rootPluginName); err != nil { | ||||
| 			r.logger.V(log.VWarn).Info(fmt.Sprintf("Invalid root plugin name '%s'", rootPluginName)) | ||||
| 			valid = false | ||||
| 		} | ||||
| 
 | ||||
| 		dependentPlugins := []plugin.Plugin{} | ||||
| 		dependentPlugins := []plugins.Plugin{} | ||||
| 		for _, pluginName := range dependentPluginNames { | ||||
| 			if p, err := plugin.New(pluginName); err != nil { | ||||
| 			if p, err := plugins.New(pluginName); err != nil { | ||||
| 				r.logger.V(log.VWarn).Info(fmt.Sprintf("Invalid dependent plugin name '%s' in root plugin '%s'", pluginName, rootPluginName)) | ||||
| 				valid = false | ||||
| 			} else { | ||||
|  | @ -73,7 +73,7 @@ func (r *ReconcileJenkinsBaseConfiguration) validatePlugins(plugins map[string][ | |||
| 	} | ||||
| 
 | ||||
| 	if valid { | ||||
| 		return plugin.VerifyDependencies(allPlugins) | ||||
| 		return plugins.VerifyDependencies(allPlugins) | ||||
| 	} | ||||
| 
 | ||||
| 	return valid | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ import ( | |||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/base" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/user" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/constants" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugin" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugins" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/log" | ||||
| 
 | ||||
| 	"github.com/go-logr/logr" | ||||
|  | @ -207,7 +207,7 @@ func (r *ReconcileJenkins) setDefaults(jenkins *virtuslabv1alpha1.Jenkins, logge | |||
| 	if len(jenkins.Spec.Master.Plugins) == 0 { | ||||
| 		logger.Info("Setting default base plugins") | ||||
| 		changed = true | ||||
| 		jenkins.Spec.Master.Plugins = plugin.BasePlugins() | ||||
| 		jenkins.Spec.Master.Plugins = plugins.BasePlugins() | ||||
| 	} | ||||
| 	_, requestCPUSet := jenkins.Spec.Master.Resources.Requests[corev1.ResourceCPU] | ||||
| 	_, requestMemporySet := jenkins.Spec.Master.Resources.Requests[corev1.ResourceMemory] | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| package plugin | ||||
| package plugins | ||||
| 
 | ||||
| // BasePlugins returns map of plugins to install by operator
 | ||||
| func BasePlugins() (plugins map[string][]string) { | ||||
|  | @ -1,4 +1,4 @@ | |||
| package plugin | ||||
| package plugins | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | @ -1,4 +1,4 @@ | |||
| package plugin | ||||
| package plugins | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | @ -6,7 +6,7 @@ import ( | |||
| 	"testing" | ||||
| 
 | ||||
| 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugin" | ||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/plugins" | ||||
| 
 | ||||
| 	"github.com/bndr/gojenkins" | ||||
| 	framework "github.com/operator-framework/operator-sdk/pkg/test" | ||||
|  | @ -86,8 +86,8 @@ func verifyBasePlugins(t *testing.T, jenkinsClient *gojenkins.Jenkins) { | |||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 
 | ||||
| 	for rootPluginName, p := range plugin.BasePluginsMap { | ||||
| 		rootPlugin, err := plugin.New(rootPluginName) | ||||
| 	for rootPluginName, p := range plugins.BasePluginsMap { | ||||
| 		rootPlugin, err := plugins.New(rootPluginName) | ||||
| 		if err != nil { | ||||
| 			t.Fatal(err) | ||||
| 		} | ||||
|  | @ -104,7 +104,7 @@ func verifyBasePlugins(t *testing.T, jenkinsClient *gojenkins.Jenkins) { | |||
| 	t.Log("Base plugins have been installed") | ||||
| } | ||||
| 
 | ||||
| func isPluginValid(plugins *gojenkins.Plugins, requiredPlugin plugin.Plugin) (*gojenkins.Plugin, bool) { | ||||
| func isPluginValid(plugins *gojenkins.Plugins, requiredPlugin plugins.Plugin) (*gojenkins.Plugin, bool) { | ||||
| 	p := plugins.Contains(requiredPlugin.Name) | ||||
| 	if p == nil { | ||||
| 		return p, false | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue