canonical / rockcraft

Tool to create OCI Images using the language from Snapcraft and Charmcraft.
https://documentation.ubuntu.com/rockcraft
GNU General Public License v3.0
38 stars 44 forks source link

Conditional parts #249

Closed sanchezfdezjavier closed 2 months ago

sanchezfdezjavier commented 1 year ago

Hi rockcraft!

During Kubeflow's Rocks 🪨 workshop I had the chance of building this rock and I realized It would be great to have a feature to have conditional parts based on a given parameter.

This rock It's meant to support two architectures: amd64 and ppc64le, we must install specific dependencies for the latter. This is how it's handled in the original Dockerfile.

I was thinking about something like Github actions' if: <codition> feature for conditionally running steps within your workflows.

I imagine something like the following, where your if statement will determine whether or not your part will be included depending on architecture, series, maybe cloud provider (if you have kernel specific requirements), or similar.

This will avoid the overhead of maintaining several rocks for different platforms, or having a bloated rock.

Let me know if that makes sense!

...

 parts:

...

   entrypoint:
     if: <condition> # <-------- NEW ✨
     plugin: dump
     source: https://github.com/kubeflow/katib.git
     source-subdir: cmd/earlystopping/medianstop/v1beta1
     source-type: git
     source-tag: master
     organize:
       main.py: usr/bin/main.py
     stage:
       - usr/bin/main.py

...
sergiusens commented 1 year ago

We have something like this, but not quite like and not for Rockcraft yet. The conditions however are opinionated to architecture and base as can be seen on https://snapcraft.io/docs/snapcraft-advanced-grammar

On Thu, May 4, 2023 at 4:58 AM Javi Sánchez @.***> wrote:

Hi rockcraft!

During Kubeflow's Rocks 🪨 workshop I had the chance of building this rock https://github.com/canonical/katib-rocks/pull/8/files and I realized It would be great to have a feature to have conditional parts based on a given parameter.

This rock It's meant to support two architectures: amd64 and , we must install specific dependencies for the latter. This is how it's handled in the original Dockerfile https://github.com/kubeflow/katib/blob/master/cmd/suggestion/nas/darts/v1beta1/Dockerfile .

I was thinking in something like Github actions' if: feature https://github.com/canonical/charmed-magma-orchestrator/blob/ba794bdd25ce86518f62eaa7fbcdf79df9b7d3ec/.github/workflows/integration-tests.yml#L30 for conditionally running steps within your workflows.

I imagine something like the following, where your if statement will determine whether or not your part will be included depending on architecture, series, maybe cloud provider (if you have kernel specific requirements), or similar.

Let me know if that makes sense!

...

parts:

...

entrypoint: if: # <-------- NEW ✨ plugin: dump source: https://github.com/kubeflow/katib.git source-subdir: cmd/earlystopping/medianstop/v1beta1 source-type: git source-tag: master organize: main.py: usr/bin/main.py stage:

  • usr/bin/main.py

...

— Reply to this email directly, view it on GitHub https://github.com/canonical/rockcraft/issues/249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIX7ZOSNRSZHOZRGBSPZYTXENOT3ANCNFSM6AAAAAAXVNKBRU . You are receiving this because you are subscribed to this thread.Message ID: @.***>