Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frizbee refactoring - support for Dockerfile, docker:// actions, etc. #139

Merged
merged 16 commits into from
Jun 4, 2024

Conversation

rdimitrov
Copy link
Member

@rdimitrov rdimitrov commented May 28, 2024

The following PR aimed to tidy up the packages, add missing functionality and fix a few of the opened issues.

Details:

  • Grouped the code base into 2 separate packages - one for parsing actions and another one for parsing container images
  • Fixed the issue of altering the formatting of the file when replacing a reference
  • Fixed an issue with caching not working properly for container images
  • Made the cache to be scoped per-instance of the replacer and not per-operation. This should help reduce the overall API consumption.
  • Added support for parsing Dockerfiles
  • Added support for parsing GitHub Actions referenced by docker://
  • Added the --platform/-p flag. The code is there but it doesn't work now as there's an opened issue in the underlying library. When debugging the underlying library it turned out that the platform configuration is not really taken into account while fetching the manifest. I can remove the code if needed or mark it as experimental until the issue is resolved.
  • Updated the README.md file - added the Frizbee logo and updated the content
  • Updated the test coverage to 69%

Fixes: #55
Fixes: #67
Fixes: #77
Fixes: #137
Fixes: #138
Closes: #61

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@rdimitrov rdimitrov force-pushed the refactor branch 10 times, most recently from af21fc3 to 00fa658 Compare May 28, 2024 10:53
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@rdimitrov rdimitrov force-pushed the refactor branch 6 times, most recently from 04d0852 to b3c876e Compare May 29, 2024 15:31
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@jhrozek
Copy link
Contributor

jhrozek commented May 30, 2024

I went through some of the code, not all of it but as you said, a lot of it is moving things around, so I've been trying to orient myself and take notes what is moved where.

I think looking at the Minder PR that the API changes are OK and searching GH, Minder is the only API user of frizbee, so if we want to break the API, now is still a good time.

But I know we have CLI users (one wrote a post about frizbee). I see that you added aliases for the k8s and dockerhub commands, but what do you think about temporary adding aliases for one as well, would that be possible?

Also the image list command doesn't seem to work all that well for me, I tested with this manifest I had around:

apiVersion: v1
kind: Pod
metadata:
  name: mount-host
  namespace: playground
spec:
  containers:
  - name: mount-host
    image: alpine
    command: ["sleep"]
    args: ["infinity"]
    volumeMounts:
    - name: host-root
      mountPath: /host
      readOnly: true
  volumes:
  - name: host-root
    hostPath:
      path: /
      type: Directory

and I got:

frizbee image list ~/devel/playground/k8s/mount-host.yaml
+----+-----------+------+--------+
| NO |   TYPE    | NAME |  REF   |
+----+-----------+------+--------+
|  1 | container |      | latest |
+----+-----------+------+--------+

shouldn't name print something?

@rdimitrov
Copy link
Member Author

rdimitrov commented May 31, 2024

@jhrozek - Thanks for the review!

  1. I'll try to see if I can add the one command too. I have to see if it would work properly with the missing -d flag though.
  2. That's a bug. I'll fix it and add that use case as part of the unit tests 👍

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@rdimitrov
Copy link
Member Author

@jhrozek - Thanks again! This was indeed a bug - I was accepting the empty string from the flag's default value for overwriting the regex which caused this failure. It should be fixed now 👍

Added more tests cases which bumped the coverage to 69%.

@rdimitrov
Copy link
Member Author

Draft branches/PRs for the two projects I found that depend on Frizbee -

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested replacing both "normal" actions and docker actions through and a bunch of things in the CLI. I don't claim I reviewed every single line of the PR, but the API looks good.

I know that @JAORMX was also planning to take a look so don't merge just yet, but ack from my part.

Thanks for all the work, this makes frizbee much better.

@JAORMX JAORMX changed the title Frezbee refactoring - support for Dockerfile, docker:// actions, etc. Frizbee refactoring - support for Dockerfile, docker:// actions, etc. Jun 4, 2024
Copy link
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Went through the library usages and tried out the CLI. shipit :shipit:

@rdimitrov rdimitrov merged commit 181f156 into main Jun 4, 2024
10 checks passed
@rdimitrov rdimitrov deleted the refactor branch June 4, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants