Skip to content

Commit

Permalink
STAC-21039: Allow for running branded and unbranded mode
Browse files Browse the repository at this point in the history
  • Loading branch information
craffit committed May 6, 2024
1 parent 71d56d6 commit ae796c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
30 changes: 20 additions & 10 deletions local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

set -e

SRC_PATH="/go/src/github.com/StackVista/stackstate-agent"
# We want to produce a final binary on a branded path, but it is convenient to run unit tests and the like on
# the original unbranded paths. Hence we allow for both.
if [[ "${BRANDED}" = "false" ]]; then
SRC_PATH="/go/src/github.com/DataDog/datadog-agent"
export AGENT_GITHUB_ORG=DataDog
export AGENT_REPO_NAME=datadog-agent
else
SRC_PATH="/go/src/github.com/StackVista/stackstate-agent"
export AGENT_GITHUB_ORG=StackVista
export AGENT_REPO_NAME=stackstate-agent
fi

WHAT=$1

if [ -z "${WHAT}" ]; then
Expand Down Expand Up @@ -31,15 +42,15 @@ function prepare() {
chown -R root:root $SRC_PATH
cd "$SRC_PATH" || exit

echo "Fixing import paths"
./fix_package_paths.sh "$SRC_PATH"

echo "Running tidy and vendor"
# TODO: Ideally we'd not need to run this, but because we update the package paths, we need to update go.mod/sum/vendor
# Alternative is to commit package renames, but that is also pretty messy
go mod tidy
go mod vendor
if [[ "${BRANDED}" != "false" ]]; then
echo "Fixing import paths"
./fix_package_paths.sh "$SRC_PATH"

echo "Running tidy after rewriting paths"
# TODO: Ideally we'd not need to run this, but because we update the package paths, we need to update go.mod/sum/vendor
# Alternative is to commit package renames, but that is also pretty messy
go mod tidy
fi
cd "$CI_PROJECT_DIR" || exit
}

Expand All @@ -57,7 +68,6 @@ if [ "${WHAT}" = "ALL" ] || [ "${WHAT}" = "DEPS_DEB" ]; then
echo " --- Getting dependencies ---"
echo " --- ---"
inv -e deps --verbose
go mod vendor
go mod tidy
inv agent.version --major-version 3 -u > version.txt
echo " --- ---"
Expand Down
8 changes: 3 additions & 5 deletions tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
from .libs.common.color import color_message

# constants
ORG_PATH = "github.com/StackVista" # sts
DEFAULT_BRANCH = "master" # sts
REPO_PATH = "{}/stackstate-agent".format(ORG_PATH) # sts
GITHUB_ORG = "StackVista"
REPO_NAME = "stackstate-agent"
GITHUB_ORG = os.environ['AGENT_GITHUB_ORG'] or "StackVista"
REPO_NAME = os.environ['AGENT_REPO_NAME'] or "stackstate-agent"
GITHUB_REPO_NAME = f"{GITHUB_ORG}/{REPO_NAME}"
REPO_PATH = f"github.com/{GITHUB_REPO_NAME}"
ALLOWED_REPO_NON_NIGHTLY_BRANCHES = {"dev", "stable", "beta", "none"}
Expand Down Expand Up @@ -147,7 +145,7 @@ def get_build_flags(
base = os.path.dirname(os.path.abspath(__file__))
task_repo_root = os.path.abspath(os.path.join(base, ".."))
git_repo_root = get_root()
gopath_root = f"{get_gopath(ctx)}/src/github.com/StackVista/stackstate-agent"
gopath_root = f"{get_gopath(ctx)}/src/github.com/{GITHUB_ORG}/{REPO_NAME}"

for root_candidate in [task_repo_root, git_repo_root, gopath_root]:
test_embedded_path = os.path.join(root_candidate, "dev")
Expand Down

0 comments on commit ae796c7

Please sign in to comment.