<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>The Wombelix Post - Coding</title><link href="https://dominik.wombacher.cc/" rel="alternate"/><link href="/feeds/tag_coding.atom.xml" rel="self"/><id>https://dominik.wombacher.cc/</id><updated>2024-11-22T00:00:00+01:00</updated><entry><title>SUSE Hack Week 2024 - Day 5</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-5.html" rel="alternate"/><published>2024-11-22T00:00:00+01:00</published><updated>2024-11-22T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-22:/posts/suse-hack-week-2024-day-5.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;The problem with a failing test was driving me nuts &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html"&gt;yesterday&lt;/a&gt;.
And I made a classic Engineer mistake, I didn't take a step back to clear my head and recharge  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-5.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;The problem with a failing test was driving me nuts &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html"&gt;yesterday&lt;/a&gt;.
And I made a classic Engineer mistake, I didn't take a step back to clear my head and recharge. I continued to work
on the same problem till 1 AM, of course without a result, before I gave up. After some sleep and getting back to
work with a structured approach, it took me less than 15 minutes today to validate my theory and figure out what
the problem was... Damn, I'm happy I found it but all the time I wasted last night... Whatever, chasing the
white rabbit and getting a bit lost happens to the best sometimes.&lt;/p&gt;
&lt;p&gt;So, what was the issue? I want to know if a method was called with a specific set of args by using
&lt;code&gt;assert_called_once_with&lt;/code&gt;. Visually, the expected and actual values match. But I pass an object of
&lt;code&gt;model.Project&lt;/code&gt; and Mock checks if it's the same instance of the object, not if the content matches.
I create a &lt;code&gt;project&lt;/code&gt; object in my tests, and &lt;code&gt;pagure.lib.tasks_services.trigger_ci_build()&lt;/code&gt; does
the same. Even though the keys and values look identical, there are two different objects and the assertion fails.&lt;/p&gt;
&lt;p&gt;To solve it, I have to Mock &lt;code&gt;pagure.lib.query.get_authorized_project()&lt;/code&gt; and inject the &lt;code&gt;project&lt;/code&gt; object
that's created in the test. Then the whole thing works as I want it. Next step: Refactoring to use &lt;code&gt;model.PullRequest&lt;/code&gt;
object with access to all pull request related information instead of &lt;code&gt;pull_request_id&lt;/code&gt; and &lt;code&gt;pull_request_uid&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;That worked pretty well, writing the tests before the actual code feels weird at first but today that was a productivity
booster. It's much easier to focus on the next feature or refactoring, while I don't have to worry that silently
breaks something else. As long the other tests continue to pass, I'm still on track. I tried Test-Driven-Development
before, but I guess bad habits came back and I never went all-in with it for a longer session.&lt;/p&gt;
&lt;p&gt;This &lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5511"&gt;Pull Request&lt;/a&gt; contains the current state and the outcome of my
Hack Week project. I finished around 2/3 of what was planned, I hope to get the rest done in the next week or two.&lt;/p&gt;
&lt;p&gt;I wrote a lot Python code before, including tests, but a couple days with an intensive focus helped a lot to
brush up my knowledge. Good chances that I not waste time with such a stupid problem next time ;) This week
re-affirmed that my passion is solving problems and writing code. I hope I can do that more regularly in future
and have the opportunity to free up time and attend SUSE Hack Week 25 as well.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 4</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-4.html" rel="alternate"/><published>2024-11-21T00:00:00+01:00</published><updated>2024-11-21T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-21:/posts/suse-hack-week-2024-day-4.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Today was the focus on writing the pagure ci plugin and fine-tune my design and architecture assumptions on the way.
Basically transferring the outcome of &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html"&gt;day 3&lt;/a&gt; into some code  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-4.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Today was the focus on writing the pagure ci plugin and fine-tune my design and architecture assumptions on the way.
Basically transferring the outcome of &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html"&gt;day 3&lt;/a&gt; into some code.
I decided to use a Test-Driven approach and to keep a close eye on existing pagure ci related tests while
I have to refactor some existing code too.&lt;/p&gt;
&lt;p&gt;Before I started to write tests, I wanted to validate a couple of assumptions on my pagure dev instance.
Unfortunately I had to fix a couple errors over there (file permissions, pagure_worker runs as apache and
not git user, db scheme forgotten to upgrade...) before I finally could start. It's always a good opportunity,
you learn most when things are broken. But I lost quite some coding time that way...&lt;/p&gt;
&lt;p&gt;Speaking of coding, the main challenge was that some information I want/need in my generic plugin are currently not passed.&lt;/p&gt;
&lt;p&gt;What we currently have doesn't leaves much room for the plugin to get additional data:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;project_path&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;job&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;token&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;cause&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-p"&gt;):&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;What I want in future to make things more flexible:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;model&lt;/span&gt;&lt;span class="pygments-o"&gt;.&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;bool&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;bool&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-nb"&gt;str&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;        &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt; &lt;span class="pygments-o"&gt;=&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt; &lt;span class="pygments-o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This could be further improved by passing &lt;code&gt;model.PullRequest&lt;/code&gt; instead of &lt;code&gt;pull_request_id&lt;/code&gt; and &lt;code&gt;pull_request_uid&lt;/code&gt;.
Then it's up to the pagure ci plugin to decide what data are needed, similar as with &lt;code&gt;project&lt;/code&gt;.
When I'm done with the &lt;code&gt;generic&lt;/code&gt; plugin then the existing &lt;code&gt;jenkins&lt;/code&gt; need some refactoring to work with the new parameters.&lt;/p&gt;
&lt;p&gt;I started to write the tests and iterate through the different plugin functionality.
All that went well until I hit a problem that still drives me crazy.
It shouldn't be hard to verify that a method was called with the expected args by using &lt;code&gt;assert_called_once_with&lt;/code&gt;.
But it throws a nice &lt;code&gt;AssertionError: expected call not found.&lt;/code&gt; even though &lt;code&gt;Expected&lt;/code&gt; and &lt;code&gt;Actual&lt;/code&gt; match:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-ne"&gt;AssertionError&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;expected&lt;/span&gt; &lt;span class="pygments-n"&gt;call&lt;/span&gt; &lt;span class="pygments-ow"&gt;not&lt;/span&gt; &lt;span class="pygments-n"&gt;found&lt;/span&gt;&lt;span class="pygments-o"&gt;.&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-n"&gt;Expected&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt; &lt;span class="pygments-n"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-mi"&gt;1&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;name&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-n"&gt;test&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;namespace&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_fork&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;parent_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;),&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'https://ci.example.com/'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'pagure'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'random_token'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'feature'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'main'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;True&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'1'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'720a0568c1274e74966e54b433b2003e'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-n"&gt;E&lt;/span&gt;           &lt;span class="pygments-n"&gt;Actual&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;   &lt;span class="pygments-n"&gt;trigger_build&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;project&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-n"&gt;Project&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-mi"&gt;1&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;name&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-n"&gt;test&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;namespace&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;url&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_fork&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;parent_id&lt;/span&gt;&lt;span class="pygments-p"&gt;:&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;),&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_url&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'https://ci.example.com/'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_job&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'pagure'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_token&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'random_token'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'feature'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;branch_to&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'main'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_pull_request&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;True&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;is_commit&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;False&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;commit_hash&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_id&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'1'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;pull_request_uid&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-s1"&gt;'720a0568c1274e74966e54b433b2003e'&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_username&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;,&lt;/span&gt; &lt;span class="pygments-n"&gt;ci_password&lt;/span&gt;&lt;span class="pygments-o"&gt;=&lt;/span&gt;&lt;span class="pygments-kc"&gt;None&lt;/span&gt;&lt;span class="pygments-p"&gt;)&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I take a break and try it again tomorrow after some sleep. Maybe I'm tired and missing something obvious.
But for me both look the same and there shouldn't be an assertion error.&lt;/p&gt;
&lt;p&gt;Let's hope I can figure out tomorrow what's going wrong here...&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 3</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-3.html" rel="alternate"/><published>2024-11-20T00:00:00+01:00</published><updated>2024-11-20T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-20:/posts/suse-hack-week-2024-day-3.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I continued where I left off on the &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html"&gt;second day&lt;/a&gt;,
I was thinking about my architecture last night. AWS CodePipeline requires a bit of a custom implementation
within the AWS  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-3.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I continued where I left off on the &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html"&gt;second day&lt;/a&gt;,
I was thinking about my architecture last night. AWS CodePipeline requires a bit of a custom implementation
within the AWS Account, for example with AWS Lambda, to handle third party repos that are not GitHub, Gitlab or Bitbucket.
Maybe the pagure ci plugin should then a generic webhook style implementation. It defines the payload that is send and the expected
answer to update the PR status. But leaves the actual implementation up to the target system. That way, the plugin isn't
limited to one single service. I can use it to interact with AWS CodePipeline, or directly AWS CodeBuild, or any other system
were I can implement the server side logic myself.&lt;/p&gt;
&lt;p&gt;This shifts the scope of &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
a little, but the outcome stays the same. I probably need two AWS Lambda functions, one to receive the webhook and trigger the build.
Another to receive status updates from CodeBuild phases and send them back to pagure. The AWS credentials for pagure need
permission to trigger the Lambda function for incoming requests. The function has permissions to interact with S3 and
CodePipeline / Codebuild. The outgoing Lambda uses the pagure ci token and gets it from a Env Var or AWS Secrets Manager.
Every component follows the least privilege principle.&lt;/p&gt;
&lt;p&gt;The pagure ci &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/pagure/api/ci/jenkins.py#_33"&gt;jenkins plugin routes&lt;/a&gt; expect a &lt;code&gt;POST&lt;/code&gt;
request but the token is part of the URL. My plugin will use routes like &lt;code&gt;/ci/webhook/&amp;lt;repo&amp;gt;&lt;/code&gt; instead of
&lt;code&gt;/ci/jenkins/&amp;lt;repo&amp;gt;/&amp;lt;pagure_ci_token&amp;gt;/build-finished&lt;/code&gt;. The token has to be submitted as part of the request.
This keeps the token away from plain text logs, it's still a secret and should be treated like that.&lt;/p&gt;
&lt;p&gt;With the idea of a generic plugin in mind, Authentication becomes a challenge.
Calling an AWS Lambda on its function URL works best with a SIGv4 authentication request.
For any other, basic authentication seems the most common and reasonable way.
I have to figure out how to handle this properly. I don't want to add more fields to
pagure ci and the Web UI. First thing in mind: URI Scheme.
&lt;code&gt;https&lt;/code&gt; means plain request with basic auth based on &lt;code&gt;ci_username&lt;/code&gt; and &lt;code&gt;ci_password&lt;/code&gt;, if set.
&lt;code&gt;https+sigv4&lt;/code&gt; = AWS SIGv4 authentication request, uses &lt;code&gt;ci_username&lt;/code&gt; (Access Key) and &lt;code&gt;ci_password&lt;/code&gt; (Secret Key).&lt;/p&gt;
&lt;p&gt;I'll add the Lambda code and a IaC example (AWS CDK, AWS CloudFormation or OpenTofu/Terraform) to the pagure repo.
That way the end-to-end integration becomes a first-class citizen in pagure, not just the ci plugin.&lt;/p&gt;
&lt;p&gt;The time I could invest today was pretty limited and focused on further Architecture details.
I started with the pagure ci plugin, it is in an early stage but I'm confident that there is more to demonstrate tomorrow.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 2</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-2.html" rel="alternate"/><published>2024-11-19T00:00:00+01:00</published><updated>2024-11-19T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-19:/posts/suse-hack-week-2024-day-2.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Second day, time to continue the work on
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
after a successful &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html"&gt;first day&lt;/a&gt;.
The focus was on research, tests and design decisions for the AWS CodePipeline pagure ci  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-2.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Second day, time to continue the work on
&lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;my project&lt;/a&gt;
after a successful &lt;a class="reference external" href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html"&gt;first day&lt;/a&gt;.
The focus was on research, tests and design decisions for the AWS CodePipeline pagure ci plugin.
I want to make the set up on the AWS side as easy and maintenance free as possible.
But keep the code and customization logic in pagure lightweight too.&lt;/p&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html"&gt;Buildspec&lt;/a&gt;
that CodeBuild uses to run a build should be in the git repository and managed independently.
The current design and workflow I have in mind looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol class="arabic"&gt;
&lt;li&gt;&lt;p class="first"&gt;User performs Git push to repository on pagure&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;pagure ci triggers AWS Lambda through function URL&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;On commits and / or on pull-requests&lt;/li&gt;
&lt;li&gt;Payload contains: cause, repo, branch, branch_to&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS Lambda gets buildspec from default branch and performs Git clone&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Clone branch depends on received payload&lt;/li&gt;
&lt;li&gt;Buildspec is used from default branch to reduce risk of untrusted Pull Requests&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS Lambda inject payload data into buildspec, generates zip archive and uploads it to S3&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodePipeline detects changed file on S3&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodePipeline retrieves archive and triggers AWS CodeBuild&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodeBuild gets pagure ci token from AWS Secrets Manager&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Injected as Environment Variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;AWS CodeBuild executes phases and reports status back to pagure ci&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;I still have to work out some details but I can start the implementation tomorrow.&lt;/p&gt;
&lt;p&gt;Another thing I stumbled across, interesting: The pagure ci code contains a &lt;code&gt;ci_username&lt;/code&gt;
and &lt;code&gt;ci_password&lt;/code&gt; field &lt;a class="reference external" href="https://pagure.io/pagure/c/9c6dee24463fdbfe88c21cfa4a6d7d3af87a5b7c?branch=master"&gt;since 5 years&lt;/a&gt;.
But for whatever reason, they were never added to the &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/pagure/hooks/pagure_ci.py#_177"&gt;fields that are rendered in the Web UI&lt;/a&gt;.
Also, the WTForms field type for &lt;code&gt;ci_password&lt;/code&gt; was &lt;code&gt;StringField&lt;/code&gt;, it should be &lt;code&gt;PasswordField&lt;/code&gt; instead.&lt;/p&gt;
&lt;pre class="code diff literal-block"&gt;
&lt;span class="pygments-gh"&gt;diff --git a/pagure/hooks/pagure_ci.py b/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gh"&gt;index 819b2a1b..38702a72 100644&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;--- a/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+++ b/pagure/hooks/pagure_ci.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -121,7 +121,7 &amp;#64;&amp;#64; class PagureCiForm(FlaskForm):&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       [wtforms.validators.Optional(), wtforms.validators.Length(max=255)],&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   )&lt;span class="pygments-w"&gt;

