Skip to content

Commit 9c0870b

Browse files
dhaiducekopenshift-merge-robot
authored andcommitted
Add go install instructions to the README
Signed-off-by: Dale Haiducek <[email protected]>
1 parent 2449b4c commit 9c0870b

File tree

1 file changed

+51
-37
lines changed

1 file changed

+51
-37
lines changed

README.md

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Overview
44

5-
The Policy Generator constructs Open Cluster Management policies from Kubernetes YAML files provided
6-
through a PolicyGenerator Custom Resource. The Policy Generator is a binary compiled for use as a
5+
The Policy Generator constructs Open Cluster Management policies from Kubernetes YAML files provided through a
6+
PolicyGenerator Custom Resource. The Policy Generator is a binary compiled for use as a
77
[kustomize](https://kustomize.io/) exec plugin.
88

99
For more about Open Cluster Management and its Policy Framework:
@@ -16,62 +16,69 @@ For more about Open Cluster Management and its Policy Framework:
1616

1717
### As a Kustomize plugin
1818

19-
#### Installation
19+
#### Install from the GitHub release
2020

21-
##### Install from the GitHub release
22-
23-
1. Download the precompiled plugin binary from the
24-
[release](https://github.com/open-cluster-management-io/policy-generator-plugin/releases)
25-
of your choice.
26-
27-
2. Create the plugin directory:
21+
1. Create the plugin directory:
2822

2923
```bash
3024
mkdir -p ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
3125
```
3226

33-
3. Move the binary to the plugin directory:
27+
2. Install the binary. You can either:
3428

35-
- Linux:
29+
- Download a released version:
3630

37-
```bash
38-
chmod +x linux-amd64-PolicyGenerator
39-
mv linux-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
40-
```
31+
1. Download the precompiled plugin binary from the
32+
[release](https://github.com/open-cluster-management-io/policy-generator-plugin/releases) of your choice.
4133

42-
- MacOS:
34+
2. Move the binary to the plugin directory:
4335

44-
```bash
45-
chmod +x darwin-amd64-PolicyGenerator
46-
mv darwin-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
47-
```
36+
- Linux:
37+
38+
```bash
39+
chmod +x linux-amd64-PolicyGenerator
40+
mv linux-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
41+
```
42+
43+
- MacOS:
44+
45+
```bash
46+
chmod +x darwin-amd64-PolicyGenerator
47+
mv darwin-amd64-PolicyGenerator ${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
48+
```
49+
50+
- Use `go install` (available for `v1.11.0` and higher):
4851

49-
##### Build and install from source
52+
- Set the `GOBIN` to the plugin directory and specify the desired version (this command uses `latest`):
53+
```bash
54+
GOBIN=${HOME}/.config/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator \
55+
go install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest
56+
```
57+
58+
#### Build and install from source
5059

5160
1. Build the plugin binary (only needed once or to update the plugin):
5261
```bash
5362
make build
5463
```
55-
**NOTE:** This will default to placing the binary in `${HOME}/.config/kustomize/plugin/`. You can
56-
change this by exporting `KUSTOMIZE_PLUGIN_HOME` to a different path.
64+
**NOTE:** This will default to placing the binary in `${HOME}/.config/kustomize/plugin/`. You can change this by
65+
exporting `KUSTOMIZE_PLUGIN_HOME` to a different path.
5766

5867
#### Configuration
5968

60-
1. Create a `kustomization.yaml` file that points to `PolicyGenerator` manifest(s), with any
61-
additional desired patches or customizations (see
62-
[`examples/policyGenerator.yaml`](./examples/policyGenerator.yaml) for an example):
69+
1. Create a `kustomization.yaml` file that points to `PolicyGenerator` manifest(s), with any additional desired patches
70+
or customizations (see [`examples/policyGenerator.yaml`](./examples/policyGenerator.yaml) for an example):
6371

6472
```yaml
6573
generators:
6674
- path/to/generator/file.yaml
6775
```
6876

69-
- To read more about the `PolicyGenerator` YAML, see
70-
[About the PolicyGenerator plugin](./docs/policygenerator.md)
77+
- To read more about the `PolicyGenerator` YAML, see [About the PolicyGenerator plugin](./docs/policygenerator.md)
7178

7279
2. To use the plugin to generate policies, do one of:
73-
- Utilize the `examples/` directory in this repository (the directory can be modified by
74-
exporting a new path to `SOURCE_DIR`):
80+
- Utilize the `examples/` directory in this repository (the directory can be modified by exporting a new path to
81+
`SOURCE_DIR`):
7582
```bash
7683
make generate
7784
```
@@ -84,11 +91,19 @@ For more about Open Cluster Management and its Policy Framework:
8491

8592
In order to bypass Kustomize and run the generator binary directly:
8693

87-
1. Build the binary:
94+
1. Get the binary. You can either:
8895

89-
```bash
90-
make build-binary
91-
```
96+
- Build from source:
97+
98+
```bash
99+
make build-binary
100+
```
101+
102+
- Use `go install` (available for `v1.11.0` and higher):
103+
104+
```bash
105+
go install open-cluster-management.io/policy-generator-plugin/cmd/PolicyGenerator@latest
106+
```
92107

93108
2. Run the binary from the location of the PolicyGenerator manifest(s):
94109
```bash
@@ -99,5 +114,4 @@ In order to bypass Kustomize and run the generator binary directly:
99114
cd examples
100115
../PolicyGenerator policyGenerator.yaml
101116
```
102-
**NOTE:** To print the trace in the case of an error, you can add the `--debug` flag to the
103-
arguments.
117+
**NOTE:** To print the trace in the case of an error, you can add the `--debug` flag to the arguments.

0 commit comments

Comments
 (0)