From ca1677f6be565ee887fa4e3ad701b2928cb44ec6 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:03:29 +0900 Subject: [PATCH 01/10] feat: test --- Pipfile | 12 +++ Pipfile.lock | 295 +++++++++++++++++++++++++++++++++++++++++++++++++++ app.py | 11 ++ 3 files changed, 318 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 app.py diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..b0954ba --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +kubernetes = "*" + +[dev-packages] + +[requires] +python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..00b7991 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,295 @@ +{ + "_meta": { + "hash": { + "sha256": "09f895fe336307b680295d201cd02955170c9145a3053d1cf97fc93aafa05018" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.10" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "cachetools": { + "hashes": [ + "sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945", + "sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105" + ], + "markers": "python_version >= '3.7'", + "version": "==5.3.3" + }, + "certifi": { + "hashes": [ + "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f", + "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1" + ], + "markers": "python_version >= '3.6'", + "version": "==2024.2.2" + }, + "charset-normalizer": { + "hashes": [ + "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027", + "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087", + "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786", + "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8", + "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09", + "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185", + "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574", + "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e", + "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519", + "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898", + "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269", + "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3", + "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f", + "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6", + "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8", + "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a", + "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73", + "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc", + "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714", + "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2", + "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc", + "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce", + "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d", + "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e", + "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6", + "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269", + "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96", + "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d", + "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a", + "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4", + "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77", + "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d", + "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0", + "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed", + "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068", + "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac", + "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25", + "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8", + "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab", + "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26", + "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2", + "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db", + "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f", + "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5", + "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99", + "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c", + "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d", + "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811", + "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa", + "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a", + "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03", + "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b", + "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04", + "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c", + "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001", + "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458", + "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389", + "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99", + "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985", + "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537", + "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238", + "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f", + "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d", + "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796", + "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a", + "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143", + "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8", + "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c", + "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5", + "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5", + "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711", + "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4", + "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6", + "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c", + "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7", + "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4", + "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b", + "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae", + "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12", + "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c", + "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae", + "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8", + "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887", + "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b", + "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4", + "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f", + "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5", + "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33", + "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519", + "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.3.2" + }, + "google-auth": { + "hashes": [ + "sha256:672dff332d073227550ffc7457868ac4218d6c500b155fe6cc17d2b13602c360", + "sha256:d452ad095688cd52bae0ad6fafe027f6a6d6f560e810fec20914e17a09526415" + ], + "markers": "python_version >= '3.7'", + "version": "==2.29.0" + }, + "idna": { + "hashes": [ + "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca", + "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f" + ], + "markers": "python_version >= '3.5'", + "version": "==3.6" + }, + "kubernetes": { + "hashes": [ + "sha256:ab8cb0e0576ccdfb71886366efb102c6a20f268d817be065ce7f9909c631e43e", + "sha256:c4812e227ae74d07d53c88293e564e54b850452715a59a927e7e1bc6b9a60459" + ], + "index": "pypi", + "markers": "python_version >= '3.6'", + "version": "==29.0.0" + }, + "oauthlib": { + "hashes": [ + "sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca", + "sha256:9859c40929662bec5d64f34d01c99e093149682a3f38915dc0655d5a633dd918" + ], + "markers": "python_version >= '3.6'", + "version": "==3.2.2" + }, + "pyasn1": { + "hashes": [ + "sha256:3a35ab2c4b5ef98e17dfdec8ab074046fbda76e281c5a706ccd82328cfc8f64c", + "sha256:cca4bb0f2df5504f02f6f8a775b6e416ff9b0b3b16f7ee80b5a3153d9b804473" + ], + "markers": "python_version >= '3.8'", + "version": "==0.6.0" + }, + "pyasn1-modules": { + "hashes": [ + "sha256:831dbcea1b177b28c9baddf4c6d1013c24c3accd14a1873fffaa6a2e905f17b6", + "sha256:be04f15b66c206eed667e0bb5ab27e2b1855ea54a842e5037738099e8ca4ae0b" + ], + "markers": "python_version >= '3.8'", + "version": "==0.4.0" + }, + "python-dateutil": { + "hashes": [ + "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", + "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "version": "==2.9.0.post0" + }, + "pyyaml": { + "hashes": [ + "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5", + "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc", + "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df", + "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741", + "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206", + "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27", + "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595", + "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62", + "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98", + "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696", + "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290", + "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9", + "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d", + "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6", + "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867", + "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47", + "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486", + "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6", + "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3", + "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007", + "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938", + "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0", + "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c", + "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735", + "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d", + "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28", + "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4", + "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba", + "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8", + "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef", + "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5", + "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd", + "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3", + "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0", + "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515", + "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c", + "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c", + "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924", + "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34", + "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43", + "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859", + "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673", + "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54", + "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a", + "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b", + "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab", + "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa", + "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c", + "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585", + "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d", + "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f" + ], + "markers": "python_version >= '3.6'", + "version": "==6.0.1" + }, + "requests": { + "hashes": [ + "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", + "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.31.0" + }, + "requests-oauthlib": { + "hashes": [ + "sha256:7dd8a5c40426b779b0868c404bdef9768deccf22749cde15852df527e6269b36", + "sha256:b3dffaebd884d8cd778494369603a9e7b58d29111bf6b41bdc2dcd87203af4e9" + ], + "markers": "python_version >= '3.4'", + "version": "==2.0.0" + }, + "rsa": { + "hashes": [ + "sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7", + "sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21" + ], + "markers": "python_version >= '3.6' and python_version < '4'", + "version": "==4.9" + }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "version": "==1.16.0" + }, + "urllib3": { + "hashes": [ + "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d", + "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19" + ], + "markers": "python_version >= '3.8'", + "version": "==2.2.1" + }, + "websocket-client": { + "hashes": [ + "sha256:10e511ea3a8c744631d3bd77e61eb17ed09304c413ad42cf6ddfa4c7787e8fe6", + "sha256:f4c3d22fec12a2461427a29957ff07d35098ee2d976d3ba244e688b8b4057588" + ], + "markers": "python_version >= '3.8'", + "version": "==1.7.0" + } + }, + "develop": {} +} diff --git a/app.py b/app.py new file mode 100644 index 0000000..ec21aa1 --- /dev/null +++ b/app.py @@ -0,0 +1,11 @@ +from kubernetes import client, config, V1ConfigMapList + +config.load_kube_config() + +v1 = client.CoreV1Api() +configmaps = v1.list_namespaced_config_map("airflow") + +print("Listing configmaps with their annotations:") + +for configmap in configmaps.items: + print(f"{configmap.metadata.name}: {configmap.metadata.annotations}") From bc3969f3fc1be581fb96524f33bdf746bc5c8650 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:18:36 +0900 Subject: [PATCH 02/10] feat: copy configmaps and secrets --- app.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index ec21aa1..233adf8 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,56 @@ -from kubernetes import client, config, V1ConfigMapList +from kubernetes import client, config -config.load_kube_config() +config.load_kube_config(context="kind-kind") v1 = client.CoreV1Api() -configmaps = v1.list_namespaced_config_map("airflow") -print("Listing configmaps with their annotations:") +# Get a list of namespaces +namespaces = v1.list_namespace() + +# Get configmaps and secrets for all namespaces +configmaps = v1.list_config_map_for_all_namespaces() +secrets = v1.list_secret_for_all_namespaces() + +# Find the annotation "ns-object-mirror/to" in the configmap, which is a comma-separated list of namespaces to mirror the object to for configmap in configmaps.items: - print(f"{configmap.metadata.name}: {configmap.metadata.annotations}") + if "ns-object-mirror/to" in configmap.metadata.annotations if configmap.metadata.annotations is not None else False: + namespaces = configmap.metadata.annotations["ns-object-mirror/to"].split(",") + print(f"ConfigMap {configmap.metadata.name} should be mirrored to the following namespaces: {namespaces}") + + for namespace in namespaces: + if namespace not in [ns.metadata.name for ns in namespaces.items]: + print(f"Namespace {namespace} does not exist. Skipping.") + continue + else: + new_configmap = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta(name=configmap.metadata.name), + data=configmap.data + ) + v1.create_namespaced_config_map(namespace, new_configmap) + print(f"ConfigMap {configmap.metadata.name} has been mirrored to namespace {namespace}.") + else: + print(f"ConfigMap {configmap.metadata.name} in {configmap.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") + +for secret in secrets.items: + if "ns-object-mirror/to" in secret.metadata.annotations if secret.metadata.annotations is not None else False: + namespaces = secret.metadata.annotations["ns-object-mirror/to"].split(",") + print(f"Secret {secret.metadata.name} should be mirrored to the following namespaces: {namespaces}") + + for namespace in namespaces: + if namespace not in [ns.metadata.name for ns in namespaces.items]: + print(f"Namespace {namespace} does not exist. Skipping.") + continue + else: + new_secret = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta(name=secret.metadata.name), + data=secret.data + ) + v1.create_namespaced_secret(namespace, new_secret) + print(f"Secret {secret.metadata.name} has been mirrored to namespace {namespace}.") + else: + print(f"Secret {secret.metadata.name} in {secret.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") From b75512a664a4d396c517798add613edcdf334dbc Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 19:36:51 +0900 Subject: [PATCH 03/10] feat: add test and methodize --- app.py | 108 ++++++++++++++++++++++++++++++-------------------------- test.py | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 50 deletions(-) create mode 100644 test.py diff --git a/app.py b/app.py index 233adf8..0f46355 100644 --- a/app.py +++ b/app.py @@ -4,53 +4,61 @@ v1 = client.CoreV1Api() -# Get a list of namespaces -namespaces = v1.list_namespace() - -# Get configmaps and secrets for all namespaces -configmaps = v1.list_config_map_for_all_namespaces() -secrets = v1.list_secret_for_all_namespaces() - -# Find the annotation "ns-object-mirror/to" in the configmap, which is a comma-separated list of namespaces to mirror the object to - -for configmap in configmaps.items: - if "ns-object-mirror/to" in configmap.metadata.annotations if configmap.metadata.annotations is not None else False: - namespaces = configmap.metadata.annotations["ns-object-mirror/to"].split(",") - print(f"ConfigMap {configmap.metadata.name} should be mirrored to the following namespaces: {namespaces}") - - for namespace in namespaces: - if namespace not in [ns.metadata.name for ns in namespaces.items]: - print(f"Namespace {namespace} does not exist. Skipping.") - continue - else: - new_configmap = client.V1ConfigMap( - api_version="v1", - kind="ConfigMap", - metadata=client.V1ObjectMeta(name=configmap.metadata.name), - data=configmap.data - ) - v1.create_namespaced_config_map(namespace, new_configmap) - print(f"ConfigMap {configmap.metadata.name} has been mirrored to namespace {namespace}.") - else: - print(f"ConfigMap {configmap.metadata.name} in {configmap.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") - -for secret in secrets.items: - if "ns-object-mirror/to" in secret.metadata.annotations if secret.metadata.annotations is not None else False: - namespaces = secret.metadata.annotations["ns-object-mirror/to"].split(",") - print(f"Secret {secret.metadata.name} should be mirrored to the following namespaces: {namespaces}") - - for namespace in namespaces: - if namespace not in [ns.metadata.name for ns in namespaces.items]: - print(f"Namespace {namespace} does not exist. Skipping.") - continue - else: - new_secret = client.V1Secret( - api_version="v1", - kind="Secret", - metadata=client.V1ObjectMeta(name=secret.metadata.name), - data=secret.data - ) - v1.create_namespaced_secret(namespace, new_secret) - print(f"Secret {secret.metadata.name} has been mirrored to namespace {namespace}.") - else: - print(f"Secret {secret.metadata.name} in {secret.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") +def mirror_configmaps(configmaps, namespaces): + for configmap in configmaps.items: + if "ns-object-mirror/to" in configmap.metadata.annotations if configmap.metadata.annotations is not None else False: + namespaces_to = configmap.metadata.annotations["ns-object-mirror/to"].split(",") + print(f"ConfigMap {configmap.metadata.name} should be mirrored to the following namespaces: {namespaces_to}") + + for namespace in namespaces_to: + if namespace not in namespaces: + print(f"Namespace {namespace} does not exist. Skipping.") + continue + else: + new_configmap = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta(name=configmap.metadata.name), + data=configmap.data + ) + v1.create_namespaced_config_map(namespace, new_configmap) + print(f"ConfigMap {configmap.metadata.name} has been mirrored to namespace {namespace}.") + else: + print(f"ConfigMap {configmap.metadata.name} in {configmap.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") + +def mirror_secrets(secrets, namespaces): + for secret in secrets.items: + if "ns-object-mirror/to" in secret.metadata.annotations if secret.metadata.annotations is not None else False: + namespaces_to = secret.metadata.annotations["ns-object-mirror/to"].split(",") + print(f"Secret {secret.metadata.name} should be mirrored to the following namespaces: {namespaces_to}") + + for namespace in namespaces_to: + if namespace not in namespaces: + print(f"Namespace {namespace} does not exist. Skipping.") + continue + else: + new_secret = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta(name=secret.metadata.name), + data=secret.data + ) + v1.create_namespaced_secret(namespace, new_secret) + print(f"Secret {secret.metadata.name} has been mirrored to namespace {namespace}.") + else: + print(f"Secret {secret.metadata.name} in {secret.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") + +def run_mirror(): + # Get a list of namespaces + namespaces = [namespace.metadata.name for namespace in v1.list_namespace().items] + + # Get configmaps and secrets for all namespaces + configmaps = v1.list_config_map_for_all_namespaces() + secrets = v1.list_secret_for_all_namespaces() + + # Mirror configmaps and secrets + mirror_configmaps(configmaps, namespaces) + mirror_secrets(secrets, namespaces) + +if __name__ == "__main__": + run_mirror() diff --git a/test.py b/test.py new file mode 100644 index 0000000..30fca0f --- /dev/null +++ b/test.py @@ -0,0 +1,70 @@ +import unittest +from kubernetes import client, config +import app + +class TestMirror(unittest.TestCase): + def setUp(self): + config.load_kube_config(context="kind-kind") + self.v1 = client.CoreV1Api() + + # Create test namespace + self.test_namespace = client.V1Namespace( + api_version="v1", + kind="Namespace", + metadata=client.V1ObjectMeta(name="test-namespace") + ) + self.v1.create_namespace(self.test_namespace) + + # Create another namespace to mirror to + self.mirror_namespace = client.V1Namespace( + api_version="v1", + kind="Namespace", + metadata=client.V1ObjectMeta(name="mirror-namespace") + ) + self.v1.create_namespace(self.mirror_namespace) + + # Create test configmap + self.test_configmap = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta( + name="test-configmap", + namespace="test-namespace", + annotations={"ns-object-mirror/to": "mirror-namespace"} + ), + data={"key": "value"} + ) + self.v1.create_namespaced_config_map("test-namespace", self.test_configmap) + + # Create test secret + self.test_secret = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta( + name="test-secret", + namespace="test-namespace", + annotations={"ns-object-mirror/to": "mirror-namespace"} + ), + data={"key": "dmFsdWU="} # "value" base64 encoded + ) + self.v1.create_namespaced_secret("test-namespace", self.test_secret) + + def test_mirror(self): + app.run_mirror() + + # Check if the configmap and secret are mirrored to the mirror-namespace + mirrored_configmap = self.v1.read_namespaced_config_map("test-configmap", "mirror-namespace") + self.assertEqual(mirrored_configmap.data, {"key": "value"}) + + mirrored_secret = self.v1.read_namespaced_secret("test-secret", "mirror-namespace") + self.assertEqual(mirrored_secret.data, {"key": "dmFsdWU="}) + + def tearDown(self): + # Delete test objects + self.v1.delete_namespaced_config_map("test-configmap", "test-namespace") + self.v1.delete_namespaced_secret("test-secret", "test-namespace") + self.v1.delete_namespace("test-namespace") + self.v1.delete_namespace("mirror-namespace") + +if __name__ == '__main__': + unittest.main() From f13e98b5df26165b6e76ef6e90b8d81eba1af6ed Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:11:12 +0900 Subject: [PATCH 04/10] feat: only update if changed --- Dockerfile | 21 ++++++++++++ app.py | 71 ++++++++++++++++++++++++++++++++++------- test.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 11 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d573ec8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Use an official Python runtime as a parent image +FROM python:3.10 + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Install pipenv +RUN pip install --upgrade pip && \ + pip install pipenv + +# Copy Pipfile to the working directory +COPY Pipfile /usr/src/app/ + +# Install any needed packages specified in Pipfile +RUN pipenv install --deploy --ignore-pipfile + +# Copy the current directory contents into the container at /usr/src/app +COPY . /usr/src/app + +# Run run.sh when the container launches +CMD ["pipenv", "run", "python", "app.py"] diff --git a/app.py b/app.py index 0f46355..70b3d16 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,4 @@ +import time from kubernetes import client, config config.load_kube_config(context="kind-kind") @@ -18,13 +19,35 @@ def mirror_configmaps(configmaps, namespaces): new_configmap = client.V1ConfigMap( api_version="v1", kind="ConfigMap", - metadata=client.V1ObjectMeta(name=configmap.metadata.name), + metadata=client.V1ObjectMeta( + name=configmap.metadata.name, + annotations={k: v for k, v in configmap.metadata.annotations.items() if not k.startswith('ns-object-mirror')} + ), data=configmap.data ) - v1.create_namespaced_config_map(namespace, new_configmap) - print(f"ConfigMap {configmap.metadata.name} has been mirrored to namespace {namespace}.") - else: - print(f"ConfigMap {configmap.metadata.name} in {configmap.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") + try: + old_configmap = v1.read_namespaced_config_map(configmap.metadata.name, namespace) + old_configmap_without_ns_object_mirror_annotations = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta( + name=old_configmap.metadata.name, + annotations={k: v for k, v in old_configmap.metadata.annotations.items() if not k.startswith('ns-object-mirror')} if old_configmap.metadata.annotations is not None else {} + ), + data=None + ) + if old_configmap.data != new_configmap.data: + v1.replace_namespaced_config_map(configmap.metadata.name, namespace, new_configmap) + print(f"ConfigMap/Data for {configmap.metadata.name} in namespace {namespace} has been updated.") + elif old_configmap_without_ns_object_mirror_annotations.metadata.annotations != new_configmap.metadata.annotations: + v1.patch_namespaced_config_map(configmap.metadata.name, namespace, new_configmap) + print(f"ConfigMap/Annotations for {configmap.metadata.name} in namespace {namespace} have been updated.") + else: + print(f"ConfigMap {configmap.metadata.name} in namespace {namespace} is already up-to-date. Skipping.") + except client.rest.ApiException as e: + if e.status == 404: + v1.create_namespaced_config_map(namespace, new_configmap) + print(f"ConfigMap {configmap.metadata.name} has been mirrored to namespace {namespace}.") def mirror_secrets(secrets, namespaces): for secret in secrets.items: @@ -40,13 +63,35 @@ def mirror_secrets(secrets, namespaces): new_secret = client.V1Secret( api_version="v1", kind="Secret", - metadata=client.V1ObjectMeta(name=secret.metadata.name), + metadata=client.V1ObjectMeta( + name=secret.metadata.name, + annotations={k: v for k, v in secret.metadata.annotations.items() if not k.startswith('ns-object-mirror')} + ), data=secret.data ) - v1.create_namespaced_secret(namespace, new_secret) - print(f"Secret {secret.metadata.name} has been mirrored to namespace {namespace}.") - else: - print(f"Secret {secret.metadata.name} in {secret.metadata.namespace} does not have the annotation 'ns-object-mirror/to'. Skipping.") + try: + old_secret = v1.read_namespaced_secret(secret.metadata.name, namespace) + old_secret_without_ns_object_mirror_annotations = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta( + name=old_secret.metadata.name, + annotations={k: v for k, v in old_secret.metadata.annotations.items() if not k.startswith('ns-object-mirror')} if old_secret.metadata.annotations is not None else {} + ), + data=None + ) + if old_secret.data != new_secret.data: + v1.replace_namespaced_secret(secret.metadata.name, namespace, new_secret) + print(f"Secret/Data for {secret.metadata.name} in namespace {namespace} has been updated.") + elif old_secret_without_ns_object_mirror_annotations.metadata.annotations != new_secret.metadata.annotations: + v1.patch_namespaced_secret(secret.metadata.name, namespace, new_secret) + print(f"Secret/Annotations for {secret.metadata.name} in namespace {namespace} have been updated.") + else: + print(f"Secret {secret.metadata.name} in namespace {namespace} is already up-to-date. Skipping.") + except client.rest.ApiException as e: + if e.status == 404: + v1.create_namespaced_secret(namespace, new_secret) + print(f"Secret {secret.metadata.name} has been mirrored to namespace {namespace}.") def run_mirror(): # Get a list of namespaces @@ -61,4 +106,8 @@ def run_mirror(): mirror_secrets(secrets, namespaces) if __name__ == "__main__": - run_mirror() + while True: + print("Running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())) + run_mirror() + print("Finished running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) + ". Sleeping for 30 seconds.") + time.sleep(30) diff --git a/test.py b/test.py index 30fca0f..84a6898 100644 --- a/test.py +++ b/test.py @@ -66,5 +66,98 @@ def tearDown(self): self.v1.delete_namespace("test-namespace") self.v1.delete_namespace("mirror-namespace") +# Test if existing mirror objects are updated from the original +class TestUpdateMirror(unittest.TestCase): + def setUp(self): + config.load_kube_config(context="kind-kind") + self.v1 = client.CoreV1Api() + + # Create test namespace + self.test_namespace = client.V1Namespace( + api_version="v1", + kind="Namespace", + metadata=client.V1ObjectMeta(name="test-namespace-2") + ) + self.v1.create_namespace(self.test_namespace) + + # Create another namespace to mirror to + self.mirror_namespace = client.V1Namespace( + api_version="v1", + kind="Namespace", + metadata=client.V1ObjectMeta(name="mirror-namespace-2") + ) + self.v1.create_namespace(self.mirror_namespace) + + # Create test configmap + self.test_configmap = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta( + name="test-configmap", + namespace="test-namespace-2", + annotations={"ns-object-mirror/to": "mirror-namespace-2"} + ), + data={"key": "value"} + ) + self.v1.create_namespaced_config_map("test-namespace-2", self.test_configmap) + + # Create mirrored configmap + self.mirrored_configmap = client.V1ConfigMap( + api_version="v1", + kind="ConfigMap", + metadata=client.V1ObjectMeta( + name="test-configmap", + namespace="mirror-namespace-2", + annotations={"ns-object-mirror/to": "mirror-namespace-2"} + ), + data={"key": "old-value"} + ) + self.v1.create_namespaced_config_map("mirror-namespace-2", self.mirrored_configmap) + + # Create test secret + self.test_secret = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta( + name="test-secret", + namespace="test-namespace-2", + annotations={"ns-object-mirror/to": "mirror-namespace-2"} + ), + data={"key": "dmFsdWU="} # "value" base64 encoded + ) + self.v1.create_namespaced_secret("test-namespace-2", self.test_secret) + + # Create mirrored secret + self.mirrored_secret = client.V1Secret( + api_version="v1", + kind="Secret", + metadata=client.V1ObjectMeta( + name="test-secret", + namespace="mirror-namespace-2", + annotations={"ns-object-mirror/to": "mirror-namespace-2"} + ), + data={"key": "b2xkLXZhbHVl"} # "old-value" base64 encoded + ) + self.v1.create_namespaced_secret("mirror-namespace-2", self.mirrored_secret) + + def test_update_mirror(self): + app.run_mirror() + + # Check if the configmap and secret are mirrored to the mirror-namespace + mirrored_configmap = self.v1.read_namespaced_config_map("test-configmap", "mirror-namespace-2") + self.assertEqual(mirrored_configmap.data, {"key": "value"}) + + mirrored_secret = self.v1.read_namespaced_secret("test-secret", "mirror-namespace-2") + self.assertEqual(mirrored_secret.data, {"key": "dmFsdWU="}) + + def tearDown(self): + # Delete test objects + self.v1.delete_namespaced_config_map("test-configmap", "test-namespace-2") + self.v1.delete_namespaced_config_map("test-configmap", "mirror-namespace-2") + self.v1.delete_namespaced_secret("test-secret", "test-namespace-2") + self.v1.delete_namespaced_secret("test-secret", "mirror-namespace-2") + self.v1.delete_namespace("test-namespace-2") + self.v1.delete_namespace("mirror-namespace-2") + if __name__ == '__main__': unittest.main() From 10d6996c1b4d15c01d6df22e6b9010d75022242b Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:14:54 +0900 Subject: [PATCH 05/10] feat: add ci --- .github/workflows/ci.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..29997b4 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,39 @@ +name: CI/CD Workflow + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install pipenv + pipenv install --dev + + - name: Run tests + run: | + pipenv run python test.py + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/ns-object-mirror:latest From f0230cb2f3b67764dd01f2e8b52acd7ecc3b52b9 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:18:25 +0900 Subject: [PATCH 06/10] fix: use default config for app and kind-kind context for CI --- .github/workflows/ci.yaml | 3 +++ app.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29997b4..03126df 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,9 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 + - name: Set up Python uses: actions/setup-python@v2 with: diff --git a/app.py b/app.py index 70b3d16..1c1a42e 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,7 @@ import time from kubernetes import client, config -config.load_kube_config(context="kind-kind") +config.load_kube_config() v1 = client.CoreV1Api() From 015764baa8e4c881fd86dcb9f4fe51ba178dd129 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:21:08 +0900 Subject: [PATCH 07/10] fix(ci): use cluster_name kind --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 03126df..01e271e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,6 +12,8 @@ jobs: - name: Create k8s Kind Cluster uses: helm/kind-action@v1 + with: + cluster_name: kind - name: Set up Python uses: actions/setup-python@v2 From 38c7340b544831a04eac60d30fd7ce20aad216f5 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:24:43 +0900 Subject: [PATCH 08/10] fix(ci): only run push on main --- .github/workflows/ci.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 01e271e..9653fe2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,7 @@ name: CI/CD Workflow on: [push] jobs: - build: + test: runs-on: ubuntu-latest steps: @@ -29,6 +29,15 @@ jobs: run: | pipenv run python test.py + build_and_push: + needs: test + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: From d205df6c3f28d521b3d6c11afabccf59fea20c58 Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:28:43 +0900 Subject: [PATCH 09/10] fix(ci): update github action versions --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9653fe2..402e41d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Create k8s Kind Cluster uses: helm/kind-action@v1 @@ -16,9 +16,9 @@ jobs: cluster_name: kind - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.10 - name: Install dependencies run: | @@ -36,17 +36,17 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . push: true From 6b970d9ca7efdcf117ebcb490db14818ecab53ec Mon Sep 17 00:00:00 2001 From: "Alexander 4584443+DragonStuff@users.noreply.github.com" <4584443+DragonStuff@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:31:28 +0900 Subject: [PATCH 10/10] feature(format): fix formatting --- .github/workflows/ci.yaml | 2 +- app.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 402e41d..21d5576 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.10 + python-version: 3.10.14 - name: Install dependencies run: | diff --git a/app.py b/app.py index 1c1a42e..b615924 100644 --- a/app.py +++ b/app.py @@ -107,7 +107,7 @@ def run_mirror(): if __name__ == "__main__": while True: - print("Running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())) + print("--- Running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) + " ---") run_mirror() - print("Finished running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) + ". Sleeping for 30 seconds.") + print("--- Finished running mirror at " + time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) + ". Sleeping for 30 seconds." + " ---") time.sleep(30)