openllb / hlb

A developer-first language to build and test any software efficiently
https://openllb.github.io/hlb/
Apache License 2.0
108 stars 12 forks source link

Add merge and diff builtins #265

Closed aaronlehmann closed 2 years ago

aaronlehmann commented 3 years ago

Uses the new LLB "merge" and "diff" ops.

Example merge usage:

fs alpine() {
        image "alpine"
}

fs busybox() {
        image "busybox"
}

fs merged() {
        busybox
        merge alpine
        breakpoint
}

Example which uses merge and diff:

fs alpine() {
        image "alpine"
}

fs busybox() {
        image "busybox"
}

fs workspace() {
        busybox
        run "echo this is a test > /root/file1"
        run "dd if=/dev/urandom bs=1024 count=100 of=/var/random"
        run "rm /bin/zcat"
}

fs differences() {
        workspace
        diff busybox
}

fs workspaceRebased() {
        alpine
        merge differences
}

fs default() {
        busybox
        run "ls" with option {
                breakpoint
                mount workspace "/workspace"
                mount differences "/differences"
                mount workspaceRebased "/rebased"
        }
}

cc @sipsma

aaronlehmann commented 2 years ago

Example using merge and diff:

fs alpine() {
        image "alpine"
}

fs busybox() {
        image "busybox"
}

fs workspace() {
        busybox
        run "echo this is a test > /root/file1"
        run "dd if=/dev/urandom bs=1024 count=100 of=/var/random"
        run "rm /bin/zcat"
}

fs differences() {
        workspace
        diff busybox
}

fs workspaceRebased() {
        alpine
        merge differences
}

fs default() {
        busybox
        run "ls" with option {
                breakpoint
                mount workspace "/workspace"
                mount differences "/differences"
                mount workspaceRebased "/rebased"
        }
}
aaronlehmann commented 2 years ago

Split out the DiffOp part to https://github.com/aaronlehmann/hlb/pull/2. Now that MergeOp is available in upstream BuildKit, this PR is ready for review.

aaronlehmann commented 2 years ago

Pulled the diff builtin back into this PR, now that DiffOp is merged upstream in BuildKit.