Skip to content

Commit 20dd7c8

Browse files
committed
fix
Signed-off-by: Robert Cerven <rcerven@redhat.com>
1 parent 3afba72 commit 20dd7c8

8 files changed

+2447
-1025
lines changed

internal/controller/component_build_controller_pipeline.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,12 @@ func generatePaCPipelineRunForComponent(
527527
}
528528
}
529529

530-
pipelineRunWorkspaces := createWorkspaceBinding(pipelineSpec.Workspaces)
530+
var pipelineRunWorkspaces []tektonapi.WorkspaceBinding
531+
if pipelineSpec != nil {
532+
pipelineRunWorkspaces = createWorkspaceBinding(pipelineSpec.Workspaces)
533+
} else {
534+
pipelineRunWorkspaces = generateWorkspaceBinding()
535+
}
531536

532537
pipelineRun := &tektonapi.PipelineRun{
533538
TypeMeta: metav1.TypeMeta{
@@ -722,6 +727,19 @@ func createWorkspaceBinding(pipelineWorkspaces []tektonapi.PipelineWorkspaceDecl
722727
return pipelineRunWorkspaces
723728
}
724729

730+
func generateWorkspaceBinding() []tektonapi.WorkspaceBinding {
731+
return []tektonapi.WorkspaceBinding{
732+
{
733+
Name: "workspace",
734+
VolumeClaimTemplate: generateVolumeClaimTemplate(),
735+
},
736+
{
737+
Name: "git-auth",
738+
Secret: &corev1.SecretVolumeSource{SecretName: "{{ git_auth_secret }}"},
739+
},
740+
}
741+
}
742+
725743
func generateVolumeClaimTemplate() *corev1.PersistentVolumeClaim {
726744
return &corev1.PersistentVolumeClaim{
727745
Spec: corev1.PersistentVolumeClaimSpec{

internal/controller/component_build_controller_test.go

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// TODO remove whole file after only new model is used
1718
package controllers
1819

1920
import (
@@ -45,37 +46,6 @@ import (
4546
//+kubebuilder:scaffold:imports
4647
)
4748

48-
const (
49-
githubAppPrivateKey = `-----BEGIN RSA PRIVATE KEY-----` + // notsecret
50-
`
51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yxkbfl0
67-
Mo6H9tlw+QSTaU13AzIBaWOB4nsQaKAM9isHrWkCgYAO0F8iBKyiAGMR5oIjVp1K
68-
9ZzKor1Yh/eGt7kZMW9xUw0DNBLGAXS98GUhPjDvSEWtSDXjbmKkhN3t0MGsSBaA
69-
0A9k4ihbaZY1qatoKfyhmWSLJnFilVS/BN/b6kkL+ip4ZKbbPGgW3t/QkZXWm/PE
70-
lMZdL211JPNvf689CpccFQKBgGXJGUZ4LuMtJjeRxHi22wDcQ7/ZaQaPc0U1TlHI
71-
tZjg3iFpqgGWWzP7k83xh763h5hZrvke7AGSyjLuY90AFglsO5QuUUjXtQqK0vdi
72-
Di+5Yx+mO9ECUbjbr58iR2ol6Ph+/O8lB+zf0XsRbR/moteAuYfM/0itbBpu82Xb
73-
JujhAoGAVdNMYdamHOJlkjYjYJmWOHPIFBMTDYk8pDATLOlqthV+fzlD2SlF0wxm
74-
OlxbwEr3BSQlE3GFPHe+J3JV3BbJFsVkM8KdMUpQCl+aD/3nWaGBYHz4yvJc0i9h
75-
duAFIZgXeivAZQAqys4JanG81cg4/d4urI3Qk9stlhB5CNCJR4k=
76-
-----END RSA PRIVATE KEY-----`
77-
)
78-
7949
var (
8050
defaultPipelineAnnotationValue = fmt.Sprintf("{\"name\":\"%s\",\"bundle\":\"%s\"}", defaultPipelineName, defaultPipelineBundle)
8151
defaultPipelineAnnotations = map[string]string{defaultBuildPipelineAnnotation: defaultPipelineAnnotationValue}
@@ -941,7 +911,7 @@ var _ = Describe("Component build controller", func() {
941911
}
942912

943913
pacSecretData := map[string]string{"password": "ghp_token"}
944-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
914+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
945915

946916
createComponentAndProcessBuildRequest(componentConfigOldModel{
947917
componentKey: resourcePacPrepKey,
@@ -973,7 +943,7 @@ var _ = Describe("Component build controller", func() {
973943
}
974944

975945
pacSecretData := map[string]string{"password": "ghp_token"}
976-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
946+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
977947

978948
createComponentAndProcessBuildRequest(componentConfigOldModel{
979949
componentKey: resourcePacPrepKey,
@@ -998,7 +968,7 @@ var _ = Describe("Component build controller", func() {
998968
}
999969

1000970
pacSecretData := map[string]string{"password": "ghp_token"}
1001-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
971+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
1002972

1003973
component1Key := resourcePacPrepKey
1004974
component2Key := types.NamespacedName{Name: "component2", Namespace: namespace}
@@ -1040,7 +1010,7 @@ var _ = Describe("Component build controller", func() {
10401010
}
10411011

10421012
pacSecretData := map[string]string{"password": "ghp_token"}
1043-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
1013+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
10441014

10451015
component1Key := resourcePacPrepKey
10461016
component2Key := types.NamespacedName{Name: "component2", Namespace: namespace}
@@ -1441,7 +1411,7 @@ var _ = Describe("Component build controller", func() {
14411411
}
14421412

14431413
pacSecretData := map[string]string{"password": "ghp_token"}
1444-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
1414+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
14451415

14461416
createComponentAndProcessBuildRequest(componentConfigOldModel{
14471417
componentKey: resourceCleanupKey,
@@ -1501,7 +1471,7 @@ var _ = Describe("Component build controller", func() {
15011471
}
15021472

15031473
pacSecretData := map[string]string{"password": "ghp_token"}
1504-
createSCMSecret(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
1474+
createSCMSecretOldModel(namespacePaCSecretKey, pacSecretData, corev1.SecretTypeBasicAuth, map[string]string{})
15051475

15061476
createComponentAndProcessBuildRequest(componentConfigOldModel{
15071477
componentKey: resourceCleanupKey,

internal/controller/component_build_controller_v2.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,8 @@ func (r *ComponentBuildReconciler) determineVersionsToCreateConfigurationFor(
14561456
log.Info("Create configuration action detected", "VersionsToCreate", versionsToOnboardWithPR)
14571457
}
14581458
}
1459+
// Sort for deterministic processing order
1460+
slices.Sort(versionsToOnboardWithPR)
14591461
return versionsToOnboardWithPR, invalidVersionsToOnboardWithPR
14601462
}
14611463

@@ -1557,6 +1559,9 @@ func (r *ComponentBuildReconciler) determineVersionsToOnboardAndOffboard(
15571559
log.Info("Versions to offboard detected", "VersionsToOffboard", versionsToOffboard)
15581560
}
15591561

1562+
// Sort for deterministic processing order
1563+
slices.Sort(versionsToOnboard)
1564+
slices.Sort(versionsToOffboard)
15601565
return versionsToOnboard, versionsToOffboard
15611566
}
15621567

@@ -1608,6 +1613,8 @@ func (r *ComponentBuildReconciler) determineVersionsToTriggerBuildFor(
16081613
}
16091614
}
16101615

1616+
// Sort for deterministic processing order
1617+
slices.Sort(versionsToTriggerBuild)
16111618
return versionsToTriggerBuild, invalidVersionsToTriggerBuild
16121619
}
16131620

0 commit comments

Comments
 (0)