Skip to content

Commit

Permalink
feat(RHHTAPREL-714): update RPA definitions (konflux-ci#996)
Browse files Browse the repository at this point in the history
* chore: get rid of managed-gitops dependency

* feat(RHHTAPREL-714): update RPA definitions

ReleasePlanAdmissions' PipelineRef and ServiceAccount fields have
moved inside a new field, Pipeline.update RPA definitions

Signed-off-by: David Moreno García <[email protected]>

* fix: code changes after tekton API version bump

* fix: address "k8s.io/utils/pointer" deprecation

* fix: snyk: update github.com/spf13/afero

---------

Signed-off-by: David Moreno García <[email protected]>
Co-authored-by: Pavel Sturc <[email protected]>
  • Loading branch information
davidmogar and psturc authored Jan 30, 2024
1 parent 31ae9ff commit d3cafac
Show file tree
Hide file tree
Showing 40 changed files with 1,453 additions and 720 deletions.
10 changes: 5 additions & 5 deletions cmd/loadTests.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
loadtestUtils "github.com/redhat-appstudio/e2e-tests/pkg/utils/loadtests"
integrationv1beta1 "github.com/redhat-appstudio/integration-service/api/v1beta1"
"github.com/spf13/cobra"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -1568,7 +1568,7 @@ func (h *ConcreteHandlerPipelines) Handle(ctx *JourneyContext) {
func (h *ConcreteHandlerPipelines) validatePipeline(ctx *JourneyContext, framework *framework.Framework, componentName, applicationName, username, usernamespace string) {
pipelineCreatedRetryInterval := time.Second * 20
pipelineCreatedTimeout := time.Minute * 30
var pipelineRun *v1beta1.PipelineRun
var pipelineRun *pipeline.PipelineRun

threadIndex := ctx.ThreadIndex
chIntegrationTestsPipelines := ctx.ChIntegrationTestsPipelines
Expand Down Expand Up @@ -1628,7 +1628,7 @@ func (h *ConcreteHandlerPipelines) validatePipeline(ctx *JourneyContext, framewo
}

func (h *ConcreteHandlerPipelines) validatePipelineCreation(ctx *JourneyContext, framework *framework.Framework, componentName, applicationName, usernamespace string, pipelineCreatedRetryInterval, pipelineCreatedTimeout time.Duration) (error, string) {
var pipelineRun *v1beta1.PipelineRun
var pipelineRun *pipeline.PipelineRun

err := k8swait.PollUntilContextTimeout(context.Background(), pipelineCreatedRetryInterval, pipelineCreatedTimeout, false, func(ctx context.Context) (done bool, err error) {
// Searching for "build" type of pipelineRun
Expand All @@ -1648,7 +1648,7 @@ func (h *ConcreteHandlerPipelines) validatePipelineCreation(ctx *JourneyContext,
}
}

func (h *ConcreteHandlerPipelines) handlePVCS(threadIndex int, framework *framework.Framework, pipelineRun *v1beta1.PipelineRun) {
func (h *ConcreteHandlerPipelines) handlePVCS(threadIndex int, framework *framework.Framework, pipelineRun *pipeline.PipelineRun) {
pvcs, err := framework.AsKubeAdmin.TektonController.KubeInterface().CoreV1().PersistentVolumeClaims(pipelineRun.Namespace).List(context.Background(), metav1.ListOptions{})
if err != nil {
logError(23, fmt.Sprintf("Error getting PVC: %v\n", err))
Expand Down Expand Up @@ -1727,7 +1727,7 @@ func (h *ConcreteHandlerItsPipelines) validateItsPipeline(ctx *JourneyContext, a

IntegrationTestsPipelineRunRetryInterval := time.Second * 20
IntegrationTestsPipelineRunTimeout := time.Minute * 60
var IntegrationTestsPipelineRun *v1beta1.PipelineRun
var IntegrationTestsPipelineRun *pipeline.PipelineRun
err = k8swait.PollUntilContextTimeout(context.Background(), IntegrationTestsPipelineRunRetryInterval, IntegrationTestsPipelineRunTimeout, false, func(ctx context.Context) (done bool, err error) {
IntegrationTestsPipelineRun, err = framework.AsKubeDeveloper.IntegrationController.GetIntegrationPipelineRun(testScenarioName, snapshotName, usernamespace)
if err != nil {
Expand Down
175 changes: 89 additions & 86 deletions go.mod

Large diffs are not rendered by default.

1,375 changes: 1,091 additions & 284 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion magefiles/installation/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (i *InstallAppStudio) CheckOperatorsReady() (err error) {
}

if !(application.Status.Sync.Status == "Synced" && application.Status.Health.Status == "Healthy") {
klog.Info("Application %s not ready\n", app.Name)
klog.Infof("Application %s not ready", app.Name)
count++
} else if strings.Contains(application.String(), ("context deadline exceeded")) {
fmt.Printf("Refreshing Application %s\n", app.Name)
Expand Down
2 changes: 1 addition & 1 deletion magefiles/testspecs/ginkgosspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func createTestPath(cwd string, destination string) (string, error) {
dir := filepath.Dir(destination)
err = os.MkdirAll(dir, 0775)
if err != nil {
klog.Error("failed to create package directory, %s", dir)
klog.Errorf("failed to create package directory, %s", dir)
return "", err
}
return destination, nil
Expand Down
72 changes: 0 additions & 72 deletions pkg/clients/gitops/gitopsdeployments.go

This file was deleted.

24 changes: 12 additions & 12 deletions pkg/clients/has/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (
"github.com/redhat-appstudio/e2e-tests/pkg/logs"
"github.com/redhat-appstudio/e2e-tests/pkg/utils"
"github.com/redhat-appstudio/e2e-tests/pkg/utils/build"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
"k8s.io/klog"
"k8s.io/utils/pointer"
pointer "k8s.io/utils/ptr"
"knative.dev/pkg/apis"
rclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -63,12 +63,12 @@ func (h *HasController) GetComponentByApplicationName(applicationName string, na
}

// GetComponentPipeline returns the pipeline for a given component labels
func (h *HasController) GetComponentPipelineRun(componentName string, applicationName string, namespace, sha string) (*v1beta1.PipelineRun, error) {
func (h *HasController) GetComponentPipelineRun(componentName string, applicationName string, namespace, sha string) (*pipeline.PipelineRun, error) {
return h.GetComponentPipelineRunWithType(componentName, applicationName, namespace, "", sha)
}

// GetComponentPipeline returns the pipeline for a given component labels with pipeline type within label "pipelines.appstudio.openshift.io/type" ("build", "test")
func (h *HasController) GetComponentPipelineRunWithType(componentName string, applicationName string, namespace, pipelineType string, sha string) (*v1beta1.PipelineRun, error) {
func (h *HasController) GetComponentPipelineRunWithType(componentName string, applicationName string, namespace, pipelineType string, sha string) (*pipeline.PipelineRun, error) {
pipelineRunLabels := map[string]string{"appstudio.openshift.io/component": componentName, "appstudio.openshift.io/application": applicationName}
if pipelineType != "" {
pipelineRunLabels["pipelines.appstudio.openshift.io/type"] = pipelineType
Expand All @@ -78,7 +78,7 @@ func (h *HasController) GetComponentPipelineRunWithType(componentName string, ap
pipelineRunLabels["pipelinesascode.tekton.dev/sha"] = sha
}

list := &v1beta1.PipelineRunList{}
list := &pipeline.PipelineRunList{}
err := h.KubeRest().List(context.Background(), list, &rclient.ListOptions{LabelSelector: labels.SelectorFromSet(pipelineRunLabels), Namespace: namespace})

if err != nil && !k8sErrors.IsNotFound(err) {
Expand All @@ -98,10 +98,10 @@ func (h *HasController) GetComponentPipelineRunWithType(componentName string, ap
}

// GetAllPipelineRunsForApplication returns the pipelineruns for a given application in the namespace
func (h *HasController) GetAllPipelineRunsForApplication(applicationName, namespace string) (*v1beta1.PipelineRunList, error) {
func (h *HasController) GetAllPipelineRunsForApplication(applicationName, namespace string) (*pipeline.PipelineRunList, error) {
pipelineRunLabels := map[string]string{"appstudio.openshift.io/application": applicationName}

list := &v1beta1.PipelineRunList{}
list := &pipeline.PipelineRunList{}
err := h.KubeRest().List(context.Background(), list, &rclient.ListOptions{LabelSelector: labels.SelectorFromSet(pipelineRunLabels), Namespace: namespace})

if err != nil && !k8sErrors.IsNotFound(err) {
Expand Down Expand Up @@ -130,7 +130,7 @@ type RetryOptions struct {
func (h *HasController) WaitForComponentPipelineToBeFinished(component *appservice.Component, sha string, t *tekton.TektonController, r *RetryOptions) error {
attempts := 1
app := component.Spec.Application
var pr *v1beta1.PipelineRun
var pr *pipeline.PipelineRun

for {
err := wait.PollUntilContextTimeout(context.Background(), constants.PipelineRunPollingInterval, 30*time.Minute, true, func(ctx context.Context) (done bool, err error) {
Expand Down Expand Up @@ -251,7 +251,7 @@ func (h *HasController) CreateComponentWithDockerSource(applicationName, compone
},
Secret: secret,
ContainerImage: outputContainerImage,
Replicas: pointer.Int(1),
Replicas: pointer.To[int](1),
TargetPort: 8081,
Route: "",
},
Expand Down Expand Up @@ -365,7 +365,7 @@ func (h *HasController) GetComponentConditionStatusMessages(name, namespace stri
}

// Universal method to retrigger pipelineruns in kubernetes cluster
func (h *HasController) RetriggerComponentPipelineRun(component *appservice.Component, pr *v1beta1.PipelineRun) (sha string, err error) {
func (h *HasController) RetriggerComponentPipelineRun(component *appservice.Component, pr *pipeline.PipelineRun) (sha string, err error) {
if err = h.KubeRest().Delete(context.Background(), pr); err != nil {
return "", fmt.Errorf("failed to delete PipelineRun %q from %q namespace with error: %v", pr.GetName(), pr.GetNamespace(), err)
}
Expand Down Expand Up @@ -424,7 +424,7 @@ func (h *HasController) RetriggerComponentPipelineRun(component *appservice.Comp
return "", err
}
}
watch, err := h.PipelineClient().TektonV1beta1().PipelineRuns(component.GetNamespace()).Watch(context.Background(), metav1.ListOptions{})
watch, err := h.PipelineClient().TektonV1().PipelineRuns(component.GetNamespace()).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
return "", fmt.Errorf("error when initiating watch for new PipelineRun after retriggering it for component %s:%s", component.GetNamespace(), component.GetName())
}
Expand All @@ -437,7 +437,7 @@ func (h *HasController) RetriggerComponentPipelineRun(component *appservice.Comp
if event.Object == nil {
continue
}
newPR, ok := event.Object.(*v1beta1.PipelineRun)
newPR, ok := event.Object.(*pipeline.PipelineRun)
if !ok {
continue
}
Expand Down
30 changes: 15 additions & 15 deletions pkg/clients/integration/pipelineruns.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/redhat-appstudio/e2e-tests/pkg/utils"
"github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton"
integrationv1beta1 "github.com/redhat-appstudio/integration-service/api/v1beta1"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -23,8 +23,8 @@ import (
)

// CreateIntegrationPipelineRun creates new integrationPipelineRun.
func (i *IntegrationController) CreateIntegrationPipelineRun(snapshotName, namespace, componentName, integrationTestScenarioName string) (*tektonv1beta1.PipelineRun, error) {
testpipelineRun := &tektonv1beta1.PipelineRun{
func (i *IntegrationController) CreateIntegrationPipelineRun(snapshotName, namespace, componentName, integrationTestScenarioName string) (*tektonv1.PipelineRun, error) {
testpipelineRun := &tektonv1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "component-pipelinerun" + "-",
Namespace: namespace,
Expand All @@ -36,15 +36,15 @@ func (i *IntegrationController) CreateIntegrationPipelineRun(snapshotName, names
"test.appstudio.openshift.io/scenario": integrationTestScenarioName,
},
},
Spec: tektonv1beta1.PipelineRunSpec{
Spec: tektonv1.PipelineRunSpec{
PipelineRef: tekton.NewBundleResolverPipelineRef(
"integration-pipeline-pass",
"quay.io/redhat-appstudio/example-tekton-bundle:integration-pipeline-pass",
),
Params: []tektonv1beta1.Param{
Params: []tektonv1.Param{
{
Name: "output-image",
Value: tektonv1beta1.ParamValue{
Value: tektonv1.ParamValue{
Type: "string",
StringVal: "quay.io/redhat-appstudio/sample-image",
},
Expand All @@ -61,8 +61,8 @@ func (i *IntegrationController) CreateIntegrationPipelineRun(snapshotName, names

// GetComponentPipeline returns the pipeline for a given component labels.
// In case of failure, this function retries till it gets timed out.
func (i *IntegrationController) GetBuildPipelineRun(componentName, applicationName, namespace string, pacBuild bool, sha string) (*tektonv1beta1.PipelineRun, error) {
var pipelineRun *tektonv1beta1.PipelineRun
func (i *IntegrationController) GetBuildPipelineRun(componentName, applicationName, namespace string, pacBuild bool, sha string) (*tektonv1.PipelineRun, error) {
var pipelineRun *tektonv1.PipelineRun

err := wait.PollUntilContextTimeout(context.Background(), constants.PipelineRunPollingInterval, 20*time.Minute, true, func(ctx context.Context) (done bool, err error) {
pipelineRunLabels := map[string]string{"appstudio.openshift.io/component": componentName, "appstudio.openshift.io/application": applicationName, "pipelines.appstudio.openshift.io/type": "build"}
Expand All @@ -71,7 +71,7 @@ func (i *IntegrationController) GetBuildPipelineRun(componentName, applicationNa
pipelineRunLabels["pipelinesascode.tekton.dev/sha"] = sha
}

list := &tektonv1beta1.PipelineRunList{}
list := &tektonv1.PipelineRunList{}
err = i.KubeRest().List(context.Background(), list, &client.ListOptions{LabelSelector: labels.SelectorFromSet(pipelineRunLabels), Namespace: namespace})

if err != nil && !k8sErrors.IsNotFound(err) {
Expand All @@ -89,7 +89,7 @@ func (i *IntegrationController) GetBuildPipelineRun(componentName, applicationNa
return true, nil
}

pipelineRun = &tektonv1beta1.PipelineRun{}
pipelineRun = &tektonv1.PipelineRun{}
GinkgoWriter.Printf("no pipelinerun found for component %s %s", componentName, utils.GetAdditionalInfo(applicationName, namespace))
return false, nil
})
Expand All @@ -99,7 +99,7 @@ func (i *IntegrationController) GetBuildPipelineRun(componentName, applicationNa

// GetIntegrationPipelineRun returns the integration pipelineRun
// for a given scenario, snapshot labels.
func (i *IntegrationController) GetIntegrationPipelineRun(integrationTestScenarioName string, snapshotName string, namespace string) (*tektonv1beta1.PipelineRun, error) {
func (i *IntegrationController) GetIntegrationPipelineRun(integrationTestScenarioName string, snapshotName string, namespace string) (*tektonv1.PipelineRun, error) {
opts := []client.ListOption{
client.InNamespace(namespace),
client.MatchingLabels{
Expand All @@ -109,7 +109,7 @@ func (i *IntegrationController) GetIntegrationPipelineRun(integrationTestScenari
},
}

list := &tektonv1beta1.PipelineRunList{}
list := &tektonv1.PipelineRunList{}
err := i.KubeRest().List(context.Background(), list, opts...)

if err != nil && !k8sErrors.IsNotFound(err) {
Expand All @@ -120,13 +120,13 @@ func (i *IntegrationController) GetIntegrationPipelineRun(integrationTestScenari
return &list.Items[0], nil
}

return &tektonv1beta1.PipelineRun{}, fmt.Errorf("no pipelinerun found for integrationTestScenario %s (snapshot: %s, namespace: %s)", integrationTestScenarioName, snapshotName, namespace)
return &tektonv1.PipelineRun{}, fmt.Errorf("no pipelinerun found for integrationTestScenario %s (snapshot: %s, namespace: %s)", integrationTestScenarioName, snapshotName, namespace)
}

// WaitForIntegrationPipelineToGetStarted wait for given integration pipeline to get started.
// In case of failure, this function retries till it gets timed out.
func (i *IntegrationController) WaitForIntegrationPipelineToGetStarted(testScenarioName, snapshotName, appNamespace string) (*tektonv1beta1.PipelineRun, error) {
var testPipelinerun *tektonv1beta1.PipelineRun
func (i *IntegrationController) WaitForIntegrationPipelineToGetStarted(testScenarioName, snapshotName, appNamespace string) (*tektonv1.PipelineRun, error) {
var testPipelinerun *tektonv1.PipelineRun

err := wait.PollUntilContextTimeout(context.Background(), time.Second*2, time.Minute*5, true, func(ctx context.Context) (done bool, err error) {
testPipelinerun, err = i.GetIntegrationPipelineRun(testScenarioName, snapshotName, appNamespace)
Expand Down
7 changes: 0 additions & 7 deletions pkg/clients/jvmbuildservice/jbs_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package jvmbuildservice

import (
"context"
"strconv"
"time"

"github.com/redhat-appstudio/jvm-build-service/pkg/apis/jvmbuildservice/v1alpha1"
"github.com/redhat-appstudio/jvm-build-service/pkg/reconciler/jbsconfig"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -35,10 +32,6 @@ func (j *JvmbuildserviceController) CreateJBSConfig(name, namespace string) (*v1
"maven-repository-314-jcs": "https://packages.jetbrains.team/maven/p/jcs/maven",
"maven-repository-315-kotlin-bootstrap": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap/",
"maven-repository-315-kotlin-kotlin-dependencies": "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies"},
ImageRegistry: v1alpha1.ImageRegistry{
Host: "quay.io",
PrependTag: strconv.FormatInt(time.Now().UnixMilli(), 10),
},
CacheSettings: v1alpha1.CacheSettings{
RequestMemory: "256Mi",
RequestCPU: "100m",
Expand Down
Loading

0 comments on commit d3cafac

Please sign in to comment.