...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/config-connector/build.sh

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/config-connector

     1#!/usr/bin/env bash
     2# Copyright 2022 Google LLC
     3#
     4# Licensed under the Apache License, Version 2.0 (the "License");
     5# you may not use this file except in compliance with the License.
     6# You may obtain a copy of the License at
     7#
     8#      http://www.apache.org/licenses/LICENSE-2.0
     9#
    10# Unless required by applicable law or agreed to in writing, software
    11# distributed under the License is distributed on an "AS IS" BASIS,
    12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13# See the License for the specific language governing permissions and
    14# limitations under the License.
    15
    16set -o errexit
    17set -o nounset
    18set -o pipefail
    19
    20# builds the config-connector binary for a single system and architecture
    21# to build for a system / arch other than the default define the ${GOOS} and ${GOARCH} variables
    22source $(dirname "${BASH_SOURCE}")/../shared-vars-public.sh
    23cd ${REPO_ROOT}
    24
    25VERSION=${VERSION:-dev}
    26BASE_OUTPUT_DIR=${BIN_DIR}/${CONFIG_CONNECTOR_BINARY_NAME}
    27# if goarch OR goos is not set, grab it from the go env
    28export GOOS=${GOOS:-$(go env GOOS)}
    29export GOARCH=${GOARCH:-$(go env GOARCH)}
    30# create a target directory for the given system & architecture
    31OUTPUT_DIR=${BASE_OUTPUT_DIR}/${GOOS}/${GOARCH}
    32mkdir -p ${OUTPUT_DIR}
    33# run the build
    34echo "Building ${CONFIG_CONNECTOR_BINARY_NAME} for ${GOOS}/${GOARCH}"
    35LDFLAGS="-X \"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/cli/cmd.version=${VERSION}\""
    36OUTPUT_PATH=${OUTPUT_DIR}/${CONFIG_CONNECTOR_BINARY_NAME}
    37if [[ ${GOOS} == "windows" ]]; then
    38  OUTPUT_PATH="${OUTPUT_PATH}.exe"
    39fi
    40go build -ldflags "${LDFLAGS}" -o ${OUTPUT_PATH} github.com/GoogleCloudPlatform/k8s-config-connector/cmd/config-connector

View as plain text