// Copyright (C) 2020 Bloomberg LP
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

import "build/bazel/remote/execution/v2/remote_execution.proto";
import "google/protobuf/duration.proto";

message RexplorerOutput {
    // The action with inline'd Command + Input Root
    InlinedAction action = 1;
    build.bazel.remote.execution.v2.ActionResult action_result = 2;

    // The output can either have the above two fields or just have the root
    repeated FSEntry root = 3;
}

// Action with the command + input_root broken out to
// make it more readable when json-ify'd
message InlinedAction {
    build.bazel.remote.execution.v2.Command command = 1;

    repeated FSEntry input_root = 2;

    google.protobuf.Duration timeout = 3;

    bool do_not_cache = 4;

    bytes salt = 5;

    build.bazel.remote.execution.v2.Platform platform = 6;
}

// An entry of a filesystem, which in the case of a directory has additional entries.
// Inspired by the format used by "tree -J"
message FSEntry {
    // Can be either file, directory, or symlink.
    string type = 1;
    string name = 2;
    string digest = 4;
    // Only populated by entries of type 'directory'
    repeated FSEntry contents = 3;
}
