github.com/kubeshop/testkube@v1.17.23/pkg/tcl/mappertcl/testexecutions/mapper.go (about)

     1  // Copyright 2024 Testkube.
     2  //
     3  // Licensed as a Testkube Pro file under the Testkube Community
     4  // License (the "License"); you may not use this file except in compliance with
     5  // the License. You may obtain a copy of the License at
     6  //
     7  //     https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt
     8  
     9  package testexecutions
    10  
    11  import (
    12  	testexecutionv1 "github.com/kubeshop/testkube-operator/api/testexecution/v1"
    13  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    14  )
    15  
    16  // MapAPIToCRD maps OpenAPI spec Execution to CRD TestExecutionStatus
    17  func MapAPIToCRD(sourceRequest *testkube.Execution,
    18  	destinationRequest *testexecutionv1.TestExecutionStatus) *testexecutionv1.TestExecutionStatus {
    19  	if sourceRequest == nil || destinationRequest == nil {
    20  		return destinationRequest
    21  	}
    22  
    23  	if destinationRequest.LatestExecution != nil {
    24  		destinationRequest.LatestExecution.ExecutionNamespace = sourceRequest.ExecutionNamespace
    25  	}
    26  
    27  	return destinationRequest
    28  }