&lt;/span&gt;&lt;span class="pygments-gd"&gt;-    ci_password = wtforms.StringField(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    ci_password = wtforms.PasswordField(&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       &amp;quot;Password to authenticate with if needed&amp;quot;,&lt;span class="pygments-w"&gt;
 &lt;/span&gt;       [wtforms.validators.Optional(), wtforms.validators.Length(max=255)],&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   )&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -174,7 +174,7 &amp;#64;&amp;#64; class PagureCi(BaseHook):&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   form = PagureCiForm&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   db_object = PagureCITable&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   backref = &amp;quot;ci_hook&amp;quot;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;-    form_fields = [&amp;quot;ci_type&amp;quot;, &amp;quot;ci_url&amp;quot;, &amp;quot;ci_job&amp;quot;, &amp;quot;active_commit&amp;quot;, &amp;quot;active_pr&amp;quot;]&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    form_fields = [&amp;quot;ci_type&amp;quot;, &amp;quot;ci_url&amp;quot;, &amp;quot;ci_job&amp;quot;, &amp;quot;ci_username&amp;quot;, &amp;quot;ci_password&amp;quot;, &amp;quot;active_commit&amp;quot;, &amp;quot;active_pr&amp;quot;]&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   runner = PagureCIRunner&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   &amp;#64;classmethod&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Last but not least, when I &lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5491"&gt;refactored the pagure ci code 5 months ago&lt;/a&gt;
one problem stayed unnoticed: To add routes to a Flask Blueprint, the modules need to be imported before the Blueprint is registered with the app.
This was the case before the refactoring, but now the import to add the routes didn't happen and at the time the pagure ci plugin is activated, it's too late.
I doubt that I came up with the most elegant solution, but at least a functional ;)&lt;/p&gt;
&lt;pre class="code diff literal-block"&gt;
&lt;span class="pygments-gh"&gt;diff --git a/pagure/flask_app.py b/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gh"&gt;index e9baa507..c22ea72c 100644&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gd"&gt;--- a/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+++ b/pagure/flask_app.py&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -11,6 +11,8 &amp;#64;&amp;#64;&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;from __future__ import absolute_import, unicode_literals&lt;span class="pygments-w"&gt;

