github.com/redhat-appstudio/e2e-tests@v0.0.0-20230619105049-9a422b2094d7/pkg/utils/jvmbuildservice/controller.go (about) 1 package jvmbuildservice 2 3 import ( 4 "context" 5 "strconv" 6 "time" 7 8 kubeCl "github.com/redhat-appstudio/e2e-tests/pkg/apis/kubernetes" 9 "github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1" 10 "github.com/redhat-appstudio/jvm-build-service/pkg/reconciler/jbsconfig" 11 12 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 13 ) 14 15 type SuiteController struct { 16 *kubeCl.CustomClient 17 } 18 19 func NewSuiteControler(kube *kubeCl.CustomClient) (*SuiteController, error) { 20 return &SuiteController{ 21 kube, 22 }, nil 23 } 24 25 func (s *SuiteController) ListArtifactBuilds(namespace string) (*v1alpha1.ArtifactBuildList, error) { 26 return s.JvmbuildserviceClient().JvmbuildserviceV1alpha1().ArtifactBuilds(namespace).List(context.TODO(), metav1.ListOptions{}) 27 } 28 29 func (s *SuiteController) DeleteArtifactBuild(name, namespace string) error { 30 return s.JvmbuildserviceClient().JvmbuildserviceV1alpha1().ArtifactBuilds(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{}) 31 } 32 33 func (s *SuiteController) ListDependencyBuilds(namespace string) (*v1alpha1.DependencyBuildList, error) { 34 return s.JvmbuildserviceClient().JvmbuildserviceV1alpha1().DependencyBuilds(namespace).List(context.TODO(), metav1.ListOptions{}) 35 } 36 37 func (s *SuiteController) DeleteDependencyBuild(name, namespace string) error { 38 return s.JvmbuildserviceClient().JvmbuildserviceV1alpha1().DependencyBuilds(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{}) 39 } 40 41 func (s *SuiteController) CreateJBSConfig(name, namespace string) (*v1alpha1.JBSConfig, error) { 42 config := &v1alpha1.JBSConfig{ 43 ObjectMeta: metav1.ObjectMeta{Name: name, Annotations: map[string]string{jbsconfig.DeleteImageRepositoryAnnotationName: "true"}}, 44 Spec: v1alpha1.JBSConfigSpec{ 45 EnableRebuilds: true, 46 RequireArtifactVerification: true, 47 MavenBaseLocations: map[string]string{ 48 "maven-repository-300-jboss": "https://repository.jboss.org/nexus/content/groups/public/", 49 "maven-repository-301-gradleplugins": "https://plugins.gradle.org/m2", 50 "maven-repository-302-confluent": "https://packages.confluent.io/maven", 51 "maven-repository-303-gradle": "https://repo.gradle.org/artifactory/libs-releases", 52 "maven-repository-304-eclipselink": "https://download.eclipse.org/rt/eclipselink/maven.repo", 53 "maven-repository-305-redhat": "https://maven.repository.redhat.com/ga", 54 "maven-repository-306-jitpack": "https://jitpack.io", 55 "maven-repository-307-jsweet": "https://repository.jsweet.org/artifactory/libs-release-local", 56 "maven-repository-308-jenkins": "https://repo.jenkins-ci.org/public/", 57 "maven-repository-309-spring-plugins": "https://repo.springsource.org/plugins-release", 58 "maven-repository-310-dokkadev": "https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev", 59 "maven-repository-311-ajoberstar": "https://ajoberstar.org/bintray-backup", 60 "maven-repository-312-googleandroid": "https://dl.google.com/dl/android/maven2/", 61 "maven-repository-313-kotlinnative14linux": "https://download.jetbrains.com/kotlin/native/builds/releases/1.4/linux", 62 "maven-repository-314-jcs": "https://packages.jetbrains.team/maven/p/jcs/maven", 63 "maven-repository-315-kotlin-bootstrap": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap/", 64 "maven-repository-315-kotlin-kotlin-dependencies": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies"}, 65 ImageRegistry: v1alpha1.ImageRegistry{ 66 Host: "quay.io", 67 PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10), 68 }, 69 CacheSettings: v1alpha1.CacheSettings{ 70 RequestMemory: "256Mi", 71 RequestCPU: "100m", 72 Storage: "1Gi", 73 }, 74 BuildSettings: v1alpha1.BuildSettings{}, 75 RelocationPatterns: []v1alpha1.RelocationPatternElement{ 76 { 77 RelocationPattern: v1alpha1.RelocationPattern{ 78 BuildPolicy: "default", 79 Patterns: []v1alpha1.PatternElement{ 80 { 81 Pattern: v1alpha1.Pattern{ 82 From: "(io.github.stuartwdouglas.hacbs-test.simple):(simple-jdk17):(99-does-not-exist)", 83 To: "io.github.stuartwdouglas.hacbs-test.simple:simple-jdk17:0.1.2", 84 }, 85 }, 86 { 87 Pattern: v1alpha1.Pattern{ 88 From: "org.graalvm.sdk:graal-sdk:21.3.2", 89 To: "org.graalvm.sdk:graal-sdk:21.3.2.0-1-redhat-00001", 90 }, 91 }, 92 }, 93 }, 94 }, 95 }, 96 }, 97 } 98 return s.JvmbuildserviceClient().JvmbuildserviceV1alpha1().JBSConfigs(namespace).Create(context.TODO(), config, metav1.CreateOptions{}) 99 }