syntax = "proto3";

// If you make any changes make sure you run: make regenerate-proto

package gitlab.agent.entity;

option go_package = "gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v18/pkg/entity";

import "buf/validate/validate.proto";

// AgentkMeta contains information about agentk.
message AgentkMeta {
  // Version of the binary.
  string version = 1 [json_name = "version", (buf.validate.field).string = {max_bytes: 50}];
  // Short commit sha of the binary. (deprecated in favor of git_ref)
  string commit_id = 2 [json_name = "commit_id", (buf.validate.field).string = {max_bytes: 255}, deprecated = true];
  // Namespace of the Pod running the binary.
  string pod_namespace = 3 [json_name = "pod_namespace", (buf.validate.field).string = {min_len: 1, max_bytes: 63}];
  // Name of the Pod running the binary.
  string pod_name = 4 [json_name = "pod_name", (buf.validate.field).string = {min_len: 1, max_bytes: 255}];
  // Version of the Kubernetes cluster.
  KubernetesVersion kubernetes_version = 5 [json_name = "kubernetes_version"];
  // Git Reference of the binary. SHA, tag, or empty.
  string git_ref = 6 [json_name = "git_ref", (buf.validate.field).string = {max_bytes: 255}];
  // Extra telemetry data to report to GitLab.
  map<string, string> extra_telemetry_data = 7 [
    json_name = "extra_telemetry_data",
    (buf.validate.field).map.max_pairs = 8,
    (buf.validate.field).map.keys = {
      string: {
        min_len: 3
        max_len: 64
      }
    },
    (buf.validate.field).map.values = {
      string: {
        max_len: 255
      }
    }
  ];
}

message AgentwMeta {
  // Version of the binary.
  string version = 1 [json_name = "version", (buf.validate.field).string = {max_bytes: 50}];
  // Git Reference of the binary. SHA, tag, or empty.
  string git_ref = 2 [json_name = "git_ref", (buf.validate.field).string = {max_bytes: 255}];
  // Extra telemetry data to report to GitLab.
  map<string, string> extra_telemetry_data = 3 [
    json_name = "extra_telemetry_data",
    (buf.validate.field).map.max_pairs = 8,
    (buf.validate.field).map.keys = {
      string: {
        min_len: 3
        max_len: 64
      }
    },
    (buf.validate.field).map.values = {
      string: {
        max_len: 255
      }
    }
  ];
  // Running agent's architecture target: one of 386, amd64, arm, s390x, and so on.
  string architecture = 4 [json_name = "architecture", (buf.validate.field).string.min_bytes = 1];
}

// Version information of the Kubernetes cluster.
message KubernetesVersion {
  // Major version of the Kubernetes cluster.
  string major = 1 [json_name = "major", (buf.validate.field).string = {max_bytes: 20}];
  // Minor version of the Kubernetes cluster.
  string minor = 2 [json_name = "minor", (buf.validate.field).string = {max_bytes: 20}];
  // Git version of the Kubernetes cluster.
  string git_version = 3 [json_name = "git_version", (buf.validate.field).string = {max_bytes: 255}];
  // Platform of the Kubernetes cluster.
  string platform = 4 [json_name = "platform", (buf.validate.field).string = {max_bytes: 255}];
}

message GitalyInfo {
  string address = 1 [json_name = "address", (buf.validate.field).string.min_bytes = 1];
  string token = 2 [json_name = "token"];
  map<string, string> features = 3 [json_name = "features"];
}

// Modified copy of Gitaly's https://gitlab.com/gitlab-org/gitaly/-/blob/55cb537898bce04e5e44be074a4d3d441e1f62b6/proto/shared.proto#L25
// Was copied to avoid exposing Gitaly type in the API and forcing the consumer to have a dependency on Gitaly.
message GitalyRepository {
  string storage_name = 2 [json_name = "storage_name", (buf.validate.field).string.min_bytes = 1];
  string relative_path = 3 [json_name = "relative_path", (buf.validate.field).string.min_bytes = 1];
  // Sets the GIT_OBJECT_DIRECTORY envvar on git commands to the value of this field.
  // It influences the object storage directory the SHA1 directories are created underneath.
  string git_object_directory = 4 [json_name = "git_object_directory"];
  // Sets the GIT_ALTERNATE_OBJECT_DIRECTORIES envvar on git commands to the values of this field.
  // It influences the list of Git object directories which can be used to search for Git objects.
  repeated string git_alternate_object_directories = 5 [json_name = "git_alternate_object_directories"];
  // Used in callbacks to GitLab so that it knows what repository the event is
  // associated with. May be left empty on RPC's that do not perform callbacks.
  // During project creation, `gl_repository` may not be known.
  string gl_repository = 6 [json_name = "gl_repository", (buf.validate.field).string.min_bytes = 1];
  // The human-readable GitLab project path (e.g. gitlab-org/gitlab-ce).
  // When hashed storage is use, this associates a project path with its
  // path on disk. The name can change over time (e.g. when a project is
  // renamed). This is primarily used for logging/debugging at the
  // moment.
  string gl_project_path = 8 [json_name = "gl_project_path", (buf.validate.field).string.min_bytes = 1];
}