&lt;/span&gt;import datetime&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+import importlib&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;import gc&lt;span class="pygments-w"&gt;
&lt;/span&gt;import logging&lt;span class="pygments-w"&gt;
&lt;/span&gt;import os&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gu"&gt;&amp;#64;&amp;#64; -135,6 +137,14 &amp;#64;&amp;#64; def create_app(config=None):&lt;/span&gt;&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   from pagure.api import API  # noqa: E402&lt;span class="pygments-w"&gt;

&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    # Load all configured pagure ci plugins once to initiate routes&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    # Required before Blueprint registration&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    ci_plugins = {}&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+    for ci_type in pagure_config[&amp;quot;PAGURE_CI_SERVICES&amp;quot;]:&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+        ci_plugins[ci_type] = importlib.import_module(&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+            &amp;quot;pagure.api.ci.&amp;quot; + ci_type&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+        )&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;&lt;span class="pygments-gi"&gt;+&lt;/span&gt;&lt;span class="pygments-w"&gt;
 &lt;/span&gt;   app.register_blueprint(API)&lt;span class="pygments-w"&gt;

 &lt;/span&gt;   from pagure.ui import UI_NS  # noqa: E402&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I iterate over all configured pagure ci plugins and import them immediately before the API Blueprint is registered.
That way the routes, required to receive status updates, are added, variable &lt;code&gt;ci_plugins&lt;/code&gt; is kind of a dummy and never used.&lt;/p&gt;
&lt;p&gt;I was hoping for a bit more progress today, troubleshooting the route import bug and planning took quite a while.
Three days left, I'm still on track and confident that I have something usable at the end of the week.&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>SUSE Hack Week 2024 - Day 1</title><link href="https://dominik.wombacher.cc/posts/suse-hack-week-2024-day-1.html" rel="alternate"/><published>2024-11-18T00:00:00+01:00</published><updated>2024-11-18T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-18:/posts/suse-hack-week-2024-day-1.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I started the work on my project &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;AWS CodePipeline CI plugin for pagure on code.opensuse.org&lt;/a&gt;
with my nemesis, the mysterious &lt;code&gt;Unable to find object&lt;/code&gt; Exception that I couldn't  ... &lt;a class="read-more" href="/posts/suse-hack-week-2024-day-1.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I started the work on my project &lt;a class="reference external" href="https://hackweek.opensuse.org/projects/aws-codepipeline-ci-plugin-for-pagure-on-code-dot-opensuse-dot-org"&gt;AWS CodePipeline CI plugin for pagure on code.opensuse.org&lt;/a&gt;
with my nemesis, the mysterious &lt;code&gt;Unable to find object&lt;/code&gt; Exception that I couldn't solve in the past. This problem blocked my PR to
&lt;a class="reference external" href="https://pagure.io/pagure/pull-request/5508"&gt;Bump test containers to F40, bump pip version pinning to align with rpm versions, address some tech debts in dependencies&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One observation I've made last time was that the Database Session is rolled back and new created in the middle of the failing test.
I started my troubleshooting there to understand which session was created and re-created during the test.
And which one is actually used by the celery task that throws the exception.&lt;/p&gt;
&lt;p&gt;Before the rollback (&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py#_171"&gt;line 171 in test_pagure_flask_dump_load_ticket.py&lt;/a&gt;)
&lt;code&gt;self.session&lt;/code&gt; and &lt;code&gt;self.db_session&lt;/code&gt; are not identical, afterwards they are.
That was somehow suspicious, but after taking a closer look and playing around with the session and db_session value,
it doesn't seem to make any difference and is a dead end.&lt;/p&gt;
&lt;p&gt;Then I checked the error message and stack trace once more,
the mock patch that injects a lambda function as override for &lt;code&gt;_maybe_wait&lt;/code&gt;
seem to cause the issues, a detail I didn't notice before:&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
tests/test_pagure_flask_dump_load_ticket.py:203:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pagure/lib/git.py:549: in update_ticket_from_git
    issue = pagure.lib.query.new_issue(
pagure/lib/query.py:1757: in new_issue
    pagure.lib.git.update_git(issue, repo=repo)
pagure/lib/git.py:165: in update_git
    _maybe_wait(queued)
/usr/lib/python3.12/site-packages/mock/mock.py:1100: in __call__
    return _mock_self._mock_call(*args, **kwargs)
/usr/lib/python3.12/site-packages/mock/mock.py:1104: in _mock_call
    return _mock_self._execute_mock_call(*args, **kwargs)
/usr/lib/python3.12/site-packages/mock/mock.py:1167: in _execute_mock_call
    result = effect(*args, **kwargs)
tests/test_pagure_flask_dump_load_ticket.py:43: in &amp;lt;lambda&amp;gt;
    mw.side_effect = lambda result: result.get()
/usr/lib/python3.12/site-packages/celery/result.py:1026: in get
    raise self.result if isinstance(
/usr/lib/python3.12/site-packages/celery/app/trace.py:477: in trace_task
    R = retval = fun(*args, **kwargs)
pagure/lib/tasks_utils.py:36: in decorated_function
    return function(self, session, *args, **kwargs)

&lt;/pre&gt;
&lt;p&gt;I checked older logs, they confirm that this trace came up earlier already...&lt;/p&gt;
&lt;p&gt;So what does &lt;code&gt;_maybe_wait&lt;/code&gt; do? well ...&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="pygments-k"&gt;def&lt;/span&gt;&lt;span class="pygments-w"&gt; &lt;/span&gt;&lt;span class="pygments-nf"&gt;_maybe_wait&lt;/span&gt;&lt;span class="pygments-p"&gt;(&lt;/span&gt;&lt;span class="pygments-n"&gt;result&lt;/span&gt;&lt;span class="pygments-p"&gt;):&lt;/span&gt;&lt;span class="pygments-w"&gt;
    &lt;/span&gt;&lt;span class="pygments-sd"&gt;&amp;quot;&amp;quot;&amp;quot;Function to patch if one wants to wait for finish.

    This function should only ever be overridden by a few tests that depend
    on counting and very precise timing.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;    &lt;span class="pygments-k"&gt;pass&lt;/span&gt;&lt;span class="pygments-w"&gt;
&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Seem to cover very few edge cases then?! How is it used by other tests?&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
tests/__init__.py:def create_maybe_waiter(method, getter):
tests/__init__.py:        self.app.get = create_maybe_waiter(self.app.get, self.app.get)
tests/__init__.py:        self.app.post = create_maybe_waiter(self.app.post, self.app.get)
tests/__init__.py:    &amp;quot;&amp;quot;&amp;quot;Helper function for definitely waiting in _maybe_wait.&amp;quot;&amp;quot;&amp;quot;
tests/test_pagure_flask_dump_load_ticket.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;)
tests/test_pagure_lib_drop_issue.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)
tests/test_pagure_lib_drop_issue.py:    &amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)
tests/test_pagure_lib_git.py:        with patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait):

