docker-archive / migrator

Tool to migrate Docker images from Docker Hub or v1 registry to a v2 registry
Apache License 2.0
160 stars 82 forks source link

fix query_tags_to_skip func #103

Closed jimmydurkin closed 7 years ago

jimmydurkin commented 7 years ago

This change fixes the collection of tags in the V2_Registry. Previously the last line was assigned to the response body. Now it collects each tag into an array.

Previous Behavior (Notice the parse error: Unmatched '}' at line 1, column 1)

+ RESPONSE_BODY='  "tags" : [ "85ca52e", "8b6b599", "a45283c", "f979df8", "7288fb5", "49b4cee", "37203a4", "ea79042", "2ea99cd", "cfe300a", "e7fa403", "d435e1a", "3f3409d", "21ef52d", "73e2758", "374418f", "9ca76fd", "7d508c7", "ff67f88", "b8f3d7f", "a9ba2a0", "6cf487f", "9c41f85", "7ec76f3", "b330f93", "f6415c0", "a934bce", "1caeda6", "89d4572", "84af8bd", "549d5b5", "57b97f6", "ce56af3", "845c62b", "5299dbf", "a583a95", "f031c46", "915bde4", "2ec84eb", "3939b98", "0e5592b", "44d8e1a", "ec4aa91", "6cdb149", "fafed78", "ad9a69e", "42c829d", "69d7d6a", "cd40c05", "3fad187", "4b269d1", "0e709df", "97b3c22", "a94c050", "1d36acf", "a9b5ae6", "f5ef22c", "90f3b21", "64005cf", "aa13a0d", "e46b0c6", "00d08cb", "d231465", "9550061", "c9ffd9d", "3691108", "254da03", "e9ef7e6", "5cfd159", "7150030", "1be08cf", "5ae37fb", "e100f29", "758f64c", "58f385f", "f005c77", "cd61cde", "8116e8a", "eafa510", "06c73c0", "37a91bb", "1f94e8d", "be1def7", "8182802", "c799ad7", "5073095", "b289a4d", "b9970f5", "c14eb91", "9703b4c", "1e4d8bf", "a49fd77", "e2c91f2", "ffa18c3", "a750e90", "e7b952a", "555b400", "1972eed", "214fb17", "f6833f6", "55b744d", "786b3a6", "4c61a17", "4327a53", "3e32672", "1b9512e", "15212f2", "986c0a8", "c617277", "228818a", "a9d7efe", "db6a0be", "9de76eb", "752cbfd", "9899556", "8258d80", "fdd71f7", "ec7761a", "3a1e030", "19cf79f", "80b82f7", "01547cf", "e070bf6", "419550c", "5b12e39", "3fa2eb0", "c6c5b6f", "d7e62ed", "852770c", "dabcf99", "13a1aa8", "a8c1a81", "37330e4", "112f021", "02eee0f", "4a7ad8d", "266d45b", "017695c", "8550bf7", "cc04eab", "f1462d9", "4c3f62d", "eb64cd6", "1b9cb55", "0172257", "9119c6b", "ae6b52c", "6fdf022", "e218215", "3d69345", "060645f", "ef5c950", "a5931a0", "5cac378", "3350c1e", "0c2795b", "f5d12ac", "620e218", "a85431f", "5830a00", "e7852ff", "63902f6" ]'
+ IFS=
+ read -r line
+ '[' false = true ']'
+ '[' false = true ']'
+ '[' true = true ']'
+ RESPONSE_BODY='}'
+ IFS=
+ read -r line
 =~ HTTP/(1(.[10])?|2) 200.* ]]
++ echo
++ grep -o '<.*>'
+ NEXT_PAGE_LINK_IN_CHEVRONS=
+ NEXT_PAGE_LINK=
++ echo '}'
++ jq -cM '[.tags[]]'
parse error: Unmatched '}' at line 1, column 1
+ THIS_PAGE_TAGS=
++ jq -scM '.[0] as $o1 | .[1] as $o2 | ($o1 + $o2)'
+++ echo '[]'
+++ echo
+ TAGS='[]'
+ TAGS_URL=
+ '[' -n '' ']'
+ echo '[]'
[]

New Behavior

