@@ -493,163 +493,3 @@ func TestValidateComponentAction(t *testing.T) {
493493 })
494494 }
495495}
496-
497- func TestValidateImageArchivesNoDuplicates (t * testing.T ) {
498- t .Parallel ()
499-
500- tests := []struct {
501- name string
502- components []v1alpha1.ZarfComponent
503- errorContains string
504- }{
505- {
506- name : "no duplicates" ,
507- components : []v1alpha1.ZarfComponent {
508- {
509- Name : "component1" ,
510- ImageArchives : []v1alpha1.ImageArchive {
511- {
512- Path : "/path/to/archive1.tar" ,
513- Images : []string {"nginx:1.21" },
514- },
515- },
516- Images : []string {"redis:6.2" },
517- },
518- },
519- },
520- {
521- name : "duplicate in different image archive" ,
522- components : []v1alpha1.ZarfComponent {
523- {
524- Name : "component1" ,
525- ImageArchives : []v1alpha1.ImageArchive {
526- {
527- Path : "/path/to/archive1.tar" ,
528- Images : []string {"postgres:13" },
529- },
530- {
531- Path : "/path/to/archive2.tar" ,
532- Images : []string {"postgres:13" },
533- },
534- },
535- },
536- },
537- errorContains : "appears in multiple image archives" ,
538- },
539- {
540- name : "duplicate in component images" ,
541- components : []v1alpha1.ZarfComponent {
542- {
543- Name : "component1" ,
544- ImageArchives : []v1alpha1.ImageArchive {
545- {
546- Path : "/path/to/archive1.tar" ,
547- Images : []string {"ghcr.io/zarf-dev/zarf/agent:0.65.0" },
548- },
549- },
550- Images : []string {"nginx:1.21" , "ghcr.io/zarf-dev/zarf/agent:0.65.0" },
551- },
552- },
553- errorContains : "is also pulled by component" ,
554- },
555- {
556- name : "duplicate in component with docker ref" ,
557- components : []v1alpha1.ZarfComponent {
558- {
559- Name : "component1" ,
560- ImageArchives : []v1alpha1.ImageArchive {
561- {
562- Path : "/path/to/archive1.tar" ,
563- Images : []string {"nginx:1.21" },
564- },
565- },
566- Images : []string {"nginx:1.21" },
567- },
568- },
569- errorContains : "is also pulled by component" ,
570- },
571- {
572- name : "duplicate across multiple components" ,
573- components : []v1alpha1.ZarfComponent {
574- {
575- Name : "component1" ,
576- ImageArchives : []v1alpha1.ImageArchive {
577- {
578- Path : "/path/to/archive1.tar" ,
579- Images : []string {"nginx:1.21" },
580- },
581- },
582- },
583- {
584- Name : "component2" ,
585- ImageArchives : []v1alpha1.ImageArchive {
586- {
587- Path : "/path/to/archive2.tar" ,
588- Images : []string {"nginx:1.21" },
589- },
590- },
591- },
592- },
593- errorContains : "appears in multiple image archives" ,
594- },
595- {
596- name : "empty components" ,
597- components : []v1alpha1.ZarfComponent {
598- {
599- Name : "component1" ,
600- },
601- },
602- },
603- {
604- name : "duplicate images in component.Images is allowed" ,
605- components : []v1alpha1.ZarfComponent {
606- {
607- Name : "component1" ,
608- Images : []string {"nginx:1.21" },
609- },
610- {
611- Name : "component2" ,
612- Images : []string {"nginx:1.21" },
613- },
614- },
615- },
616- {
617- name : "same archive path used by multiple components is allowed" ,
618- components : []v1alpha1.ZarfComponent {
619- {
620- Name : "component1" ,
621- ImageArchives : []v1alpha1.ImageArchive {
622- {
623- Path : "/path/to/shared-archive.tar" ,
624- Images : []string {"nginx:1.21" , "redis:6.2" },
625- },
626- },
627- },
628- {
629- Name : "component2" ,
630- ImageArchives : []v1alpha1.ImageArchive {
631- {
632- Path : "/path/to/shared-archive.tar" ,
633- Images : []string {"nginx:1.21" , "postgres:13" },
634- },
635- },
636- },
637- },
638- },
639- }
640-
641- for _ , tt := range tests {
642- t .Run (tt .name , func (t * testing.T ) {
643- t .Parallel ()
644-
645- err := validateImageArchivesNoDuplicates (tt .components )
646-
647- if tt .errorContains != "" {
648- require .Error (t , err )
649- require .Contains (t , err .Error (), tt .errorContains )
650- } else {
651- require .NoError (t , err )
652- }
653- })
654- }
655- }
0 commit comments