mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-17 21:35:38 +02:00
Code clean up
This commit is contained in:
@@ -437,7 +437,7 @@ func (r *ReconcileJenkinsBaseConfiguration) baseConfiguration(jenkinsClient jenk
|
||||
hash := sha256.New()
|
||||
|
||||
var keys []string
|
||||
for key, _ := range configuration.Data {
|
||||
for key := range configuration.Data {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
@@ -65,7 +65,7 @@ func NewJenkinsMasterPod(objectMeta metav1.ObjectMeta, jenkins *virtuslabv1alpha
|
||||
ObjectMeta: objectMeta,
|
||||
Spec: corev1.PodSpec{
|
||||
ServiceAccountName: objectMeta.Name,
|
||||
RestartPolicy: corev1.RestartPolicyNever,
|
||||
RestartPolicy: corev1.RestartPolicyNever,
|
||||
SecurityContext: &corev1.PodSecurityContext{
|
||||
RunAsUser: &runAsUser,
|
||||
RunAsGroup: &runAsUser,
|
||||
|
||||
@@ -15,6 +15,7 @@ const (
|
||||
updateVerb = "update"
|
||||
)
|
||||
|
||||
// NewRole returns rbac role for jenkins master
|
||||
func NewRole(meta metav1.ObjectMeta) *v1.Role {
|
||||
return &v1.Role{
|
||||
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 {
|
||||
return &v1.RoleBinding{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// NewServiceAccount return kubernetes service account
|
||||
func NewServiceAccount(meta metav1.ObjectMeta) *v1.ServiceAccount {
|
||||
return &v1.ServiceAccount{
|
||||
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 {
|
||||
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 {
|
||||
if existingBuild.JobName != build.JobName && existingBuild.Hash != build.Hash {
|
||||
builds = append(builds, existingBuild)
|
||||
|
||||
@@ -46,22 +46,20 @@ func VerifyDependencies(values ...map[string][]Plugin) bool {
|
||||
valid := true
|
||||
|
||||
for _, value := range values {
|
||||
if value != nil {
|
||||
for rootPluginNameAndVersion, plugins := range value {
|
||||
if rootPlugin, err := New(rootPluginNameAndVersion); err != nil {
|
||||
valid = false
|
||||
} else {
|
||||
allPlugins[rootPlugin.Name] = append(allPlugins[rootPlugin.Name], Plugin{
|
||||
Name: rootPlugin.Name,
|
||||
Version: rootPlugin.Version,
|
||||
rootPluginNameAndVersion: rootPluginNameAndVersion})
|
||||
}
|
||||
for _, plugin := range plugins {
|
||||
allPlugins[plugin.Name] = append(allPlugins[plugin.Name], Plugin{
|
||||
Name: plugin.Name,
|
||||
Version: plugin.Version,
|
||||
rootPluginNameAndVersion: rootPluginNameAndVersion})
|
||||
}
|
||||
for rootPluginNameAndVersion, plugins := range value {
|
||||
if rootPlugin, err := New(rootPluginNameAndVersion); err != nil {
|
||||
valid = false
|
||||
} else {
|
||||
allPlugins[rootPlugin.Name] = append(allPlugins[rootPlugin.Name], Plugin{
|
||||
Name: rootPlugin.Name,
|
||||
Version: rootPlugin.Version,
|
||||
rootPluginNameAndVersion: rootPluginNameAndVersion})
|
||||
}
|
||||
for _, plugin := range plugins {
|
||||
allPlugins[plugin.Name] = append(allPlugins[plugin.Name], Plugin{
|
||||
Name: plugin.Name,
|
||||
Version: plugin.Version,
|
||||
rootPluginNameAndVersion: rootPluginNameAndVersion})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user