Code clean up
This commit is contained in:
		
							parent
							
								
									4f29529747
								
							
						
					
					
						commit
						80c5730763
					
				|  | @ -874,6 +874,7 @@ | ||||||
|     "github.com/operator-framework/operator-sdk/version", |     "github.com/operator-framework/operator-sdk/version", | ||||||
|     "github.com/stretchr/testify/assert", |     "github.com/stretchr/testify/assert", | ||||||
|     "k8s.io/api/core/v1", |     "k8s.io/api/core/v1", | ||||||
|  |     "k8s.io/api/rbac/v1", | ||||||
|     "k8s.io/apimachinery/pkg/api/errors", |     "k8s.io/apimachinery/pkg/api/errors", | ||||||
|     "k8s.io/apimachinery/pkg/api/resource", |     "k8s.io/apimachinery/pkg/api/resource", | ||||||
|     "k8s.io/apimachinery/pkg/apis/meta/v1", |     "k8s.io/apimachinery/pkg/apis/meta/v1", | ||||||
|  | @ -885,6 +886,7 @@ | ||||||
|     "k8s.io/apimachinery/pkg/util/wait", |     "k8s.io/apimachinery/pkg/util/wait", | ||||||
|     "k8s.io/client-go/kubernetes/scheme", |     "k8s.io/client-go/kubernetes/scheme", | ||||||
|     "k8s.io/client-go/plugin/pkg/client/auth/gcp", |     "k8s.io/client-go/plugin/pkg/client/auth/gcp", | ||||||
|  |     "k8s.io/client-go/util/workqueue", | ||||||
|     "k8s.io/code-generator/cmd/client-gen", |     "k8s.io/code-generator/cmd/client-gen", | ||||||
|     "k8s.io/code-generator/cmd/conversion-gen", |     "k8s.io/code-generator/cmd/conversion-gen", | ||||||
|     "k8s.io/code-generator/cmd/deepcopy-gen", |     "k8s.io/code-generator/cmd/deepcopy-gen", | ||||||
|  | @ -898,6 +900,7 @@ | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/client/fake", |     "sigs.k8s.io/controller-runtime/pkg/client/fake", | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/controller", |     "sigs.k8s.io/controller-runtime/pkg/controller", | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil", |     "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil", | ||||||
|  |     "sigs.k8s.io/controller-runtime/pkg/event", | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/handler", |     "sigs.k8s.io/controller-runtime/pkg/handler", | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/manager", |     "sigs.k8s.io/controller-runtime/pkg/manager", | ||||||
|     "sigs.k8s.io/controller-runtime/pkg/reconcile", |     "sigs.k8s.io/controller-runtime/pkg/reconcile", | ||||||
|  |  | ||||||
|  | @ -1,5 +1,8 @@ | ||||||
| # Jenkins Operator | # Jenkins Operator | ||||||
| 
 | 
 | ||||||
