Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ The `--release_branch` specifies the value of the ***release_branch_prefix*** at

The `create_gitops_prs` tool will query all `gitops` targets which have set the ***deploy_branch*** attribute (see [k8s_deploy](#k8s_deploy)) and the ***release_branch_prefix*** attribute value that matches the `release_branch` parameter.

In case you need to specify a custom Bazel flag during the pull request process, you can add one `--bazel_flag` such as `--bazel_flag --config=ci` or multiple such as `--bazel_flag --config=ci --bazel_flag --color=no`.

The all discovered `gitops` targets are grouped by the value of ***deploy_branch*** attribute. The one deployment branch will accumulate the output of all corresponding `gitops` targets.

For example, we define two deployments: grafana and prometheus. Both deployments share the same namespace. The deployments a grouped by namespace.
Expand Down
2 changes: 2 additions & 0 deletions gitops/gitops.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def __create_gitops_prs_impl(ctx):
executables = src_by_train[deployment_branch]
for exe in executables:
params += "--resolved_binary {}:{} ".format(deployment_branch, exe.short_path)
if ctx.attr.bazel_flag:
params += "--bazel_flag {} ".format(ctx.attr.bazel_flag)
for exe in trans_img_pushes:
params += "--resolved_push {} ".format(exe.files_to_run.executable.short_path)
if ctx.attr.release_branch:
Expand Down
17 changes: 16 additions & 1 deletion gitops/prer/create_gitops_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (i *SliceFlags) Set(value string) error {
var (
releaseBranch = flag.String("release_branch", "master", "filter gitops targets by release branch")
bazelCmd = flag.String("bazel_cmd", "tools/bazel", "bazel binary to use")
bazelFlags SliceFlags
workspace = flag.String("workspace", "", "path to workspace root")
repo = flag.String("git_repo", "", "git repo location")
gitMirror = flag.String("git_mirror", "", "git mirror location, like /mnt/mirror/bitbucket.tubemogul.info/tm/repo.git for jenkins")
Expand All @@ -77,6 +78,7 @@ var (
)

func init() {
flag.Var(&bazelFlags, "bazel_flag", "bazel flag to pass during gitops phase. Can be specified multiple times. Default is empty")
flag.Var(&gitopsKind, "gitops_dependencies_kind", "dependency kind(s) to run during gitops phase. Can be specified multiple times. Default is 'k8s_container_push'")
flag.Var(&gitopsRuleName, "gitops_dependencies_name", "dependency name(s) to run during gitops phase. Can be specified multiple times. Default is empty")
flag.Var(&gitopsRuleAttr, "gitops_dependencies_attr", "dependency attribute(s) to run during gitops phase. Use attribute=value format. Can be specified multiple times. Default is empty")
Expand Down Expand Up @@ -266,7 +268,20 @@ func main() {
exec.Mustex("", bin)
} else {
log.Println("target", target, "is not a file, running as a command")
exec.Mustex("", *bazelCmd, "run", target)

args := []string{"run"}

if len(bazelFlags) > 0 {
for _, bazelFlag := range bazelFlags {
bazelFlagArgs := strings.Split(bazelFlag, " ")

args = append(args, bazelFlagArgs...)
}
}

args = append(args, target)

exec.Mustex("", *bazelCmd, args...)
}
}
}()
Expand Down