Skip to content

Commit 16b20d8

Browse files
Merge pull request #106 from HeavyWombat/add/bundle
Add source bundle to `upload` command
2 parents 9185dde + 7779498 commit 16b20d8

File tree

351 files changed

+61303
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+61303
-232
lines changed

.github/workflows/e2e.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ jobs:
1616
- v1.21.2
1717
max-parallel: 2
1818
runs-on: ubuntu-latest
19+
1920
steps:
2021
- name: Setup Go
2122
uses: actions/setup-go@v2
2223
with:
23-
go-version: ^1.17
24+
go-version: 1.17.x
2425

2526
- name: Check out code into the Go module directory
2627
uses: actions/checkout@v2
@@ -41,6 +42,7 @@ jobs:
4142
version: v0.11.1
4243
node_image: kindest/node:${{ matrix.kubernetes }}
4344
cluster_name: kind
45+
config: test/kind/config.yaml
4446
wait: 120s
4547

4648
- name: Verify KinD cluster
@@ -49,11 +51,15 @@ jobs:
4951
- name: Install Registry
5052
run: make install-registry
5153

54+
- name: Add cluster hosted registry name to /etc/hosts
55+
run: echo "127.0.0.1 registry.registry.svc.cluster.local" | sudo tee -a /etc/hosts
56+
5257
- name: Installing Shipwright Build Controller
5358
run: make install-shipwright
5459

5560
- name: Build Application (shp)
5661
run: make build
5762

5863
- name: End-to-End Tests
59-
run: make test-e2e
64+
run: |
65+
make test-e2e

.github/workflows/unit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Go
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: ^1.17
22+
go-version: 1.17.x
2323

2424
- name: Check out code into the Go module directory
2525
uses: actions/checkout@v2

docs/local_source_upload.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
1-
Local Source Upload
2-
-------------------
1+
# Local Source Upload
32

43
The purpose of project Shipwright is to transform source code into container images, using known strategies to accomplish this task.
54

65
Now, with local source upload, we move Shipwright closer to the developer's inner loop. As a developer, you can use the local source upload feature to stream local content to a Build Controller running in a Kubernetes cluster and create a container image from it. This way, you can try out Shipwright before submitting a pull-request and use the cluster's computing power to build the image.
76

8-
# Usage
7+
## Usage
98

109
To build an image by using the local source upload feature:
1110

1211
1. Create a Build or use a pre-existing one. Register the standard settings, such as the Build Strategy, on the Build resource. For example:
1312

14-
```bash
15-
shp build create sample-nodejs \
16-
--source-url="https://github.com/shipwright-io/sample-nodejs.git" \
17-
--output-image="docker.io/<namespace>/sample-nodejs:latest"
18-
```
13+
```bash
14+
shp build create sample-nodejs \
15+
--source-url="https://github.com/shipwright-io/sample-nodejs.git" \
16+
--output-image="docker.io/<namespace>/sample-nodejs:latest"
17+
```
1918

20-
2. Clone the repository or use a pre-existing one. For example:
19+
1. Clone the repository or use a pre-existing one. For example:
2120

22-
```bash
23-
git clone https://github.com/shipwright-io/sample-nodejs.git && \
24-
cd sample-nodejs
25-
```
21+
```bash
22+
git clone https://github.com/shipwright-io/sample-nodejs.git && \
23+
cd sample-nodejs
24+
```
2625

27-
3. Keep working on the project. When you're ready to build or rebuild a container image with the local changes, run:
26+
1. Keep working on the project. When you're ready to build or rebuild a container image with the local changes, run:
2827

29-
```bash
30-
shp build upload sample-nodejs --follow \
31-
--output-image="docker.io/<namespace>/sample-nodejs:<tag>"
32-
```
28+
```bash
29+
shp build upload sample-nodejs --follow \
30+
--output-image="docker.io/<namespace>/sample-nodejs:<tag>"
31+
```
32+
33+
Notes:
3334

34-
Notes:
3535
- In the preceding examples, replace placeholders like `<namespace>` and `<tag>` with proper values.
3636
- For `--output-image`, you can specify any Container Registry, use it in combination with `--output-credentials-secret` when needed.
3737

38-
# Streaming
38+
## Streaming
3939

4040
The subcommand `build upload` creates a new `BuildRun` for the informed `Build`. The newly created `BuildRun` contains settings to instruct the Build Controller to wait for the local user upload instead of cloning the external repository as usual.
4141

4242
The command-line interface orchestrates the process of making the `BuildRun`'s Pod wait, and streaming the specified directory when the Pod is ready for it.
4343

4444
The data streamed to the cluster skips the `.git` directory, if present, and any entries specified by the `.gitignore` file.
45+
46+
## Bundling
47+
48+
Alternatively, the `build upload` command can also make use of the `bundle` feature of the Shipwright Build Controller. Instead of a stream into the build pod, with bundle images the local source code is packed (bundled) together into a container image and then pushed into a container registry. The Pod created as a result of the `BuildRun` will pull this image and extract its content. Please note, if the container registry being used is a separate service, make sure to use private images and authentication to protect the source code.
49+
50+
The bundling feature is used in case the `Build` configures a source bundle image name in the source section. This also needs to have a reference to a secret with the credentials for private images.
51+
52+
Files that should be ignored by the bundle feature need to be configured in `.shpignore` file. It follows Git ignore [patterns](https://git-scm.com/docs/gitignore#_pattern_format).

docs/shp_build_create.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ shp build create <name> [flags]
3030
--retention-succeeded-limit uint number of succeeded BuildRuns to be kept (default 65535)
3131
--retention-ttl-after-failed duration duration to delete a failed BuildRun after completion
3232
--retention-ttl-after-succeeded duration duration to delete a succeeded BuildRun after completion
33+
--source-bundle-image string source bundle image location, e.g. ghcr.io/shipwright-io/sample-go/source-bundle:latest
34+
--source-bundle-prune pruneOption source bundle prune option, either Never, or AfterPull (default Never)
3335
--source-context-dir string use a inner directory as context directory
34-
--source-credentials-secret string name of the secret with git repository credentials
36+
--source-credentials-secret string name of the secret with credentials to access the source, e.g. git or registry credentials
3537
--source-revision string git repository source revision
3638
--source-url string git repository source URL
3739
--strategy-apiversion string kubernetes api-version of the build-strategy resource (default "v1alpha1")

docs/shp_build_upload.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ Run a Build with local data
55
### Synopsis
66

77

8-
Creates a new BuildRun instance and instructs the Build Controller to wait for the data streamed,
9-
instead of executing "git clone". Therefore, you can employ Shipwright Builds from a local repository
10-
clone.
8+
Creates a new BuildRun instance and instructs the Build Controller to use data from a local directory
9+
to be used for the Build. Two options are supported: streaming and bundling. With these, you can
10+
employ Shipwright Builds from a local repository clone.
1111

12-
The upload skips the ".git" directory completely, and it follows the ".gitignore" directives, when
13-
the file is found at the root of the directory uploaded.
12+
When streaming is used, the Build Controller waits for the data being streamed to the build pod,
13+
instead of executing "git clone". The upload skips the ".git" directory completely, and it follows
14+
the ".gitignore" directives, when the file is found at the root of the directory uploaded.
15+
16+
In case a source bundle image is defined, the bundling feature is used, which will bundle the local
17+
source code into a bundle container and upload it to the specified container registry. Instead of
18+
executing using Git in the source step, it will use the container registry to obtain the source code.
1419

1520
$ shp buildrun upload <build-name>
1621
$ shp buildrun upload <build-name> /path/to/repository

go.mod

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ module github.com/shipwright-io/cli
33
go 1.17
44

55
require (
6+
github.com/google/go-containerregistry v0.8.1-0.20220216220642-00c59d91847c
67
github.com/onsi/gomega v1.19.0
78
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
9+
github.com/schollz/progressbar/v3 v3.8.6
810
github.com/shipwright-io/build v0.9.0
911
github.com/spf13/cobra v1.4.0
1012
github.com/spf13/pflag v1.0.5
@@ -32,13 +34,19 @@ require (
3234
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
3335
github.com/PuerkitoBio/purell v1.1.1 // indirect
3436
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
37+
github.com/acomagu/bufpipe v1.0.3 // indirect
3538
github.com/beorn7/perks v1.0.1 // indirect
3639
github.com/blendle/zapdriver v1.3.1 // indirect
3740
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
3841
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3942
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
43+
github.com/containerd/stargz-snapshotter/estargz v0.11.3 // indirect
4044
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
4145
github.com/davecgh/go-spew v1.1.1 // indirect
46+
github.com/docker/cli v20.10.14+incompatible // indirect
47+
github.com/docker/distribution v2.8.1+incompatible // indirect
48+
github.com/docker/docker v20.10.14+incompatible // indirect
49+
github.com/docker/docker-credential-helpers v0.6.4 // indirect
4250
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
4351
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
4452
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
@@ -47,20 +55,21 @@ require (
4755
github.com/fvbommel/sortorder v1.0.1 // indirect
4856
github.com/ghodss/yaml v1.0.0 // indirect
4957
github.com/go-errors/errors v1.0.1 // indirect
58+
github.com/go-git/gcfg v1.5.0 // indirect
59+
github.com/go-git/go-billy/v5 v5.3.1 // indirect
60+
github.com/go-git/go-git/v5 v5.4.2 // indirect
5061
github.com/go-kit/log v0.2.0 // indirect
5162
github.com/go-logfmt/logfmt v0.5.1 // indirect
5263
github.com/go-logr/logr v1.2.3 // indirect
5364
github.com/go-openapi/jsonpointer v0.19.5 // indirect
5465
github.com/go-openapi/jsonreference v0.19.6 // indirect
55-
github.com/go-openapi/spec v0.20.4 // indirect
5666
github.com/go-openapi/swag v0.21.1 // indirect
5767
github.com/gogo/protobuf v1.3.2 // indirect
5868
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
5969
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
6070
github.com/golang/protobuf v1.5.2 // indirect
6171
github.com/google/btree v1.0.1 // indirect
6272
github.com/google/go-cmp v0.5.7 // indirect
63-
github.com/google/go-containerregistry v0.8.1-0.20220216220642-00c59d91847c // indirect
6473
github.com/google/gofuzz v1.2.0 // indirect
6574
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
6675
github.com/google/uuid v1.3.0 // indirect
@@ -69,20 +78,26 @@ require (
6978
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
7079
github.com/hashicorp/errwrap v1.1.0 // indirect
7180
github.com/hashicorp/go-multierror v1.1.1 // indirect
72-
github.com/hashicorp/golang-lru v0.5.4 // indirect
7381
github.com/imdario/mergo v0.3.12 // indirect
7482
github.com/inconshreveable/mousetrap v1.0.0 // indirect
83+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
7584
github.com/josharian/intern v1.0.0 // indirect
7685
github.com/json-iterator/go v1.1.12 // indirect
86+
github.com/klauspost/compress v1.15.1 // indirect
7787
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
7888
github.com/mailru/easyjson v0.7.7 // indirect
89+
github.com/mattn/go-runewidth v0.0.13 // indirect
7990
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
91+
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
92+
github.com/mitchellh/go-homedir v1.1.0 // indirect
8093
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
8194
github.com/moby/spdystream v0.2.0 // indirect
8295
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect
8396
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8497
github.com/modern-go/reflect2 v1.0.2 // indirect
8598
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
99+
github.com/opencontainers/go-digest v1.0.0 // indirect
100+
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 // indirect
86101
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
87102
github.com/pkg/errors v0.9.1 // indirect
88103
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -91,10 +106,13 @@ require (
91106
github.com/prometheus/common v0.33.0 // indirect
92107
github.com/prometheus/procfs v0.7.3 // indirect
93108
github.com/prometheus/statsd_exporter v0.22.4 // indirect
109+
github.com/rivo/uniseg v0.2.0 // indirect
94110
github.com/russross/blackfriday v1.6.0 // indirect
95111
github.com/russross/blackfriday/v2 v2.1.0 // indirect
112+
github.com/sirupsen/logrus v1.8.1 // indirect
96113
github.com/stretchr/testify v1.7.0 // indirect
97114
github.com/tektoncd/pipeline v0.34.1 // indirect
115+
github.com/vbatts/tar-split v0.11.2 // indirect
98116
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
99117
go.opencensus.io v0.23.0 // indirect
100118
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
@@ -116,6 +134,7 @@ require (
116134
google.golang.org/grpc v1.45.0 // indirect
117135
google.golang.org/protobuf v1.28.0 // indirect
118136
gopkg.in/inf.v0 v0.9.1 // indirect
137+
gopkg.in/warnings.v0 v0.1.2 // indirect
119138
gopkg.in/yaml.v2 v2.4.0 // indirect
120139
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
121140
k8s.io/component-base v0.23.4 // indirect

0 commit comments

Comments
 (0)