+ echo '["85ca52e","8b6b599","a45283c","f979df8","7288fb5","49b4cee","37203a4","ea79042","2ea99cd","cfe300a","e7fa403","d435e1a","3f3409d","21ef52d","73e2758","374418f","9ca76fd","7d508c7","ff67f88","b8f3d7f","a9ba2a0","6cf487f","9c41f85","7ec76f3","b330f93","f6415c0","a934bce","1caeda6","89d4572","84af8bd","549d5b5","57b97f6","ce56af3","845c62b","5299dbf","a583a95","f031c46","915bde4","2ec84eb","3939b98","0e5592b","44d8e1a","ec4aa91","6cdb149","fafed78","ad9a69e","42c829d","69d7d6a","cd40c05","3fad187","4b269d1","0e709df","97b3c22","a94c050","1d36acf","a9b5ae6","f5ef22c","90f3b21","64005cf","aa13a0d","e46b0c6","00d08cb","d231465","9550061","c9ffd9d","3691108","254da03","e9ef7e6","5cfd159","7150030","1be08cf","5ae37fb","e100f29","758f64c","58f385f","f005c77","cd61cde","8116e8a","eafa510","06c73c0","37a91bb","1f94e8d","be1def7","8182802","c799ad7","5073095","b289a4d","b9970f5","c14eb91","9703b4c","1e4d8bf","a49fd77","e2c91f2","ffa18c3","a750e90","e7b952a","555b400","1972eed","214fb17","f6833f6","55b744d","786b3a6","4c61a17","4327a53","3e32672","1b9512e","15212f2","986c0a8","c617277","228818a","a9d7efe","db6a0be","9de76eb","752cbfd","9899556","8258d80","fdd71f7","ec7761a","3a1e030","19cf79f","80b82f7","01547cf","e070bf6","419550c","5b12e39","3fa2eb0","c6c5b6f","d7e62ed","852770c","dabcf99","13a1aa8","a8c1a81","37330e4","112f021","02eee0f","4a7ad8d","266d45b","017695c","8550bf7","cc04eab","f1462d9","4c3f62d","eb64cd6","1b9cb55","0172257","9119c6b","ae6b52c","6fdf022","e218215","3d69345","060645f","ef5c950","a5931a0","5cac378","3350c1e","0c2795b","f5d12ac","620e218","a85431f","5830a00","e7852ff","63902f6"]'

["85ca52e","8b6b599","a45283c","f979df8","7288fb5","49b4cee","37203a4","ea79042","2ea99cd","cfe300a","e7fa403","d435e1a","3f3409d","21ef52d","73e2758","374418f","9ca76fd","7d508c7","ff67f88","b8f3d7f","a9ba2a0","6cf487f","9c41f85","7ec76f3","b330f93","f6415c0","a934bce","1caeda6","89d4572","84af8bd","549d5b5","57b97f6","ce56af3","845c62b","5299dbf","a583a95","f031c46","915bde4","2ec84eb","3939b98","0e5592b","44d8e1a","ec4aa91","6cdb149","fafed78","ad9a69e","42c829d","69d7d6a","cd40c05","3fad187","4b269d1","0e709df","97b3c22","a94c050","1d36acf","a9b5ae6","f5ef22c","90f3b21","64005cf","aa13a0d","e46b0c6","00d08cb","d231465","9550061","c9ffd9d","3691108","254da03","e9ef7e6","5cfd159","7150030","1be08cf","5ae37fb","e100f29","758f64c","58f385f","f005c77","cd61cde","8116e8a","eafa510","06c73c0","37a91bb","1f94e8d","be1def7","8182802","c799ad7","5073095","b289a4d","b9970f5","c14eb91","9703b4c","1e4d8bf","a49fd77","e2c91f2","ffa18c3","a750e90","e7b952a","555b400","1972eed","214fb17","f6833f6","55b744d","786b3a6","4c61a17","4327a53","3e32672","1b9512e","15212f2","986c0a8","c617277","228818a","a9d7efe","db6a0be","9de76eb","752cbfd","9899556","8258d80","fdd71f7","ec7761a","3a1e030","19cf79f","80b82f7","01547cf","e070bf6","419550c","5b12e39","3fa2eb0","c6c5b6f","d7e62ed","852770c","dabcf99","13a1aa8","a8c1a81","37330e4","112f021","02eee0f","4a7ad8d","266d45b","017695c","8550bf7","cc04eab","f1462d9","4c3f62d","eb64cd6","1b9cb55","0172257","9119c6b","ae6b52c","6fdf022","e218215","3d69345","060645f","ef5c950","a5931a0","5cac378","3350c1e","0c2795b","f5d12ac","620e218","a85431f","5830a00","e7852ff","63902f6"]
mbentley commented 7 years ago

test this please

mbentley commented 7 years ago

Thanks for the contribution! LGTM.