Refactoring, additional tests and update README.md
This commit is contained in:
		
							parent
							
								
									e7c55512a8
								
							
						
					
					
						commit
						70aef4838b
					
				|  | @ -105,6 +105,7 @@ User configuration: | ||||||
| * ~~user reconciliation loop with CR validation~~ | * ~~user reconciliation loop with CR validation~~ | ||||||
| * ~~configure seed jobs and deploy keys~~ | * ~~configure seed jobs and deploy keys~~ | ||||||
| * ~~e2e tests for seed jobs~~ | * ~~e2e tests for seed jobs~~ | ||||||
|  | * configure Jenkins authorization (via configuration as a code plugin or groovy scripts) | ||||||
| * backup and restore for Jenkins jobs running as standalone job | * backup and restore for Jenkins jobs running as standalone job | ||||||
| * trigger backup job before pod deletion using preStop k8s hooks | * trigger backup job before pod deletion using preStop k8s hooks | ||||||
| * verify Jenkins configuration events | * verify Jenkins configuration events | ||||||
|  |  | ||||||
|  | @ -2,21 +2,25 @@ package user | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" |  | ||||||
| 	"strings" |  | ||||||
| 
 |  | ||||||
| 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" |  | ||||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/log" |  | ||||||
| 
 |  | ||||||
| 	"crypto/x509" | 	"crypto/x509" | ||||||
| 	"encoding/pem" | 	"encoding/pem" | ||||||
|  | 	"fmt" | ||||||
|  | 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" | ||||||
|  | 	"github.com/VirtusLab/jenkins-operator/pkg/log" | ||||||
| 	"k8s.io/api/core/v1" | 	"k8s.io/api/core/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
|  | 	"strings" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Validate validates Jenkins CR Spec section
 | // Validate validates Jenkins CR Spec section
 | ||||||
| func (r *ReconcileUserConfiguration) Validate(jenkins *virtuslabv1alpha1.Jenkins) bool { | func (r *ReconcileUserConfiguration) Validate(jenkins *virtuslabv1alpha1.Jenkins) bool { | ||||||
| 	// validate jenkins.Spec.SeedJobs
 | 	if !r.validateSeedJobs(jenkins) { | ||||||
|  | 		return false | ||||||
|  | 	} | ||||||
|  | 	return true | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (r *ReconcileUserConfiguration) validateSeedJobs(jenkins *virtuslabv1alpha1.Jenkins) bool { | ||||||
| 	if jenkins.Spec.SeedJobs != nil { | 	if jenkins.Spec.SeedJobs != nil { | ||||||
| 		for _, seedJob := range jenkins.Spec.SeedJobs { | 		for _, seedJob := range jenkins.Spec.SeedJobs { | ||||||
| 			logger := r.logger.WithValues("seedJob", fmt.Sprintf("%+v", seedJob)).V(log.VWarn) | 			logger := r.logger.WithValues("seedJob", fmt.Sprintf("%+v", seedJob)).V(log.VWarn) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue