Skip to content

Commit 327b637

Browse files
committed
Merge branch 'master' into go-e2e-refactor
2 parents ed4af22 + 915ddef commit 327b637

File tree

13 files changed

+163
-107
lines changed

13 files changed

+163
-107
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Scaffold a `pkg/apis/<group>/group.go` package file to avoid `go/build` errors when running Kubernetes code generators. ([#1401](https://github.com/operator-framework/operator-sdk/pull/1401))
1111
- Adds a new extra variable containing the unmodified CR spec for ansible based operators. [#1563](https://github.com/operator-framework/operator-sdk/pull/1563)
1212
- New flag `--repo` for subcommands [`new`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#new) and [`migrate`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#migrate) specifies the repository path to be used in Go source files generated by the SDK. This flag can only be used with [Go modules](https://github.com/golang/go/wiki/Modules). ([#1475](https://github.com/operator-framework/operator-sdk/pull/1475))
13+
- Adds `--go-build-args` flag to `operator-sdk build` for providing additional Go build arguments. ([#1582](https://github.com/operator-framework/operator-sdk/pull/1582))
1314

1415
### Changed
1516

Gopkg.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/operator-sdk/build/cmd.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
var (
3333
imageBuildArgs string
3434
imageBuilder string
35+
goBuildArgs string
3536
)
3637

3738
func NewCmd() *cobra.Command {
@@ -54,6 +55,7 @@ For example:
5455
}
5556
buildCmd.Flags().StringVar(&imageBuildArgs, "image-build-args", "", "Extra image build arguments as one string such as \"--build-arg https_proxy=$https_proxy\"")
5657
buildCmd.Flags().StringVar(&imageBuilder, "image-builder", "docker", "Tool to build OCI images. One of: [docker, podman, buildah]")
58+
buildCmd.Flags().StringVar(&goBuildArgs, "go-build-args", "", "Extra Go build arguments as one string such as \"-ldflags -X=main.xyz=abc\"")
5759
return buildCmd
5860
}
5961

@@ -99,10 +101,17 @@ func buildFunc(cmd *cobra.Command, args []string) error {
99101
// Don't need to build Go code if a non-Go Operator.
100102
if projutil.IsOperatorGo() {
101103
trimPath := fmt.Sprintf("all=-trimpath=%s", filepath.Dir(absProjectPath))
104+
args := []string{"-gcflags", trimPath, "-asmflags", trimPath}
105+
106+
if goBuildArgs != "" {
107+
splitArgs := strings.Fields(goBuildArgs)
108+
args = append(args, splitArgs...)
109+
}
110+
102111
opts := projutil.GoCmdOptions{
103112
BinName: filepath.Join(absProjectPath, scaffold.BuildBinDir, projectName),
104113
PackagePath: path.Join(projutil.GetGoPkg(), filepath.ToSlash(scaffold.ManagerDir)),
105-
Args: []string{"-gcflags", trimPath, "-asmflags", trimPath},
114+
Args: args,
106115
Env: goBuildEnv,
107116
GoMod: projutil.IsDepManagerGoMod(),
108117
}

doc/ansible/user-guide.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ This guide walks through an example of building a simple memcached-operator powe
44

55
## Prerequisites
66

7-
- [git][git_tool]
8-
- [docker][docker_tool] version 17.03+.
9-
- [kubectl][kubectl_tool] version v1.9.0+.
10-
- [ansible][ansible_tool] version v2.6.0+
11-
- [ansible-runner][ansible_runner_tool] version v1.1.0+
12-
- [ansible-runner-http][ansible_runner_http_plugin] version v1.0.0+
13-
- [dep][dep_tool] version v0.5.0+. (Optional if you aren't installing from source)
14-
- [go][go_tool] version v1.12+. (Optional if you aren't installing from source)
7+
- [git][git-tool]
8+
- [docker][docker-tool] version 17.03+.
9+
- [kubectl][kubectl-tool] version v1.9.0+.
10+
- [ansible][ansible-tool] version v2.6.0+
11+
- [ansible-runner][ansible-runner-tool] version v1.1.0+
12+
- [ansible-runner-http][ansible-runner-http-plugin] version v1.0.0+
13+
- [dep][dep-tool] version v0.5.0+. (Optional if you aren't installing from source)
14+
- [go][go-tool] version v1.12+. (Optional if you aren't installing from source)
1515
- Access to a Kubernetes v.1.9.0+ cluster.
1616

17-
**Note**: This guide uses [minikube][minikube_tool] version v0.25.0+ as the
18-
local Kubernetes cluster and [quay.io][quay_link] for the public registry.
17+
**Note**: This guide uses [minikube][minikube-tool] version v0.25.0+ as the
18+
local Kubernetes cluster and [quay.io][quay-link] for the public registry.
1919

2020
## Install the Operator SDK CLI
2121

22-
Follow the steps in the [installation guide][install_guide] to learn how to install the Operator SDK CLI tool.
22+
Follow the steps in the [installation guide][install-guide] to learn how to install the Operator SDK CLI tool.
2323

2424
## Create a new project
2525

@@ -35,11 +35,11 @@ Memcached resource with APIVersion `cache.example.com/v1apha1` and Kind
3535
`Memcached`.
3636

3737
To learn more about the project directory structure, see [project
38-
layout][layout_doc] doc.
38+
layout][layout-doc] doc.
3939

4040
#### Operator scope
4141

42-
Read the [operator scope][operator_scope] documentation on how to run your operator as namespace-scoped vs cluster-scoped.
42+
Read the [operator scope][operator-scope] documentation on how to run your operator as namespace-scoped vs cluster-scoped.
4343

4444
### Watches file
4545

@@ -282,8 +282,8 @@ memcached-operator 1 1 1 1 1m
282282

283283
This method is preferred during the development cycle to speed up deployment and testing.
284284

285-
**Note**: Ensure that [Ansible Runner][ansible_runner_tool] and [Ansible Runner
286-
HTTP Plugin][ansible_runner_http_plugin] is installed or else you will see
285+
**Note**: Ensure that [Ansible Runner][ansible-runner-tool] and [Ansible Runner
286+
HTTP Plugin][ansible-runner-http-plugin] is installed or else you will see
287287
unexpected errors from Ansible Runner when a Custom Resource is created.
288288

289289
It is also important that the `role` path referenced in `watches.yaml` exists
@@ -410,17 +410,17 @@ $ kubectl delete -f deploy/service_account.yaml
410410
$ kubectl delete -f deploy/crds/cache_v1alpha1_memcached_crd.yaml
411411
```
412412

413-
[operator_scope]:./../operator-scope.md
414-
[install_guide]: ../user/install-operator-sdk.md
415-
[layout_doc]:./project_layout.md
416-
[homebrew_tool]:https://brew.sh/
417-
[dep_tool]:https://golang.github.io/dep/docs/installation.html
418-
[git_tool]:https://git-scm.com/downloads
419-
[go_tool]:https://golang.org/dl/
420-
[docker_tool]:https://docs.docker.com/install/
421-
[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
422-
[minikube_tool]:https://github.com/kubernetes/minikube#installation
423-
[ansible_tool]:https://docs.ansible.com/ansible/latest/index.html
424-
[ansible_runner_tool]:https://ansible-runner.readthedocs.io/en/latest/install.html
425-
[ansible_runner_http_plugin]:https://github.com/ansible/ansible-runner-http
426-
[quay_link]:https://quay.io
413+
[operator-scope]:./../operator-scope.md
414+
[install-guide]: ../user/install-operator-sdk.md
415+
[layout-doc]:./project_layout.md
416+
[homebrew-tool]:https://brew.sh/
417+
[dep-tool]:https://golang.github.io/dep/docs/installation.html
418+
[git-tool]:https://git-scm.com/downloads
419+
[go-tool]:https://golang.org/dl/
420+
[docker-tool]:https://docs.docker.com/install/
421+
[kubectl-tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
422+
[minikube-tool]:https://github.com/kubernetes/minikube#installation
423+
[ansible-tool]:https://docs.ansible.com/ansible/latest/index.html
424+
[ansible-runner-tool]:https://ansible-runner.readthedocs.io/en/latest/install.html
425+
[ansible-runner-http-plugin]:https://github.com/ansible/ansible-runner-http
426+
[quay-link]:https://quay.io

doc/dev/developer_guide.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
This document explains how to setup your dev environment.
44

55
## Prerequisites
6-
- [dep][dep_tool] version v0.5.0+
7-
- [git][git_tool]
8-
- [go][go_tool] version v1.12+
6+
- [dep][dep-tool] version v0.5.0+
7+
- [git][git-tool]
8+
- [go][go-tool] version v1.12+
99

1010
## Download Operator SDK
1111

12-
Go to the [Operator SDK repo][repo_sdk] and follow the [fork guide][fork_guide] to fork, clone, and setup the local operator-sdk repository.
12+
Go to the [Operator SDK repo][repo-sdk] and follow the [fork guide][fork-guide] to fork, clone, and setup the local operator-sdk repository.
1313

1414
## Vendor dependencies
1515

@@ -47,14 +47,14 @@ $ make test
4747
For more information on running testing and correctly configuring your environment,
4848
refer to the [`Running the Tests Locally`][running-the-tests] document.
4949

50-
See the project [README][sdk_readme] for more details.
50+
See the project [README][sdk-readme] for more details.
5151

52-
[dep_tool]:https://golang.github.io/dep/docs/installation.html
53-
[git_tool]:https://git-scm.com/downloads
54-
[go_tool]:https://golang.org/dl/
55-
[repo_sdk]:https://github.com/operator-framework/operator-sdk
56-
[fork_guide]:https://help.github.com/en/articles/fork-a-repo
57-
[docker_tool]:https://docs.docker.com/install/
58-
[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
59-
[sdk_readme]:../../README.md
52+
[dep-tool]:https://golang.github.io/dep/docs/installation.html
53+
[git-tool]:https://git-scm.com/downloads
54+
[go-tool]:https://golang.org/dl/
55+
[repo-sdk]:https://github.com/operator-framework/operator-sdk
56+
[fork-guide]:https://help.github.com/en/articles/fork-a-repo
57+
[docker-tool]:https://docs.docker.com/install/
58+
[kubectl-tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
59+
[sdk-readme]:../../README.md
6060
[running-the-tests]: ./testing/running-the-tests.md

doc/helm/user-guide.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ This guide walks through an example of building a simple nginx-operator powered
44

55
## Prerequisites
66

7-
- [git][git_tool]
8-
- [docker][docker_tool] version 17.03+.
9-
- [kubectl][kubectl_tool] version v1.11.3+.
10-
- [dep][dep_tool] version v0.5.0+. (Optional if you aren't installing from source)
11-
- [go][go_tool] version v1.12+. (Optional if you aren't installing from source)
7+
- [git][git-tool]
8+
- [docker][docker-tool] version 17.03+.
9+
- [kubectl][kubectl-tool] version v1.11.3+.
10+
- [dep][dep-tool] version v0.5.0+. (Optional if you aren't installing from source)
11+
- [go][go-tool] version v1.12+. (Optional if you aren't installing from source)
1212
- Access to a Kubernetes v1.11.3+ cluster.
1313

14-
**Note**: This guide uses [minikube][minikube_tool] version v0.25.0+ as the
15-
local Kubernetes cluster and [quay.io][quay_link] for the public registry.
14+
**Note**: This guide uses [minikube][minikube-tool] version v0.25.0+ as the
15+
local Kubernetes cluster and [quay.io][quay-link] for the public registry.
1616

1717
## Install the Operator SDK CLI
1818

19-
Follow the steps in the [installation guide][install_guide] to learn how to install the Operator SDK CLI tool.
19+
Follow the steps in the [installation guide][install-guide] to learn how to install the Operator SDK CLI tool.
2020

2121
## Create a new project
2222

@@ -37,7 +37,7 @@ chart's default manifest. Be sure to double check that the rules generated
3737
in `deploy/role.yaml` meet the operator's permission requirements.
3838

3939
To learn more about the project directory structure, see the
40-
[project layout][layout_doc] doc.
40+
[project layout][layout-doc] doc.
4141

4242
### Use an existing chart
4343

@@ -66,7 +66,7 @@ If `--helm-chart-version` is not set, the SDK will fetch the latest available ve
6666

6767
### Operator scope
6868

69-
Read the [operator scope][operator_scope] documentation on how to run your operator as namespace-scoped vs cluster-scoped.
69+
Read the [operator scope][operator-scope] documentation on how to run your operator as namespace-scoped vs cluster-scoped.
7070

7171

7272
## Customize the operator logic
@@ -102,11 +102,11 @@ resources, along with a NOTES.txt template, which Helm chart developers use
102102
to convey helpful information about a release.
103103
104104
If you aren't already familiar with Helm Charts, take a moment to review
105-
the [Helm Chart developer documentation][helm_charts].
105+
the [Helm Chart developer documentation][helm-charts].
106106
107107
### Understanding the Nginx CR spec
108108
109-
Helm uses a concept called [values][helm_values] to provide customizations
109+
Helm uses a concept called [values][helm-values] to provide customizations
110110
to a Helm chart's defaults, which are defined in the Helm chart's `values.yaml`
111111
file.
112112

@@ -329,16 +329,16 @@ kubectl delete -f deploy/service_account.yaml
329329
kubectl delete -f deploy/crds/example_v1alpha1_nginx_crd.yaml
330330
```
331331

332-
[operator_scope]:./../operator-scope.md
333-
[install_guide]: ../user/install-operator-sdk.md
334-
[layout_doc]:./project_layout.md
335-
[homebrew_tool]:https://brew.sh/
336-
[dep_tool]:https://golang.github.io/dep/docs/installation.html
337-
[git_tool]:https://git-scm.com/downloads
338-
[go_tool]:https://golang.org/dl/
339-
[docker_tool]:https://docs.docker.com/install/
340-
[kubectl_tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
341-
[minikube_tool]:https://github.com/kubernetes/minikube#installation
342-
[helm_charts]:https://helm.sh/docs/developing_charts/
343-
[helm_values]:https://helm.sh/docs/using_helm/#customizing-the-chart-before-installing
344-
[quay_link]:https://quay.io
332+
[operator-scope]:./../operator-scope.md
333+
[install-guide]: ../user/install-operator-sdk.md
334+
[layout-doc]:./project_layout.md
335+
[homebrew-tool]:https://brew.sh/
336+
[dep-tool]:https://golang.github.io/dep/docs/installation.html
337+
[git-tool]:https://git-scm.com/downloads
338+
[go-tool]:https://golang.org/dl/
339+
[docker-tool]:https://docs.docker.com/install/
340+
[kubectl-tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
341+
[minikube-tool]:https://github.com/kubernetes/minikube#installation
342+
[helm-charts]:https://helm.sh/docs/developing_charts/
343+
[helm-values]:https://helm.sh/docs/using_helm/#customizing-the-chart-before-installing
344+
[quay-link]:https://quay.io

doc/sdk-cli-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Usage:
1919

2020
* `--image-build-args` string - extra, optional image build arguments as one string such as `"--build-arg https_proxy=$https_proxy"` (default "")
2121
* `--image-builder` string - tool to build OCI images. One of: `[docker, podman, buildah]` (default "docker")
22+
* `--go-build-args` string - extra Go build arguments as one string such as `"-ldflags -X=main.xyz=abc"`
2223
* `-h, --help` - help for build
2324

2425
### Use

doc/test-framework/scorecard.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ flags:
3131
- `--namespaced-manifest` - if set, this flag must point to a manifest file with all resources that run within a namespace. By default, the scorecard will combine `service_account.yaml`, `role.yaml`, `role_binding.yaml`, and `operator.yaml` from the `deploy` directory into a temporary manifest to use as the namespaced manifest.
3232
- `--global-manifest` - if set, this flag must point to all required resources that run globally (not namespaced). By default, the scorecard will combine all CRDs in the `deploy/crds` directory into a temporary manifest to use as the global manifest.
3333
- `--namespace` - if set, which namespace to run the scorecard tests in. If it is not set, the scorecard will use the default namespace of the current context set in the kubeconfig file.
34+
- `--olm-deployed` - indicates that the CSV and relevant CRD's have been deployed onto the cluster by the [Operator Lifecycle Manager (OLM)][olm]. This flag cannot be used in conjunction with `--namespaced-manifest` or `--global-manifest`. See the [CSV-only tests](#running-the-scorecard-with-a-deployed-csv) section below for more details.
3435

3536
To run the tests, simply run the `scorecard` subcommand from your project root with the flags you want to
3637
use. For example:
@@ -324,8 +325,24 @@ Example of a valid JSON output:
324325

325326
**NOTE:** The `ScorecardOutput.Log` field is only intended to be used to log the scorecard's output and the scorecard will ignore that field if a plugin provides it.
326327

328+
## Running the scorecard with a deployed CSV
329+
330+
The scorecard can be run using only a [Cluster Service Version (CSV)][olm-csv], providing a way to test cluster-ready and non-SDK operators.
331+
332+
Running with a CSV alone requires both the `--csv-path=<CSV manifest path>` and `--olm-deployed` flags to be set. The scorecard assumes your CSV and relevant CRD's have been deployed onto the cluster using the OLM when using `--olm-deployed`. This [document][olm-deploy-operator] walks through bundling your CSV and CRD's, deploying the OLM on minikube or [OKD][okd], and deploying your operator. Once these steps have been completed, run the scorecard with both the `--csv-path=<CSV manifest path>` and `--olm-deployed` flags.
333+
334+
A few notes:
335+
336+
- As of now, using the scorecard with a CSV does not permit multiple CR manifests to be set through the CLI/config/CSV annotations. You will have to tear down your operator in the cluster, re-deploy, and re-run the scorecard for each CR being tested. In the future the scorecard will fully support testing multiple CR's without requiring users to teardown/standup each time.
337+
- You can either use `--cr-manifest` or your CSV's [`metadata.annotations['alm-examples']`][olm-csv-alm-examples] to provide CR's to the scorecard, but not both.
338+
327339
[cli-reference]: ../sdk-cli-reference.md#scorecard
328340
[writing-tests]: ./writing-e2e-tests.md
329341
[owned-crds]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#owned-crds
330342
[alm-examples]: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#crd-templates
331343
[viper]: https://github.com/spf13/viper/blob/master/README.md
344+
[olm-csv]:https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md
345+
[olm-csv-alm-examples]:https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#crd-templates
346+
[olm]:https://github.com/operator-framework/operator-lifecycle-manager
347+
[olm-deploy-operator]:https://github.com/operator-framework/community-operators/blob/master/docs/testing-operators.md
348+
[okd]:https://www.okd.io/

0 commit comments

Comments
 (0)