forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
130646: drtprod: yaml config support r=sambhav-jain-16,vidit-bhat a=nameisbhaskar This implementation of drtprod enables you to define the series of commands in a YAML file and execute the same. This way you can define a sequence of commands for a cluster. You can find more details in https://cockroachlabs.atlassian.net/l/cp/0nxKZuyP. With this the expectation is to decommission drtprod script and move all configurations to smaller scripts and yaml. Fixes: cockroachdb#125381 Epic: None Co-authored-by: Bhaskarjyoti Bora <[email protected]>
- Loading branch information
Showing
15 changed files
with
821 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
|
||
go_library( | ||
name = "drtprod_lib", | ||
srcs = ["main.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/drtprod", | ||
visibility = ["//visibility:private"], | ||
deps = ["//pkg/cmd/drtprod/cli"], | ||
) | ||
|
||
go_binary( | ||
name = "drtprod", | ||
embed = [":drtprod_lib"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# DRT Prod | ||
|
||
drtprod is a tool for manipulating drt clusters using roachprod, | ||
allowing easy creating, destruction, controls and configurations of clusters. | ||
|
||
Commands include:<br/> | ||
<b>execute</b>: executes the commands in the YAML<br/> | ||
<b>*</b>: any other command is passed to roachprod, potentially with flags added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "cli", | ||
srcs = [ | ||
"handlers.go", | ||
"registry.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/drtprod/cli", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/cmd/drtprod/cli/commands", | ||
"//pkg/cmd/drtprod/helpers", | ||
"//pkg/roachprod", | ||
"@com_github_spf13_cobra//:cobra", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "commands", | ||
srcs = [ | ||
"rootcmd.go", | ||
"yamlprocessor.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/drtprod/cli/commands", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/build", | ||
"//pkg/cmd/drtprod/helpers", | ||
"@com_github_spf13_cobra//:cobra", | ||
"@in_gopkg_yaml_v2//:yaml_v2", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "commands_test", | ||
srcs = ["yamlprocessor_test.go"], | ||
embed = [":commands"], | ||
deps = ["@com_github_stretchr_testify//require"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package commands | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/build" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetRootCommand returns the root command | ||
func GetRootCommand(_ context.Context) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "drtprod [command] (flags)", | ||
Short: "drtprod runs roachprod commands against DRT clusters", | ||
Long: `drtprod is a tool for manipulating drt clusters using roachprod, | ||
allowing easy creating, destruction, controls and configurations of clusters. | ||
Commands include: | ||
execute: executes the commands as per the YAML configuration. Refer to pkg/cmd/drtprod/configs/drt_test.yaml as an example | ||
*: any other command is passed to roachprod, potentially with flags added | ||
`, | ||
Version: "details:\n" + build.GetInfo().Long(), | ||
} | ||
} |
Oops, something went wrong.