Skip to content

Commit

Permalink
feat(STONEINTG-619): use Tekton v0.49.0 and v1 APIs
Browse files Browse the repository at this point in the history
* Upgrade to Tekton v0.49.0 and use latest version
  of application-api
* Switch to using Tekton v1 APIs in Integration service
* Update Tekton TaskResult and PipelineResult
  references to use the updated Result API format
* Replace the remaining spec.Bundle references to
  use git or bundle resolvers where appropriate
* Update unit tests with the changes

Signed-off-by: dirgim <[email protected]>
  • Loading branch information
dirgim committed Nov 9, 2023
1 parent 3def7ad commit dc227ab
Show file tree
Hide file tree
Showing 45 changed files with 995 additions and 605 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ spec:
required:
- deploymentTargetClaim
type: object
required:
- env
type: object
name:
type: string
Expand Down Expand Up @@ -316,8 +314,6 @@ spec:
required:
- deploymentTargetClaim
type: object
required:
- env
type: object
name:
type: string
Expand Down
4 changes: 2 additions & 2 deletions controllers/binding/snapshotenvironmentbinding_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
h "github.com/redhat-appstudio/integration-service/helpers"
"github.com/redhat-appstudio/integration-service/loader"
"github.com/redhat-appstudio/integration-service/tekton"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -200,7 +200,7 @@ func (a *Adapter) EnsureEphemeralEnvironmentsCleanedUp() (controller.OperationRe
// createIntegrationPipelineRunWithEnvironment creates new integration PipelineRun. The Pipeline information and the parameters to it
// will be extracted from the given integrationScenario. The integration's Snapshot will also be passed to the integration PipelineRun.
// If the creation of the PipelineRun is unsuccessful, an error will be returned.
func (a *Adapter) createIntegrationPipelineRunWithEnvironment(application *applicationapiv1alpha1.Application, integrationTestScenario *v1beta1.IntegrationTestScenario, snapshot *applicationapiv1alpha1.Snapshot, environment *applicationapiv1alpha1.Environment) (*pipeline.PipelineRun, error) {
func (a *Adapter) createIntegrationPipelineRunWithEnvironment(application *applicationapiv1alpha1.Application, integrationTestScenario *v1beta1.IntegrationTestScenario, snapshot *applicationapiv1alpha1.Snapshot, environment *applicationapiv1alpha1.Environment) (*tektonv1.PipelineRun, error) {
deploymentTarget, err := a.getDeploymentTargetForEnvironment(environment)
if err != nil || deploymentTarget == nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
toolkit "github.com/redhat-appstudio/operator-toolkit/loader"
releasev1alpha1 "github.com/redhat-appstudio/release-service/api/v1alpha1"
releasemetadata "github.com/redhat-appstudio/release-service/metadata"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -380,7 +380,7 @@ var _ = Describe("Binding Adapter", Ordered, func() {
return !result.CancelRequest && err == nil
}, time.Second*20).Should(BeTrue())

integrationPipelineRuns := &tektonv1beta1.PipelineRunList{}
integrationPipelineRuns := &tektonv1.PipelineRunList{}
opts := []client.ListOption{
client.InNamespace(hasApp.Namespace),
client.MatchingLabels{
Expand Down Expand Up @@ -419,7 +419,7 @@ var _ = Describe("Binding Adapter", Ordered, func() {
return !result.CancelRequest && err == nil
}, time.Second*20).Should(BeTrue())

integrationPipelineRuns := &tektonv1beta1.PipelineRunList{}
integrationPipelineRuns := &tektonv1.PipelineRunList{}
opts := []client.ListOption{
client.InNamespace(hasApp.Namespace),
client.MatchingLabels{
Expand Down
4 changes: 2 additions & 2 deletions controllers/binding/snapshotenvironmentbinding_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1"
"github.com/redhat-appstudio/integration-service/api/v1beta1"
releasev1alpha1 "github.com/redhat-appstudio/release-service/api/v1alpha1"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
Expand Down Expand Up @@ -86,7 +86,7 @@ var _ = BeforeSuite(func() {
Expect(cfg).NotTo(BeNil())

Expect(applicationapiv1alpha1.AddToScheme(clientsetscheme.Scheme)).To(Succeed())
Expect(tektonv1beta1.AddToScheme(clientsetscheme.Scheme)).To(Succeed())
Expect(tektonv1.AddToScheme(clientsetscheme.Scheme)).To(Succeed())
Expect(releasev1alpha1.AddToScheme(clientsetscheme.Scheme)).To(Succeed())
Expect(v1beta1.AddToScheme(clientsetscheme.Scheme)).To(Succeed())

Expand Down
18 changes: 9 additions & 9 deletions controllers/buildpipeline/buildpipeline_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import (
"github.com/redhat-appstudio/integration-service/tekton"
"github.com/redhat-appstudio/operator-toolkit/controller"
"github.com/redhat-appstudio/operator-toolkit/metadata"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// Adapter holds the objects needed to reconcile a build PipelineRun.
type Adapter struct {
pipelineRun *tektonv1beta1.PipelineRun
pipelineRun *tektonv1.PipelineRun
component *applicationapiv1alpha1.Component
application *applicationapiv1alpha1.Application
loader loader.ObjectLoader
Expand All @@ -47,7 +47,7 @@ type Adapter struct {
}

// NewAdapter creates and returns an Adapter instance.
func NewAdapter(pipelineRun *tektonv1beta1.PipelineRun, component *applicationapiv1alpha1.Component, application *applicationapiv1alpha1.Application, logger h.IntegrationLogger, loader loader.ObjectLoader, client client.Client,
func NewAdapter(pipelineRun *tektonv1.PipelineRun, component *applicationapiv1alpha1.Component, application *applicationapiv1alpha1.Application, logger h.IntegrationLogger, loader loader.ObjectLoader, client client.Client,
context context.Context) *Adapter {
return &Adapter{
pipelineRun: pipelineRun,
Expand Down Expand Up @@ -134,7 +134,7 @@ func (a *Adapter) EnsureSnapshotExists() (controller.OperationResult, error) {

// getImagePullSpecFromPipelineRun gets the full image pullspec from the given build PipelineRun,
// In case the Image pullspec can't be composed, an error will be returned.
func (a *Adapter) getImagePullSpecFromPipelineRun(pipelineRun *tektonv1beta1.PipelineRun) (string, error) {
func (a *Adapter) getImagePullSpecFromPipelineRun(pipelineRun *tektonv1.PipelineRun) (string, error) {
outputImage, err := tekton.GetOutputImage(pipelineRun)
if err != nil {
return "", err
Expand All @@ -148,7 +148,7 @@ func (a *Adapter) getImagePullSpecFromPipelineRun(pipelineRun *tektonv1beta1.Pip

// getComponentSourceFromPipelineRun gets the component Git Source for the Component built in the given build PipelineRun,
// In case the Git Source can't be composed, an error will be returned.
func (a *Adapter) getComponentSourceFromPipelineRun(pipelineRun *tektonv1beta1.PipelineRun) (*applicationapiv1alpha1.ComponentSource, error) {
func (a *Adapter) getComponentSourceFromPipelineRun(pipelineRun *tektonv1.PipelineRun) (*applicationapiv1alpha1.ComponentSource, error) {
componentSourceGitUrl, err := tekton.GetComponentSourceGitUrl(pipelineRun)
if err != nil {
return nil, err
Expand All @@ -171,7 +171,7 @@ func (a *Adapter) getComponentSourceFromPipelineRun(pipelineRun *tektonv1beta1.P

// prepareSnapshotForPipelineRun prepares the Snapshot for a given PipelineRun,
// component and application. In case the Snapshot can't be created, an error will be returned.
func (a *Adapter) prepareSnapshotForPipelineRun(pipelineRun *tektonv1beta1.PipelineRun, component *applicationapiv1alpha1.Component, application *applicationapiv1alpha1.Application) (*applicationapiv1alpha1.Snapshot, error) {
func (a *Adapter) prepareSnapshotForPipelineRun(pipelineRun *tektonv1.PipelineRun, component *applicationapiv1alpha1.Component, application *applicationapiv1alpha1.Application) (*applicationapiv1alpha1.Snapshot, error) {
newContainerImage, err := a.getImagePullSpecFromPipelineRun(pipelineRun)
if err != nil {
return nil, err
Expand Down Expand Up @@ -244,8 +244,8 @@ func (a *Adapter) isLatestSucceededBuildPipelineRun() (bool, error) {
// getSucceededBuildPipelineRunsForComponent returns all succeeded PipelineRun for the
// associated component. In the case the List operation fails,
// an error will be returned.
func (a *Adapter) getSucceededBuildPipelineRunsForComponent(component *applicationapiv1alpha1.Component) (*[]tektonv1beta1.PipelineRun, error) {
var succeededPipelineRuns []tektonv1beta1.PipelineRun
func (a *Adapter) getSucceededBuildPipelineRunsForComponent(component *applicationapiv1alpha1.Component) (*[]tektonv1.PipelineRun, error) {
var succeededPipelineRuns []tektonv1.PipelineRun

buildPipelineRuns, err := a.loader.GetAllBuildPipelineRunsForComponent(a.client, a.context, component)
if err != nil {
Expand All @@ -261,7 +261,7 @@ func (a *Adapter) getSucceededBuildPipelineRunsForComponent(component *applicati
return &succeededPipelineRuns, nil
}

func (a *Adapter) annotateBuildPipelineRunWithSnapshot(pipelineRun *tektonv1beta1.PipelineRun, snapshot *applicationapiv1alpha1.Snapshot) (*tektonv1beta1.PipelineRun, error) {
func (a *Adapter) annotateBuildPipelineRunWithSnapshot(pipelineRun *tektonv1.PipelineRun, snapshot *applicationapiv1alpha1.Snapshot) (*tektonv1.PipelineRun, error) {
patch := client.MergeFrom(pipelineRun.DeepCopy())

_ = metadata.SetAnnotation(&pipelineRun.ObjectMeta, tekton.SnapshotNameLabel, snapshot.Name)
Expand Down
Loading

0 comments on commit dc227ab

Please sign in to comment.