mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 15:47:14 +01:00
Previously, destroy support was behind TAGS=libvirt_destroy and create
support was always built in. But since 3fb4400c (terraform/plugins:
add `libvirt`, `aws`, `ignition`, `openstack` to KnownPlugins,
2018-12-14, #919), the bundled libvirt Terraform provider has also
been behind libvirt_destroy. That leads to cluster creation failing
with:
$ openshift-install create cluster
...
ERROR Missing required providers.
ERROR
ERROR The following provider constraints are not met by the currently-installed
ERROR provider plugins:
ERROR
ERROR * libvirt (any version)
ERROR
ERROR Terraform can automatically download and install plugins to meet the given
ERROR constraints, but this step was skipped due to the use of -get-plugins=false
ERROR and/or -plugin-dir on the command line.
...
With this commit, folks trying to 'create cluster' without libvirt
compiled in will get:
FATAL failed to fetch Common Manifests: failed to load asset "Install Config": invalid "install-config.yaml" file: platform: Invalid value: types.Platform{AWS:(*aws.Platform)(nil), Libvirt:(*libvirt.Platform)(0xc4209511f0), OpenStack:(*openstack.Platform)(nil)}: platform must be one of: aws, openstack
before we get to Terraform.
Now that the build tag guards both creation and deletion, I've renamed
it from 'libvirt_destroy' to the unqualified 'libvirt'.
I've also adjusted the install-config validation testing to use
regular expressions so we can distinguish between failures because
libvirt was not compiled in as a valid platform and failures because
some portion of the libvirt configuration was broken. In order to get
stable error messages for comparison, I've added some strings.Sort
calls for various allowed-value string-slice computations.
68 lines
1.6 KiB
Bash
Executable File
68 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -ex
|
|
|
|
# shellcheck disable=SC2068
|
|
version() { IFS="."; printf "%03d%03d%03d\\n" $@; unset IFS;}
|
|
|
|
minimum_go_version=1.10
|
|
current_go_version=$(go version | cut -d " " -f 3)
|
|
|
|
if [ "$(version "${current_go_version#go}")" -lt "$(version "$minimum_go_version")" ]; then
|
|
echo "Go version should be greater or equal to $minimum_go_version"
|
|
exit 1
|
|
fi
|
|
|
|
LAUNCH_PATH="${PWD}"
|
|
cd "$(dirname "$0")/.."
|
|
|
|
PACKAGE_PATH="$(go list -e -f '{{.Dir}}' github.com/openshift/installer)"
|
|
if test -z "${PACKAGE_PATH}"
|
|
then
|
|
echo "build from your \${GOPATH} (${LAUNCH_PATH} is not in $(go env GOPATH))" 2>&1
|
|
exit 1
|
|
fi
|
|
|
|
LOCAL_PATH="${PWD}"
|
|
if test "${PACKAGE_PATH}" != "${LOCAL_PATH}"
|
|
then
|
|
echo "build from your \${GOPATH} (${PACKAGE_PATH}, not ${LAUNCH_PATH})" 2>&1
|
|
exit 1
|
|
fi
|
|
|
|
MODE="${MODE:-release}"
|
|
LDFLAGS="${LDFLAGS} -X main.version=$(git describe --always --abbrev=40 --dirty)"
|
|
TAGS="${TAGS:-}"
|
|
OUTPUT="${OUTPUT:-bin/openshift-install}"
|
|
export CGO_ENABLED=0
|
|
|
|
case "${MODE}" in
|
|
release)
|
|
TAGS="${TAGS} release"
|
|
if test -n "${RELEASE_IMAGE}"
|
|
then
|
|
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/asset/ignition/bootstrap.defaultReleaseImage=${RELEASE_IMAGE}"
|
|
fi
|
|
if test -n "${RHCOS_BUILD_NAME}"
|
|
then
|
|
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/rhcos.buildName=${RHCOS_BUILD_NAME}"
|
|
fi
|
|
if test "${SKIP_GENERATION}" != y
|
|
then
|
|
go generate ./data
|
|
fi
|
|
;;
|
|
dev)
|
|
;;
|
|
*)
|
|
echo "unrecognized mode: ${MODE}" >&2
|
|
exit 1
|
|
esac
|
|
|
|
if (echo "${TAGS}" | grep -q 'libvirt')
|
|
then
|
|
export CGO_ENABLED=1
|
|
fi
|
|
|
|
go build -ldflags "${LDFLAGS}" -tags "${TAGS}" -o "${OUTPUT}" ./cmd/openshift-install
|