&lt;/pre&gt;
&lt;p&gt;Twice in &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_lib_drop_issue.py"&gt;tests/test_pagure_lib_drop_issue.py&lt;/a&gt;,
once in &lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_lib_git.py"&gt;tests/test_pagure_lib_git.py&lt;/a&gt;.
Always with &lt;code&gt;tests.definitely_wait&lt;/code&gt;, never in the way it's used in
&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py"&gt;tests/test_pagure_flask_dump_load_ticket.py&lt;/a&gt;.
A test with &lt;code&gt;&amp;#64;patch(&amp;quot;pagure.lib.git._maybe_wait&amp;quot;, tests.definitely_wait)&lt;/code&gt; ended up in the same &lt;code&gt;Unable to find object&lt;/code&gt; exception.
After dropping the whole patch / mock,
&lt;a class="reference external" href="https://pagure.io/pagure/blob/master/f/tests/test_pagure_flask_dump_load_ticket.py#_40"&gt;tests/test_pagure_flask_dump_load_ticket.py::PagureFlaskDumpLoadTicketTests::test_dumping_reloading_ticket&lt;/a&gt;
is happy after all and passes.&lt;/p&gt;
&lt;p&gt;I have to admit, I still don't fully understand why the test was implemented like that.
My only explanation is, that some Celery behavior must have changed over time in a release.
And after removing / bumping the version pinning and using Fedora 40 it came up as a problem.&lt;/p&gt;
&lt;p&gt;Such tests are there to rely on, and if that one now passes without mocking, I'm fine with that.&lt;/p&gt;
&lt;p&gt;After finally fixing this annoying problem, one of four Goals that I have for the Hack Week is completed.&lt;/p&gt;
&lt;p&gt;Project Goals:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Resolve issues with outdated python dependencies to ensure pagure runs on Python 3.11 and current package versions.
At least Fedora 40 python and python package versions. Fedora 41 would be even better.
This will also satisfy openSUSE Tumbleweed and Leap 15.6 package versions used on code.opensuse.org&lt;/li&gt;
&lt;li&gt;Validate if &lt;a class="reference external" href="https://bugzilla.opensuse.org/show_bug.cgi?id=1229570"&gt;https://bugzilla.opensuse.org/show_bug.cgi?id=1229570&lt;/a&gt; is fixed for code.opensuse.org and that all
required packages / backports landed in openSUSE:infrastructure:pagure&lt;/li&gt;
&lt;li&gt;Develop AWS CodePipeline pagure CI plugin and create an upstream pull request&lt;/li&gt;
&lt;li&gt;Backport Plugin into openSUSE pagure package on OBS till new upstream release&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;While I was waiting for my pagure PR to be reviewed and merged, I worked on Goal 2.
Based on the Bugzilla Ticket, the problem with the unsatisfied runtime dependency on cffi
is solved for &lt;a class="reference external" href="https://build.opensuse.org/project/show/openSUSE:infrastructure:pagure"&gt;openSUSE:infrastructure:pagure&lt;/a&gt;.
And still pending for openSUSE Leap 15.6 / SLES 15 SP6 in general.
But for know I only care about pagure on &lt;a class="reference external" href="https://code.opensuse.org"&gt;code.opensuse.org&lt;/a&gt;.
The OBS project had two broken packages that I fixed. Nothing else to do, Goal 2 completed.&lt;/p&gt;
&lt;p&gt;In preparation for Day 2, I updated my pagure dev system to the latest master branch version,
including the Patch from my pending PR. This allows me to develop the actual pagure CI plugin
for AWS CodePipeline on the latest build. Avoids running into issues because of old code and
refactoring to get it included into the pagure code base.&lt;/p&gt;
&lt;p&gt;I'm pretty happy with the progress of the first Day, can't wait how things going tomorrow :)&lt;/p&gt;
</content><category term="Code"/><category term="SUSE"/><category term="openSUSE"/><category term="pagure"/><category term="HackWeek"/><category term="AWS"/><category term="CodePipeline"/><category term="Coding"/><category term="OpenSource"/></entry><entry><title>Use a Bucket as Git repository and AWS CodePipeline source with git-remote-s3</title><link href="https://dominik.wombacher.cc/posts/use-a-bucket-as-git-repository-and-aws-codepipeline-source-with-git-remote-s3.html" rel="alternate"/><published>2024-11-17T00:00:00+01:00</published><updated>2024-11-17T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-17:/posts/use-a-bucket-as-git-repository-and-aws-codepipeline-source-with-git-remote-s3.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Let's talk about how to use a ordinary S3 Bucket as serverless Git repository with
the remote helper script &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3"&gt;git-remote-s3&lt;/a&gt;.
Release &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3/releases/tag/v0.2.0"&gt;v0.2.0&lt;/a&gt;,
contains a feature that let you  ... &lt;a class="read-more" href="/posts/use-a-bucket-as-git-repository-and-aws-codepipeline-source-with-git-remote-s3.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;Let's talk about how to use a ordinary S3 Bucket as serverless Git repository with
the remote helper script &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3"&gt;git-remote-s3&lt;/a&gt;.
Release &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3/releases/tag/v0.2.0"&gt;v0.2.0&lt;/a&gt;,
contains a feature that let you use the repo as source for AWS CodePipeline as well.&lt;/p&gt;
&lt;p&gt;I was looking for a way to replace AWS CodeCommit in a Workshop I build.
The reasons: &lt;a class="reference external" href="https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/"&gt;New customer access was closed&lt;/a&gt;
(Archive: &lt;a class="reference external" href="https://web.archive.org/web/20241013215252/https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://archive.today/2024.07.28-001143/https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/"&gt;[2]&lt;/a&gt;)
on July 25, 2024. &lt;strong&gt;git-remote-s3&lt;/strong&gt; looked promising for my use-case,
I can use a Bucket as remote, push and pull code, leverage AWS IAM to grant access.
The only challenge was AWS CodePipeline, more on that later.&lt;/p&gt;
&lt;p&gt;First, how does &lt;strong&gt;git-remote-s3&lt;/strong&gt; work under the hood?
It is a so called &lt;a class="reference external" href="https://git-scm.com/docs/gitremote-helpers"&gt;remote helper&lt;/a&gt; script.
And uses the &lt;a class="reference external" href="https://git-scm.com/docs/git-bundle"&gt;git bundle&lt;/a&gt; feature.
The bundle file is then then stored in the S3 bucket as &lt;code&gt;&amp;lt;prefix&amp;gt;/&amp;lt;ref&amp;gt;/&amp;lt;sha&amp;gt;.bundle&lt;/code&gt;.
&lt;strong&gt;git-remote-s3&lt;/strong&gt; interacts with the bucket thought the S3 API. It performs a get or put
that either updates the bundle in the bucket or retrieves the file and adds the containing data
to the local git clone. When a push was successful, the previous bundle is removed. There is
only one bundle file per git &lt;em&gt;ref&lt;/em&gt; at any point in time stored on the bucket.&lt;/p&gt;
&lt;p&gt;To learn more, I recommend the &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3?tab=readme-ov-file#under-the-hood"&gt;Under the hood&lt;/a&gt;
and &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3?tab=readme-ov-file#use-s3-remotes"&gt;use S3 remotes&lt;/a&gt;
section in the &lt;strong&gt;git-remote-s3&lt;/strong&gt; &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3?tab=readme-ov-file"&gt;README&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://aws.amazon.com/codepipeline/"&gt;AWS CodePipeline&lt;/a&gt; offers an
&lt;a class="reference external" href="https://docs.aws.amazon.com/codepipeline/latest/userguide/integrations-action-type.html#integrations-source-s3"&gt;Amazon S3 source action&lt;/a&gt;
as location for your code and application files. But this requires to upload the source files as a single ZIP file.
&lt;strong&gt;git-remote-s3&lt;/strong&gt; can create and upload zip archives. Use &lt;code&gt;s3+zip&lt;/code&gt; as URI Scheme when you add the remote and &lt;strong&gt;git-remote-s3&lt;/strong&gt;
will automatically place an archive on the S3 bucket that can be used by AWS CodePipeline.&lt;/p&gt;
&lt;p&gt;You might wonder, where the archive file is located? Let's assume your bucket name is &lt;code&gt;my-git-bucket&lt;/code&gt; and the repo is called &lt;code&gt;my-repo&lt;/code&gt;.
Run &lt;code&gt;git remote add origin s3+zip://my-git-bucket/my-repo&lt;/code&gt; to use it as remote. When you now commit your changes and push to the remote,
an additional &lt;code&gt;repo.zip&lt;/code&gt; file will be uploaded to the bucket. For example, if you push to the main branch (&lt;code&gt;git push origin main&lt;/code&gt;),
the file is available under &lt;code&gt;s3://my-git-bucket/my-repo/refs/heads/main/repo.zip&lt;/code&gt;. When you push to a branch called &lt;code&gt;fix_a_bug&lt;/code&gt;,
it's available under &lt;code&gt;s3://my-git-bucket/my-repo/refs/heads/fix_a_bug/repo.zip&lt;/code&gt;. Or if you create and push a tag called &lt;code&gt;v1.0&lt;/code&gt;,
it will be &lt;code&gt;s3://my-git-bucket/my-repo/refs/tags/v1.0/repo.zip&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Your AWS CodePipeline Action configuration, to trigger on updates of your &lt;code&gt;main&lt;/code&gt; branch, would then look like this:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Action Provider: &lt;code&gt;Amazon S3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Bucket: &lt;code&gt;my-git-bucket&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;S3 object key: &lt;code&gt;my-repo/refs/heads/main/repo.zip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Change detection options: &lt;code&gt;AWS CodePipeline&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check out the Tutorial &lt;a class="reference external" href="https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-s3.html"&gt;Create a simple pipeline (S3 bucket)&lt;/a&gt;
to learn more about a S3 bucket as source action.&lt;/p&gt;
&lt;p&gt;I'm proud that &lt;a class="reference external" href="https://github.com/awslabs/git-remote-s3/pull/16"&gt;my first contribution&lt;/a&gt;,
to &lt;strong&gt;git-remote-s3&lt;/strong&gt;, introduced the feature that allows using it together with AWS CodePipeline.
And while I was working on it, I had the opportunity to make a couple more code improvements.&lt;/p&gt;
&lt;p&gt;If you have any other use-case that requires a ZIP archive, then this feature will work for you too, it's not limited to AWS CodePipeline.&lt;/p&gt;
</content><category term="Code"/><category term="AWS"/><category term="S3"/><category term="CodePipeline"/><category term="Coding"/><category term="Git"/><category term="OpenSource"/></entry><entry><title>Fluent Bit: Output Plugin for AWS CloudTrail Data Service</title><link href="https://dominik.wombacher.cc/posts/fluent-bit-output-plugin-for-aws-cloudtrail-data-service.html" rel="alternate"/><published>2024-11-12T00:00:00+01:00</published><updated>2024-11-12T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2024-11-12:/posts/fluent-bit-output-plugin-for-aws-cloudtrail-data-service.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I recently wrote a &lt;a class="reference external" href="https://git.sr.ht/~wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;AWS CloudTrail Data Service output plugin&lt;/a&gt;
(Mirror: &lt;a class="reference external" href="https://github.com/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://gitlab.com/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[2]&lt;/a&gt;,
&lt;a class="reference external" href="https://codeberg.org/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[3]&lt;/a&gt;)
in Golang for &lt;a class="reference external" href="https://fluentbit.io/"&gt;Fluent Bit&lt;/a&gt;. It's Open Source under the Apache-2.0 license.
The plugin ingest  ... &lt;a class="read-more" href="/posts/fluent-bit-output-plugin-for-aws-cloudtrail-data-service.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2024 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I recently wrote a &lt;a class="reference external" href="https://git.sr.ht/~wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;AWS CloudTrail Data Service output plugin&lt;/a&gt;
(Mirror: &lt;a class="reference external" href="https://github.com/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://gitlab.com/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[2]&lt;/a&gt;,
&lt;a class="reference external" href="https://codeberg.org/wombelix/fluent-bit-output-plugin-aws-cloudtrail-data"&gt;[3]&lt;/a&gt;)
in Golang for &lt;a class="reference external" href="https://fluentbit.io/"&gt;Fluent Bit&lt;/a&gt;. It's Open Source under the Apache-2.0 license.
The plugin ingest events into &lt;a class="reference external" href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html"&gt;AWS CloudTrail Lake&lt;/a&gt;
through the CloudTrail Data Service by making a
&lt;a class="reference external" href="https://docs.aws.amazon.com/awscloudtraildata/latest/APIReference/API_PutAuditEvents.html"&gt;PutAuditEvents&lt;/a&gt; API call.&lt;/p&gt;
&lt;p&gt;I wrote a guest Article in the SUSE Blog:
&lt;a class="reference external" href="https://www.suse.com/c/send-suse-security-neuvector-events-to-aws-cloudtrail-lake/"&gt;Send SUSE Security (NeuVector) events to AWS CloudTrail Lake&lt;/a&gt;
(Archive: &lt;a class="reference external" href="https://web.archive.org/web/20241117122619/https://www.suse.com/c/send-suse-security-neuvector-events-to-aws-cloudtrail-lake/"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://archive.today/2024.11.17-122935/https://www.suse.com/c/send-suse-security-neuvector-events-to-aws-cloudtrail-lake/"&gt;[2]&lt;/a&gt;).
It covers the Architecture and usage, in the context of SUSE Security (NeuVector) and Syslog as Fluent Bit input.
But given the modular nature of Fluent Bit, your Input can be one of the other &lt;a class="reference external" href="https://docs.fluentbit.io/manual/pipeline/inputs"&gt;over 40 sources&lt;/a&gt;.
Which makes the Blog a blueprint for other use-cases too.&lt;/p&gt;
&lt;p&gt;The Heart and Soul of the plugin is &lt;a class="reference external" href="https://git.sr.ht/~wombelix/fluent-bit-output-plugin-aws-cloudtrail-data/tree/main/item/out_aws-cloudtrail-data.go"&gt;out_aws-cloudtrail-data.go&lt;/a&gt;,
which is based on the boilerplate example &lt;a class="reference external" href="https://github.com/fluent/fluent-bit-go/blob/master/examples/out_gstdout/out_gstdout.go"&gt;out_gstdout.go&lt;/a&gt;.
It's my first Fluent Bit plugin and I enjoyed the nice coding exercise to hack a first working version together and release it.
There is, as always in life, room for improvement but it does the job and is more than enough to get started.&lt;/p&gt;
&lt;p&gt;Looking forward for feedback to improve the plugin and to the next opportunity to write another one.&lt;/p&gt;
&lt;p&gt;Helpful resources to understand the Fluent Bit concepts and to write a plugin in Go:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.fluentbit.io/manual/concepts/key-concepts"&gt;Fluent Bit - Key Concepts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.fluentbit.io/manual/development/golang-output-plugins"&gt;Fluent Bit - Golang Output Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/fluent/fluent-bit-go/tree/master/examples"&gt;fluent-bit-go / examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Recommended resources to learn more about the AWS CloudTrail Data Service and the API to ingest events into AWS CloudTrail Lake:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.aws.amazon.com/awscloudtraildata/latest/APIReference/API_PutAuditEvents.html"&gt;AWS CloudTrail – API Reference – PutAuditEvents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-event-data-store-integration-custom.html"&gt;AWS CloudTrail – User Guide – Create a custom integration with the console&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-integration-event-schema.html"&gt;CloudTrail Lake integrations event schema&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content><category term="Code"/><category term="FluentBit"/><category term="Go"/><category term="Coding"/><category term="Plugin"/><category term="AWS"/><category term="CloudTrail"/><category term="OpenSource"/></entry></feed>