|  | [](https://travis-ci.org/VirtusLab/jenkins-operator) | ||||||
|  | [](https://goreportcard.com/report/github.com/VirtusLab/jenkins-operator) | ||||||
|  | 
 | ||||||
| ## What's Jenkins Operator? | ## What's Jenkins Operator? | ||||||
| 
 | 
 | ||||||
| Jenkins operator it's a Kubernetes native operator which fully manages Jenkins on Kubernetes. | Jenkins operator it's a Kubernetes native operator which fully manages Jenkins on Kubernetes. | ||||||
|  |  | ||||||
|  | @ -437,7 +437,7 @@ func (r *ReconcileJenkinsBaseConfiguration) baseConfiguration(jenkinsClient jenk | ||||||
| 	hash := sha256.New() | 	hash := sha256.New() | ||||||
| 
 | 
 | ||||||
| 	var keys []string | 	var keys []string | ||||||
| 	for key, _ := range configuration.Data { | 	for key := range configuration.Data { | ||||||
| 		keys = append(keys, key) | 		keys = append(keys, key) | ||||||
| 	} | 	} | ||||||
| 	sort.Strings(keys) | 	sort.Strings(keys) | ||||||
|  |  | ||||||
|  | @ -65,7 +65,7 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *virtuslabv1alpha | ||||||
| 		ObjectMeta: objectMeta, | 		ObjectMeta: objectMeta, | ||||||
| 		Spec: corev1.PodSpec{ | 		Spec: corev1.PodSpec{ | ||||||
| 			ServiceAccountName: objectMeta.Name, | 			ServiceAccountName: objectMeta.Name, | ||||||
| 			RestartPolicy: corev1.RestartPolicyNever, | 			RestartPolicy:      corev1.RestartPolicyNever, | ||||||
| 			SecurityContext: &corev1.PodSecurityContext{ | 			SecurityContext: &corev1.PodSecurityContext{ | ||||||
| 				RunAsUser:  &runAsUser, | 				RunAsUser:  &runAsUser, | ||||||
| 				RunAsGroup: &runAsUser, | 				RunAsGroup: &runAsUser, | ||||||
|  |  | ||||||
|  | @ -15,6 +15,7 @@ const ( | ||||||
| 	updateVerb = "update" | 	updateVerb = "update" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // NewRole returns rbac role for jenkins master
 | ||||||
| func NewRole(meta metav1.ObjectMeta) *v1.Role { | func NewRole(meta metav1.ObjectMeta) *v1.Role { | ||||||
| 	return &v1.Role{ | 	return &v1.Role{ | ||||||
| 		TypeMeta: metav1.TypeMeta{ | 		TypeMeta: metav1.TypeMeta{ | ||||||
|  | @ -48,6 +49,7 @@ func NewRole(meta metav1.ObjectMeta) *v1.Role { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // NewRoleBinding returns rbac role binding for jenkins master
 | ||||||
| func NewRoleBinding(meta metav1.ObjectMeta) *v1.RoleBinding { | func NewRoleBinding(meta metav1.ObjectMeta) *v1.RoleBinding { | ||||||
| 	return &v1.RoleBinding{ | 	return &v1.RoleBinding{ | ||||||
| 		TypeMeta: metav1.TypeMeta{ | 		TypeMeta: metav1.TypeMeta{ | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ import ( | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // NewServiceAccount return kubernetes service account
 | ||||||
| func NewServiceAccount(meta metav1.ObjectMeta) *v1.ServiceAccount { | func NewServiceAccount(meta metav1.ObjectMeta) *v1.ServiceAccount { | ||||||
| 	return &v1.ServiceAccount{ | 	return &v1.ServiceAccount{ | ||||||
| 		TypeMeta: metav1.TypeMeta{ | 		TypeMeta: metav1.TypeMeta{ | ||||||
|  |  | ||||||
|  | @ -219,7 +219,7 @@ func (jobs *Jobs) ensureExpiredBuild(build virtuslabv1alpha1.Build, jenkins *vir | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (jobs *Jobs) removeBuildFromStatus(build virtuslabv1alpha1.Build, jenkins *virtuslabv1alpha1.Jenkins) error { | func (jobs *Jobs) removeBuildFromStatus(build virtuslabv1alpha1.Build, jenkins *virtuslabv1alpha1.Jenkins) error { | ||||||
| 	builds := make([]virtuslabv1alpha1.Build, len(jenkins.Status.Builds), len(jenkins.Status.Builds)) | 	builds := make([]virtuslabv1alpha1.Build, len(jenkins.Status.Builds)) | ||||||
| 	for _, existingBuild := range jenkins.Status.Builds { | 	for _, existingBuild := range jenkins.Status.Builds { | ||||||
| 		if existingBuild.JobName != build.JobName && existingBuild.Hash != build.Hash { | 		if existingBuild.JobName != build.JobName && existingBuild.Hash != build.Hash { | ||||||
| 			builds = append(builds, existingBuild) | 			builds = append(builds, existingBuild) | ||||||
|  |  | ||||||
|  | @ -46,22 +46,20 @@ func VerifyDependencies(values ...map[string][]Plugin) bool { | ||||||
| 	valid := true | 	valid := true | ||||||
| 
 | 
 | ||||||
| 	for _, value := range values { | 	for _, value := range values { | ||||||
| 		if value != nil { | 		for rootPluginNameAndVersion, plugins := range value { | ||||||
| 			for rootPluginNameAndVersion, plugins := range value { | 			if rootPlugin, err := New(rootPluginNameAndVersion); err != nil { | ||||||
| 				if rootPlugin, err := New(rootPluginNameAndVersion); err != nil { | 				valid = false | ||||||
| 					valid = false | 			} else { | ||||||
| 				} else { | 				allPlugins[rootPlugin.Name] = append(allPlugins[rootPlugin.Name], Plugin{ | ||||||
| 					allPlugins[rootPlugin.Name] = append(allPlugins[rootPlugin.Name], Plugin{ | 					Name:                     rootPlugin.Name, | ||||||
| 						Name:                     rootPlugin.Name, | 					Version:                  rootPlugin.Version, | ||||||
| 						Version:                  rootPlugin.Version, | 					rootPluginNameAndVersion: rootPluginNameAndVersion}) | ||||||
| 						rootPluginNameAndVersion: rootPluginNameAndVersion}) | 			} | ||||||
| 				} | 			for _, plugin := range plugins { | ||||||
| 				for _, plugin := range plugins { | 				allPlugins[plugin.Name] = append(allPlugins[plugin.Name], Plugin{ | ||||||
| 					allPlugins[plugin.Name] = append(allPlugins[plugin.Name], Plugin{ | 					Name:                     plugin.Name, | ||||||
| 						Name:                     plugin.Name, | 					Version:                  plugin.Version, | ||||||
| 						Version:                  plugin.Version, | 					rootPluginNameAndVersion: rootPluginNameAndVersion}) | ||||||
| 						rootPluginNameAndVersion: rootPluginNameAndVersion}) |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -1,13 +1,12 @@ | ||||||
| package log | package log | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/go-logr/logr" |  | ||||||
| 	"sigs.k8s.io/controller-runtime/pkg/runtime/log" | 	"sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||||||
| 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Log represents global logger
 | // Log represents global logger
 | ||||||
| var Log logr.Logger = log.Log.WithName("controller-jenkins") | var Log = log.Log.WithName("controller-jenkins") | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| 	// VWarn defines warning log level
 | 	// VWarn defines warning log level
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue