Skip to content

Commit

Permalink
De-bazel in README
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahuif committed Sep 2, 2021
1 parent 3af8253 commit 9eda024
Showing 1 changed file with 22 additions and 50 deletions.
72 changes: 22 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,60 @@
# cloud-provider-gcp

## Publishing gcp-controller-manager image
## Building Container Images

This command will build and publish
`gcr.io/k8s-image-staging/gcp-controller-manager:latest`:
`gcr.io/k8s-image-staging/cloud-controller-manager`:

```
bazel run //cmd/gcp-controller-manager:publish
```sh
make images
```

Environment variables `IMAGE_REGISTRY`, `IMAGE_REPO` and `IMAGE_TAG` can be
used to override destination GCR repository and tag.

This command will build and publish
`example.com/my-repo/gcp-controller-manager:v1`:
`example.com/my-repo/cloud-controller-manager:v1`:


```
IMAGE_REGISTRY=example.com IMAGE_REPO=my-repo IMAGE_TAG=v1 bazel run //cmd/gcp-controller-manager:publish
```sh
IMAGE_REGISTRY=example.com IMAGE_REPO=my-repo IMAGE_TAG=v1 make images
```

# Cross-compiling

Selecting the target platform is done with the `--platforms` option with `bazel`.
This command builds release tarballs for Windows:

```
bazel build --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 //release:release-tars
This project uses standard go tools for cross-building.
```sh
GOOS=linux GOARCH=amd64 go build ./cmd/cloud-controller-manager
```
Alternatively, run `make bin` to build both server and node binaries for all supported platforms.

This command explicitly targets Linux as the target platform:

```
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //release:release-tars
```
Server
- linux/amd64

Node:
- linux/amd64
- windows/amd64

# Dependency management

Dependencies are managed using [Go modules](https://github.com/golang/go/wiki/Modules) (`go mod` subcommands).

Note that builds are done with Bazel and not the Go tool. Don't follow public
Go module docs, instead use instructions in this readme.

## Working within GOPATH

If you work within `GOPATH`, `go mod` will error out unless you do one of:

- move repo outside of GOPATH (it should "just work")
- set env var `GO111MODULE=on`
This project manages dependencies using standard [Go modules](https://github.com/golang/go/wiki/Modules) (`go mod` subcommands).

## Add a new dependency

```
go get github.com/new/dependency && ./tools/update_vendor.sh
go get github.com/new/dependency
```

## Update an existing dependency

```
go get -u github.com/existing/dependency && ./tools/update_vendor.sh
go get -u github.com/existing/dependency
```

## Update all dependencies

```
go get -u && ./tools/update_vendor.sh
go get -u
```

Note that this most likely won't work due to cross-dependency issues or repos
Expand All @@ -74,22 +63,5 @@ not implementing modules correctly.
## Clean up unused dependencies

```
go mod tidy && ./tools/update_vendor.sh
```

# Bazel

Bazel is required to build and release cloud-provider-gcp.

To install:

```sh
go get github.com/bazelbuild/bazelisk
alias bazel=bazelisk
```

To re-generate `BUILD` files:

```sh
tools/update_bazel.sh
```
go mod tidy
```

0 comments on commit 9eda024

Please sign in to comment.