Skip to content

Commit 8e77757

Browse files
authored
Merge pull request containerd#4381 from AkihiroSuda/no_ipfs
Add build tag `no_ipfs`
2 parents b66e7fa + c731c25 commit 8e77757

File tree

12 files changed

+518
-311
lines changed

12 files changed

+518
-311
lines changed

.github/workflows/job-build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,12 @@ jobs:
9999
build linux s390x
100100
101101
[ ! "$failure" ] || exit 1
102+
103+
- if: ${{ env.GO_VERSION != '' }}
104+
name: "Run: make binaries with custom BUILDTAGS"
105+
run: |
106+
set -eux
107+
# no_ipfs: make sure it does not incur any IPFS-related dependency
108+
go mod vendor
109+
rm -rf vendor/github.com/ipfs vendor/github.com/multiformats
110+
BUILDTAGS=no_ipfs make binaries

BUILDING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Building nerdctl
2+
3+
To build nerdctl, use `make`:
4+
5+
```bash
6+
make
7+
sudo make install
8+
```
9+
10+
Alternatively, nerdctl can be also built with `go build ./cmd/nerdctl`.
11+
However, this is not recommended as it does not populate the version string (`nerdctl -v`).
12+
13+
## Customization
14+
15+
To specify build tags, set the `BUILDTAGS` variable as follows:
16+
17+
```bash
18+
BUILDTAGS=no_ipfs make
19+
```
20+
21+
The following build tags are supported:
22+
* `no_ipfs` (since v2.1.3): Disable IPFS

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ LINT_COMMIT_RANGE ?= main..HEAD
4646
GO_BUILD_LDFLAGS ?= -s -w
4747
GO_BUILD_FLAGS ?=
4848

49+
BUILDTAGS ?=
50+
GO_TAGS=$(if $(BUILDTAGS),-tags "$(strip $(BUILDTAGS))",)
51+
4952
##########################
5053
# Helpers
5154
##########################
@@ -54,7 +57,7 @@ ifdef VERBOSE
5457
VERBOSE_FLAG_LONG := --verbose
5558
endif
5659

57-
export GO_BUILD=CGO_ENABLED=0 GOOS=$(GOOS) $(GO) -C $(MAKEFILE_DIR) build -ldflags "$(GO_BUILD_LDFLAGS) $(VERBOSE_FLAG) -X $(PACKAGE)/pkg/version.Version=$(VERSION) -X $(PACKAGE)/pkg/version.Revision=$(REVISION)"
60+
export GO_BUILD=CGO_ENABLED=0 GOOS=$(GOOS) $(GO) -C $(MAKEFILE_DIR) build $(GO_TAGS) -ldflags "$(GO_BUILD_LDFLAGS) $(VERBOSE_FLAG) -X $(PACKAGE)/pkg/version.Version=$(VERSION) -X $(PACKAGE)/pkg/version.Revision=$(REVISION)"
5861

5962
ifndef NO_COLOR
6063
NC := \033[0m

pkg/ipfs/image.go renamed to pkg/ipfs/image_ipfs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !no_ipfs
2+
13
/*
24
Copyright The containerd Authors.
35

pkg/ipfs/image_noipfs.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//go:build no_ipfs
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package ipfs
20+
21+
import (
22+
"context"
23+
24+
containerd "github.com/containerd/containerd/v2/client"
25+
"github.com/containerd/containerd/v2/core/images/converter"
26+
27+
"github.com/containerd/nerdctl/v2/pkg/api/types"
28+
"github.com/containerd/nerdctl/v2/pkg/imgutil"
29+
)
30+
31+
// EnsureImage pull the specified image from IPFS.
32+
func EnsureImage(ctx context.Context, client *containerd.Client, scheme, ref, ipfsPath string, options types.ImagePullOptions) (*imgutil.EnsuredImage, error) {
33+
return nil, ErrNotImplemented
34+
}
35+
36+
// Push pushes the specified image to IPFS.
37+
func Push(ctx context.Context, client *containerd.Client, rawRef string, layerConvert converter.ConvertFunc, allPlatforms bool, platform []string, ensureImage bool, ipfsPath string) (string, error) {
38+
return "", ErrNotImplemented
39+
}

pkg/ipfs/noipfs.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package ipfs
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/containerd/errdefs"
23+
)
24+
25+
var ErrNotImplemented = fmt.Errorf("%w: ipfs is disabled by the distributor of this build", errdefs.ErrNotImplemented)

0 commit comments

Comments
 (0)