Adds copybara file.
This is the original copybara file that was used in the sushid directory, on the filepaths have been changed
Will need to run.
go/copybara-service-commands#replace
PiperOrigin-RevId: 769183116
Change-Id: Ie3198b76af861f28a62eca2812a8b3a166b180af
diff --git a/google3/production/borg_mgmt/node_proxy/safepower/safepower_agent/copy.bara.sky b/google3/production/borg_mgmt/node_proxy/safepower/safepower_agent/copy.bara.sky
new file mode 100644
index 0000000..f9f49b2
--- /dev/null
+++ b/google3/production/borg_mgmt/node_proxy/safepower/safepower_agent/copy.bara.sky
@@ -0,0 +1,282 @@
+"""Copybara config to export file from google3 / safepower_agent to gPowerD
+
+Validate the config in terms of syntax:
+copybara validate copy.bara.sky
+
+1. Run the workflow in dry-run mode
+ alias copybara='/google/bin/releases/copybara/public/copybara/copybara'
+ gPowerD: copybara copy.bara.sky gpowerd_presubmit_piper_to_gerrit 12345 --dry-run --ignore-noop
+2. Format patch (get the GIT_DIR from the copybara output)
+ b) gPowerD: GIT_DIR=/usr/local/google/home/$USER/copybara/cache/git_repos/rpc%3A%2F%2Fgbmc%2FgPowerD git format-patch -1 \
+ && cp 0001-DO-NOT-SUBMIT.patch /path/to/gPowerD
+3. Apply the patch and test there.
+
+"""
+
+load("//devtools/copybara/library/scrubbing", "cc_scrub", "message_scrub_google_block", "proto_scrub")
+load("//devtools/copybara/library/workflow", "piper_sot_to_gerrit")
+
+#######################
+# Private definitions
+########################
+_cc_files = ["**.h", "**.cc", "**.in"]
+_proto_files = ["**.proto", "**.textproto"]
+_meson_files = ["**.build", "**meson_options.txt"]
+_copybara_config = [
+ "copy.bara.sky",
+]
+
+_gpowerd_codebase_lib = [
+ # go/keep-sorted start
+ "action_context.cc",
+ "action_context.h",
+ "action_hash.h",
+ "bmc/auth.cc",
+ "bmc/auth.h",
+ "bmc/auth_loas3.h",
+ "bmc/convert_status.h",
+ "bmc/daemon_context_bmc.cc",
+ "bmc/daemon_context_bmc.h",
+ "bmc/daemon_context_bmc_test.cc",
+ "bmc/gmi_reader.cc",
+ "bmc/gmi_reader.h",
+ "bmc/gmi_reader_test.cc",
+ "bmc/gpowerd.cc",
+ "bmc/http_connection.cc",
+ "bmc/http_connection.h",
+ "bmc/http_connection_test.cc",
+ "bmc/machine_configs/embedded_data.h",
+ "bmc/machine_configs/example.textproto",
+ "bmc/machine_configs/meson.build",
+ "bmc/machine_configs/setup_configs.cc",
+ "bmc/machine_configs/setup_configs.h",
+ "bmc/machine_configs/setup_configs_test.cc",
+ "bmc/meson.build",
+ "bmc/mock_server.h",
+ "bmc/persistent_storage_bmc.cc",
+ "bmc/persistent_storage_bmc.h",
+ "bmc/persistent_storage_bmc_test.cc",
+ "bmc/proto_reader.cc",
+ "bmc/proto_reader.h",
+ "bmc/proto_reader_test.cc",
+ "bmc/redfish.cc",
+ "bmc/redfish.h",
+ "bmc/register_actions_bmc.cc",
+ "bmc/register_actions_bmc.h",
+ "bmc/register_actions_bmc_test.cc",
+ "bmc/scheduler_bmc.cc",
+ "bmc/scheduler_bmc.h",
+ "bmc/scheduler_bmc_test.cc",
+ "bmc/state_monitor_bmc.cc",
+ "bmc/state_monitor_bmc.h",
+ "bmc/status_macros.h",
+ "bmc/test_util.h",
+ "condition.cc",
+ "condition.h",
+ "convert_proto.cc",
+ "convert_proto.h",
+ "daemon_context.cc",
+ "daemon_context.h",
+ "disruption_manager.cc",
+ "disruption_manager.h",
+ "gpowerd_build_config.h.in",
+ "meson.build",
+ "meson_options.txt",
+ "parse_text_proto.cc",
+ "parse_text_proto.h",
+ "persistent_storage.h",
+ "proto/meson.build",
+ "proto/safepower_agent.proto",
+ "proto/safepower_agent_config.proto",
+ "proto/state_persistence.proto",
+ "safepower_agent.cc",
+ "safepower_agent.h",
+ "scheduler_interface.h",
+ "state_change_reactor.h",
+ "state_fields.h",
+ "state_merge.cc",
+ "state_merge.h",
+ "state_updater.h",
+ # go/keep-sorted end
+]
+
+_all_gpowerd_google3_files = glob(
+ include =
+ _gpowerd_codebase_lib + _copybara_config,
+)
+
+_all_gob_files = glob(
+ include = ["**"],
+)
+
+allowed_authors = {
+ "jebr": "John Broadbent <jebr@google.com>",
+ "shounak": "Shounak Mitra <shounak@google.com>",
+ "arunsa": "Arun Satyanarayana <arunsa@google.com>",
+ "jainrish": "Rishabh Jain <jainrish@google.com>",
+ "sruthiganti": "Sruthi Ganti <sruthiganti@google.com>",
+}
+
+_transformations = [
+ ###############################
+ # common scrubs
+ ###############################
+ cc_scrub(),
+ proto_scrub(),
+ leakr.check(),
+ ###############################
+ # common headers
+ ###############################
+ core.replace(
+ before = "third_party/absl",
+ after = "absl",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/grpc/google_specific/include/",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/grpc/include/",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/protobuf/",
+ after = "google/protobuf/",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/json/include/nlohmann",
+ after = "nlohmann",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "proto/${proto_file}.proto.h",
+ after = "${proto_file}.pb.h",
+ regex_groups = {
+ "proto_file": "\\w+",
+ },
+ ),
+ core.replace(
+ before = "google/protobuf/${proto_file}.proto.h",
+ after = "google/protobuf/${proto_file}.pb.h",
+ regex_groups = {
+ "proto_file": "\\w+",
+ },
+ ),
+ core.replace(
+ before = "gmi/machine_identity.pb.h",
+ after = "gmi/machine_identity.pb.h",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "bmc/convert_status.h",
+ after = "bmc/convert_status.h",
+ ),
+ core.replace(
+ before = "bmc/status_macros.h",
+ after = "bmc/status_macros.h",
+ ),
+ core.replace(
+ before = "third_party/milotic/internal/cc/authn/generate_self_signed_cert.h",
+ after = "zatar/generate_self_signed_cert.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "proto2::",
+ after = "google::protobuf::",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "testing/base/public/gunit.h",
+ after = "gtest/gtest.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "testing/base/public/gmock.h",
+ after = "gmock/gmock.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "absl/types/source_location.h",
+ after = "source_location",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "absl::SourceLocation",
+ after = "std::source_location",
+ paths = glob(_cc_files),
+ ),
+ ###############################
+ # move
+ ###############################
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_proto_files),
+ ),
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_meson_files),
+ ),
+ # , , and are not yet present in the
+ # version of absl gBMC is using. Not all annotations may be present in our code yet, so ignore
+ # noop changes for these replacements.
+ # TODO: b/381875619 - Remove these when absl is bumped to 48f0f91 or newer.
+ core.transform([
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ ], ignore_noop = True),
+]
+
+piper_sot_to_gerrit(
+ name_prefix = "gpowerd",
+ google3_files = _all_gpowerd_google3_files,
+ git_files = _all_gob_files,
+ default_author = "gBMC Team <gbmc-core@google.com>",
+ allowed_authors = allowed_authors,
+ contact_email = "gbmc-core+copybara@google.com",
+ url = "rpc://gbmc/gPowerD",
+ transformations = _transformations,
+ owner_mdb = "gbmc-git-approvers",
+ ci_labels = ["Presubmit"],
+ common_flags = {
+ "--ignore-noop": [],
+ },
+ metadata_scrubber = message_scrub_google_block(),
+ multiple_gerrit_workflows = True,
+ branch = "master",
+)