@@ -244,33 +244,6 @@ spec:
244244` , name , namespace , repo , taskName , cacheMode ))
245245}
246246
247- func createGitTaskRun (t * testing.T , namespace , name , revision string ) * v1.TaskRun {
248- t .Helper ()
249- return parse .MustParseV1TaskRun (t , fmt .Sprintf (`
250- metadata:
251- name: %s
252- namespace: %s
253- spec:
254- workspaces:
255- - name: output
256- emptyDir: {}
257- taskRef:
258- resolver: git
259- params:
260- - name: url
261- value: https://github.com/tektoncd/catalog.git
262- - name: pathInRepo
263- value: task/git-clone/0.10/git-clone.yaml
264- - name: revision
265- value: %s
266- params:
267- - name: url
268- value: https://github.com/tektoncd/pipeline
269- - name: deleteExisting
270- value: "true"
271- ` , name , namespace , revision ))
272- }
273-
274247func createGitTaskRunWithCache (t * testing.T , namespace , name , revision , cacheMode string ) * v1.TaskRun {
275248 t .Helper ()
276249 return parse .MustParseV1TaskRun (t , fmt .Sprintf (`
@@ -760,107 +733,3 @@ func createTaskRunAndWait(ctx context.Context, t *testing.T, c *clients, tr *v1.
760733 t .Fatalf ("Error waiting for TaskRun %s to finish: %s" , tr .Name , err )
761734 }
762735}
763-
764- // getImageDigest gets the digest of an image from the local registry
765- func getImageDigest (ctx context.Context , t * testing.T , c * clients , namespace , imageRef string ) string {
766- t .Helper ()
767-
768- // Create a pod to run skopeo inspect
769- podName := "get-digest-" + helpers .ObjectNameForTest (t )
770- po , err := c .KubeClient .CoreV1 ().Pods (namespace ).Create (ctx , & corev1.Pod {
771- ObjectMeta : metav1.ObjectMeta {
772- Namespace : namespace ,
773- Name : podName ,
774- },
775- Spec : corev1.PodSpec {
776- Containers : []corev1.Container {{
777- Name : "skopeo" ,
778- Image : "ghcr.io/tektoncd/catalog/upstream/tasks/skopeo-copy:latest" ,
779- Command : []string {"/bin/sh" , "-c" },
780- Args : []string {"skopeo inspect --tls-verify=false docker://" + imageRef + " | jq -r '.Digest'" },
781- }},
782- RestartPolicy : corev1 .RestartPolicyNever ,
783- },
784- }, metav1.CreateOptions {})
785- if err != nil {
786- t .Fatalf ("Failed to create digest pod: %v" , err )
787- }
788-
789- // Wait for pod to complete
790- if err := WaitForPodState (ctx , c , po .Name , namespace , func (pod * corev1.Pod ) (bool , error ) {
791- return pod .Status .Phase == "Succeeded" , nil
792- }, "PodContainersTerminated" ); err != nil {
793- req := c .KubeClient .CoreV1 ().Pods (namespace ).GetLogs (po .GetName (), & corev1.PodLogOptions {Container : "skopeo" })
794- logs , err := req .DoRaw (ctx )
795- if err != nil {
796- t .Fatalf ("Error getting pod logs: %v" , err )
797- }
798- t .Fatalf ("Failed to get digest. Pod logs: \n %s" , string (logs ))
799- }
800-
801- // Get the digest from pod logs
802- req := c .KubeClient .CoreV1 ().Pods (namespace ).GetLogs (po .GetName (), & corev1.PodLogOptions {Container : "skopeo" })
803- logs , err := req .DoRaw (ctx )
804- if err != nil {
805- t .Fatalf ("Error getting pod logs: %v" , err )
806- }
807-
808- digest := strings .TrimSpace (string (logs ))
809- if digest == "" {
810- t .Fatalf ("Empty digest returned" )
811- }
812-
813- return digest
814- }
815-
816- // getGitCommitHash gets the commit hash for a branch in the catalog repository
817- func getGitCommitHash (ctx context.Context , t * testing.T , c * clients , namespace , branch string ) string {
818- t .Helper ()
819-
820- // Create a pod to run git ls-remote
821- podName := "get-commit-" + helpers .ObjectNameForTest (t )
822- po , err := c .KubeClient .CoreV1 ().Pods (namespace ).Create (ctx , & corev1.Pod {
823- ObjectMeta : metav1.ObjectMeta {
824- Namespace : namespace ,
825- Name : podName ,
826- },
827- Spec : corev1.PodSpec {
828- Containers : []corev1.Container {{
829- Name : "git" ,
830- Image : "alpine/git:latest" ,
831- Command : []string {"/bin/sh" , "-c" },
832- Args : []string {"git ls-remote https://github.com/tektoncd/catalog.git " + branch + " | cut -f1" },
833- }},
834- RestartPolicy : corev1 .RestartPolicyNever ,
835- },
836- }, metav1.CreateOptions {})
837- if err != nil {
838- t .Fatalf ("Failed to create git pod: %v" , err )
839- }
840-
841- // Wait for pod to complete
842- if err := WaitForPodState (ctx , c , po .Name , namespace , func (pod * corev1.Pod ) (bool , error ) {
843- return pod .Status .Phase == "Succeeded" , nil
844- }, "PodContainersTerminated" ); err != nil {
845- req := c .KubeClient .CoreV1 ().Pods (namespace ).GetLogs (po .GetName (), & corev1.PodLogOptions {Container : "git" })
846- logs , err := req .DoRaw (ctx )
847- if err != nil {
848- t .Fatalf ("Error getting pod logs: %v" , err )
849- }
850- t .Fatalf ("Failed to get commit hash. Pod logs: \n %s" , string (logs ))
851- }
852-
853- // Get the commit hash from pod logs
854- req := c .KubeClient .CoreV1 ().Pods (namespace ).GetLogs (po .GetName (), & corev1.PodLogOptions {Container : "git" })
855- logs , err := req .DoRaw (ctx )
856- if err != nil {
857- t .Fatalf ("Error getting pod logs: %v" , err )
858- }
859-
860- commitHash := strings .TrimSpace (string (logs ))
861- if commitHash == "" {
862- t .Fatalf ("Empty commit hash returned" )
863- }
864-
865- return commitHash
866- }
0 commit comments