Skip to content

Commit 5711726

Browse files
authored
Apantuso/revert to working build script (app-sre#207)
* Revert "test: adding integration suite (app-sre#196)" This reverts commit 9b953dc. * Revert "Boilerplate: Update to a6c27570590858412f03ce4b84e7d6bb1ecfdc7a (app-sre#194)" This reverts commit e648b6a.
1 parent 9b953dc commit 5711726

33 files changed

+423
-1162
lines changed

.ci-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: boilerplate
33
namespace: openshift
4-
tag: image-v2.3.2
4+
tag: image-v1.0.0

.codecov.yml

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ comment:
2424
layout: "reach,diff,flags,tree"
2525
behavior: default
2626
require_changes: no
27-
28-
ignore:
29-
- "**/mocks"
30-
- "**/zz_generated*.go"

boilerplate/_data/backing-image-tag

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
image-v2.3.2
1+
image-v1.0.0
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a6c27570590858412f03ce4b84e7d6bb1ecfdc7a
1+
b0a20637c47d7d94d6bdadbb2660b4f081526015

boilerplate/_lib/container-make

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@ fi
99

1010
source ${0%/*}/common.sh
1111

12-
CONTAINER_ENGINE="${CONTAINER_ENGINE:-$(command -v podman || command -v docker)}"
12+
CONTAINER_ENGINE=$(command -v podman || command -v docker)
1313
[[ -n "$CONTAINER_ENGINE" ]] || err "Couldn't find a container engine. Are you already in a container?"
1414

15+
CONTAINER_ENGINE_SHORT=${CONTAINER_ENGINE##*/}
16+
1517
# Make sure the mount inside the container is named in such a way that
1618
# - openapi-gen (which relies on GOPATH) produces absolute paths; and
1719
# - other go-ish paths are writeable, e.g. for `go mod download`.
1820
CONTAINER_MOUNT=/go/src/$(repo_import $REPO_ROOT)
1921

2022
# First set up a detached container with the repo mounted.
2123
banner "Starting the container"
22-
if [[ "${CONTAINER_ENGINE##*/}" == "podman" ]]; then
23-
if [[ $OSTYPE == *"darwin"* ]]; then
24-
CE_OPTS="--userns keep-id -v $REPO_ROOT:$CONTAINER_MOUNT"
25-
else
26-
CE_OPTS="--userns keep-id -v $REPO_ROOT:$CONTAINER_MOUNT:Z"
27-
fi
24+
if [[ $CONTAINER_ENGINE_SHORT == "podman" ]]; then
25+
container_id=$($CONTAINER_ENGINE run --userns keep-id -d -v "$REPO_ROOT":"$CONTAINER_MOUNT":Z $IMAGE_PULL_PATH tail -f /dev/null)
2826
else
29-
CE_OPTS="-v $REPO_ROOT:$CONTAINER_MOUNT"
27+
container_id=$($CONTAINER_ENGINE run -d -v "$REPO_ROOT":"$CONTAINER_MOUNT" $IMAGE_PULL_PATH tail -f /dev/null)
3028
fi
31-
container_id=$($CONTAINER_ENGINE run -d ${CE_OPTS} $IMAGE_PULL_PATH sleep infinity)
3229

3330
if [[ $? -ne 0 ]] || [[ -z "$container_id" ]]; then
3431
err "Couldn't start detached container"

boilerplate/_lib/subscriber-propose

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare -A SUBCOMMANDS
77
SUBCOMMANDS=(
88
# TODO:
99
# [bootstrap]='Bootstrap a new subscriber'
10+
# [codecov-secret-mapping]='Propose codecov secret mapping to openshift/release'
1011
# [prow-config]='Propose standardized prow configuration to openshift/release'
1112
[update]='Update an already-onboarded subscriber'
1213
)

boilerplate/openshift/golang-osd-operator/.codecov.yml

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ comment:
2424
layout: "reach,diff,flags,tree"
2525
behavior: default
2626
require_changes: no
27-
28-
ignore:
29-
- "**/mocks"
30-
- "**/zz_generated*.go"

boilerplate/openshift/golang-osd-operator/README.md

+21-40
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ This convention is suitable for both cluster- and hive-deployed operators.
1414
The following components are included:
1515

1616
## `make` targets and functions.
17-
1817
**Note:** Your repository's main `Makefile` needs to be edited to include the
1918
"nexus makefile include":
2019

@@ -29,7 +28,7 @@ following:
2928
### Prow
3029

3130
| Test name / `make` target | Purpose |
32-
| ------------------------- | --------------------------------------------------------------------------------------------------------------- |
31+
|---------------------------|-----------------------------------------------------------------------------------------------------------------|
3332
| `validate` | Ensure code generation has not been forgotten; and ensure generated and boilerplate code has not been modified. |
3433
| `lint` | Perform static analysis. |
3534
| `test` | "Local" unit and functional testing. |
@@ -49,26 +48,18 @@ $ make RELEASE_CLONE=/home/me/github/openshift/release prow-config
4948
```
5049

5150
This will generate a delta configuring prow to:
52-
5351
- Build your `build/Dockerfile`.
5452
- Run the above targets in presubmit tests.
5553
- Run the `coverage` target in a postsubmit. This is the step that
5654
updates your coverage report in codecov.io.
5755

5856
#### Local Testing
59-
6057
You can run these `make` targets locally during development to test your
6158
code changes. However, differences in platforms and environments may
6259
lead to unpredictable results. Therefore boilerplate provides a utility
6360
to run targets in a container environment that is designed to be as
6461
similar as possible to CI:
6562

66-
```shell
67-
$ make container-{target}
68-
```
69-
70-
or
71-
7263
```shell
7364
$ ./boilerplate/_lib/container-make {target}
7465
```
@@ -81,15 +72,27 @@ By default it is configured to be run from the app-sre jenkins pipelines.
8172
Consult [this doc](app-sre.md) for information on local execution/testing.
8273

8374
## Code coverage
84-
8575
- A `codecov.sh` script, referenced by the `coverage` `make` target, to
86-
run code coverage analysis per [this SOP](https://github.com/openshift/ops-sop/blob/93d100347746ce04ad552591136818f82043c648/services/codecov.md).
76+
run code coverage analysis per [this SOP](https://github.com/openshift/ops-sop/blob/93d100347746ce04ad552591136818f82043c648/services/codecov.md).
8777

8878
- A `.codecov.yml` configuration file for
8979
[codecov.io](https://docs.codecov.io/docs/codecov-yaml). Note that
9080
this is copied into the repository root, because that's
9181
[where codecov.io expects it](https://docs.codecov.io/docs/codecov-yaml#can-i-name-the-file-codecovyml).
9282

83+
- A `make` target to [request the secret mapping in openshift/release](https://github.com/openshift/ops-sop/blob/be43125239deb1f2bbc1ef54f010410e97ff6146/services/codecov.md#openshiftrelease-pr-1---secret-mapping):
84+
85+
```shell
86+
$ make codecov-secret-mapping
87+
```
88+
89+
If you already have the openshift/release repository cloned locally, you
90+
may specify its path via `$RELEASE_CLONE`:
91+
92+
```shell
93+
$ make RELEASE_CLONE=/home/me/github/openshift/release codecov-secret-mapping
94+
```
95+
9396
## Linting and other static analysis with `golangci-lint`
9497

9598
- A `go-check` `make` target, which
@@ -104,35 +107,13 @@ The convention embeds default checks to ensure generated code generation is curr
104107
To trigger the check, you can use `make generate-check` provided your Makefile properly includes the boilerplate-generated include `boilerplate/generated-includes.mk`.
105108

106109
Checks consist of:
107-
108-
- Checking all files are committed to ensure a safe point to revert to in case of error
109-
- Running the `make generate` command (see below) to regenerate the needed code
110-
- Checking if this results in any new uncommitted files in the git project or if all is clean.
110+
* Checking all files are committed to ensure a safe point to revert to in case of error
111+
* Running the `make generate` command (see below) to regenerate the needed code
112+
* Checking if this results in any new uncommitted files in the git project or if all is clean.
111113

112114
`make generate` does the following:
113-
114-
- generate crds and deepcopy via controller-gen. This is a no-op if your
115+
* `operator-sdk generate crds` and `k8s`. This is a no-op if your
115116
operator has no APIs.
116-
- `openapi-gen`. This is a no-op if your operator has no APIs.
117-
- `go generate`. This is a no-op if you have no `//go:generate`
117+
* `openapi-gen`. This is a no-op if your operator has no APIs.
118+
* `go generate`. This is a no-op if you have no `//go:generate`
118119
directives in your code.
119-
120-
## FIPS (Federal Information Processing Standards)
121-
122-
To enable FIPS in your build there is a `make ensure-fips` target.
123-
124-
Add `FIPS_ENABLED=true` to your repos Makefile. Please ensure that this variable is added **before** including boilerplate Makefiles.
125-
126-
e.g.
127-
128-
```.mk
129-
FIPS_ENABLED=true
130-
131-
include boilerplate/generated-includes.mk
132-
```
133-
134-
`ensure-fips` will add a [fips.go](./fips.go) file in the same directory as the `main.go` file. (Please commit this file as normal)
135-
136-
`fips.go` will import the necessary packages to restrict all TLS configuration to FIPS-approved settings.
137-
138-
With `FIPS_ENABLED=true`, `ensure-fips` is always run before `make go-build`

boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ for channel in staging production; do
6868
echo "properly. Nothing to do!"
6969
else
7070
# build the CSV and create & push image catalog for the appropriate channel
71-
make ${channel}-csv-build ${channel}-catalog-build ${channel}-catalog-publish
71+
make ${channel}-common-csv-build ${channel}-catalog-build ${channel}-catalog-publish
7272
fi
7373
done

boilerplate/openshift/golang-osd-operator/app-sre.md

-11
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ If not, you will need to set the `IMAGE_REGISTRY` environment variable (see [bel
2121
The SaaS bundle repository for `$OPERATOR_NAME` should be located at `https://gitlab.cee.redhat.com/service/saas-{operator}-bundle`, e.g. https://gitlab.cee.redhat.com/service/saas-deadmanssnitch-operator-bundle.
2222
Fork it to your personal namespace.
2323

24-
If you have already forked it to your personal namespace and/or used your fork for testing app-sre scripts at some time in the past, it is recommended that you bring your fork in sync with how upstream appears, or else the catalog you test with may not work correctly when deployed.
25-
26-
An example of how to do this for the `staging` branch is below (`production` steps are the same):
27-
28-
```
29-
git checkout staging
30-
git pull upstream staging
31-
git reset --hard upstream/staging
32-
git push origin staging --force
33-
```
34-
3524
## Set environment variables
3625
```bash
3726
# The process creates artifacts in your git clone. Some of the make targets

boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh

-8
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,6 @@ function main() {
320320
local versions
321321
# shellcheck disable=SC2207
322322
versions=($(get_prev_operator_version "$bundle_versions_file"))
323-
# This condition is triggered when an operator is built for the first time. In such case the
324-
# get_prev_operator_version returns an empty string and causes undefined variables failures
325-
# in a few lines below.
326-
if [ -z ${versions+x} ]
327-
then
328-
versions[0]=""
329-
versions[1]=""
330-
fi
331323
local prev_operator_version="${versions[0]}"
332324
local prev_good_operator_version="${versions[1]}"
333325
local skip_versions=("${versions[@]:2}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
REPO_ROOT=$(git rev-parse --show-toplevel)
6+
source $REPO_ROOT/boilerplate/_lib/common.sh
7+
source $REPO_ROOT/boilerplate/_lib/release.sh
8+
9+
cmd=${0##*/}
10+
11+
usage() {
12+
cat <<EOF
13+
Usage: $cmd [PATH_TO_RELEASE_CLONE]
14+
15+
Creates a delta in $RELEASE_REPO requesting a codecov secret mapping for a
16+
boilerplate consumer. Must be invoked from within a local clone of a repository
17+
already subscribed to the $CONVENTION_NAME convention.
18+
19+
Parameters:
20+
PATH_TO_RELEASE_CLONE File system path to a local clone of
21+
https://github.com/$RELEASE_REPO. If not
22+
specified, the repository will be cloned in a
23+
temporary directory.
24+
EOF
25+
exit -1
26+
}
27+
28+
# Was a release repo clone specified?
29+
release_process_args "$@"
30+
31+
release_validate_invocation
32+
33+
release_prep_clone
34+
35+
cd $RELEASE_CLONE
36+
37+
mapping_file=core-services/secret-mirroring/_mapping.yaml
38+
secret_name=$CONSUMER_NAME-codecov-token
39+
40+
# TODO: Do some proper yaml validation and editing here.
41+
42+
# See if the mapping already exists. This ain't great: it assumes the
43+
# lines are in a particular order, and doesn't check the namespaces. See
44+
# TODO above :)
45+
grep -B2 $secret_name $mapping_file && err "
46+
Found existing mapping in $mapping_file
47+
Nothing to do."
48+
49+
# Append it. This ain't great: it assumes the `secrets` top-level key is
50+
# still in play, that we're matching whitespace, etc. See TODO above :)
51+
cat <<EOF >> $mapping_file
52+
- from:
53+
namespace: sd-sre-secrets
54+
name: $secret_name
55+
to:
56+
namespace: ci
57+
name: $secret_name
58+
EOF
59+
60+
release_branch=$CONSUMER_ORG-$CONSUMER_NAME-$DEFAULT_BRANCH-boilerplate-$cmd
61+
62+
release_done_msg $release_branch

boilerplate/openshift/golang-osd-operator/configure-fips.sh

-18
This file was deleted.

boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh

+2-25
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ while getopts "o:c:r:" option; do
2323
esac
2424
done
2525

26-
# Detect the container engine to use, allowing override from the env
27-
CONTAINER_ENGINE=${CONTAINER_ENGINE:-$(command -v podman || command -v docker || true)}
28-
if [[ -z "$CONTAINER_ENGINE" ]]; then
29-
echo "WARNING: Couldn't find a container engine! Defaulting to docker."
30-
CONTAINER_ENGINE=docker
31-
fi
32-
3326
# Checking parameters
3427
check_mandatory_params operator_channel operator_name
3528

@@ -63,29 +56,13 @@ EOF
6356

6457
# Build registry
6558
cat <<EOF > $DOCKERFILE_REGISTRY
66-
FROM quay.io/openshift/origin-operator-registry:4.10.0 AS builder
59+
FROM quay.io/openshift/origin-operator-registry:4.8.0
6760
COPY $SAAS_OPERATOR_DIR manifests
6861
RUN initializer --permissive
69-
70-
FROM registry.access.redhat.com/ubi8/ubi-micro:8.6-484
71-
72-
COPY --from=builder /bin/registry-server /bin/registry-server
73-
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe
74-
COPY --from=builder /bin/initializer /bin/initializer
75-
76-
WORKDIR /registry
77-
RUN chgrp -R 0 /registry && chmod -R g+rwx /registry
78-
79-
USER 1001
80-
81-
COPY --from=builder /registry /registry
82-
83-
EXPOSE 50051
84-
8562
CMD ["registry-server", "-t", "/tmp/terminate.log"]
8663
EOF
8764

88-
${CONTAINER_ENGINE} build --pull -f $DOCKERFILE_REGISTRY --tag "${registry_image}:${operator_channel}-latest" .
65+
docker build -f $DOCKERFILE_REGISTRY --tag "${registry_image}:${operator_channel}-latest" .
8966

9067
if [ $? -ne 0 ] ; then
9168
echo "docker build failed, exiting..."

boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh

+2-13
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ BUNDLE_DIR="${SAAS_OPERATOR_DIR}/${operator_name}"
4141
OPERATOR_NEW_VERSION=$(ls "${BUNDLE_DIR}" | sort -t . -k 3 -g | tail -n 1)
4242
OPERATOR_PREV_VERSION=$(ls "${BUNDLE_DIR}" | sort -t . -k 3 -g | tail -n 2 | head -n 1)
4343

44-
# Get container engine
45-
CONTAINER_ENGINE=$(command -v podman || command -v docker || true)
46-
[[ -n "$CONTAINER_ENGINE" ]] || echo "WARNING: Couldn't find a container engine. Assuming you already in a container, running unit tests." >&2
47-
48-
# Set SRC container transport based on container engine
49-
if [[ "${CONTAINER_ENGINE##*/}" == "podman" ]]; then
50-
SRC_CONTAINER_TRANSPORT="containers-storage"
51-
else
52-
SRC_CONTAINER_TRANSPORT="docker-daemon"
53-
fi
54-
5544
# Checking SAAS_OPERATOR_DIR exist
5645
if [ ! -d "${SAAS_OPERATOR_DIR}/.git" ] ; then
5746
echo "${SAAS_OPERATOR_DIR} should exist and be a git repository"
@@ -96,7 +85,7 @@ popd
9685
if [ "$push_catalog" = true ] ; then
9786
# push image
9887
skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \
99-
"${SRC_CONTAINER_TRANSPORT}:${registry_image}:${operator_channel}-latest" \
88+
"docker-daemon:${registry_image}:${operator_channel}-latest" \
10089
"docker://${registry_image}:${operator_channel}-latest"
10190

10291
if [ $? -ne 0 ] ; then
@@ -105,7 +94,7 @@ if [ "$push_catalog" = true ] ; then
10594
fi
10695

10796
skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \
108-
"${SRC_CONTAINER_TRANSPORT}:${registry_image}:${operator_channel}-latest" \
97+
"docker-daemon:${registry_image}:${operator_channel}-latest" \
10998
"docker://${registry_image}:${operator_channel}-${operator_commit_hash}"
11099

111100
if [ $? -ne 0 ] ; then

0 commit comments

Comments
 (0)