syntax = "proto2";

package janitor;

message Distribution {
  optional string name = 1;

  optional string archive_mirror_uri = 2;

  // This should eventually be distribution-specific
  optional string tracker_url = 3;

  // Chroot name to use in sbuild
  optional string chroot = 5;

  repeated string component = 4;

  optional string lintian_profile = 6;

  repeated string lintian_suppress_tag = 8;

  optional string build_command = 7;

  optional string vendor = 9;

  repeated string extra = 10;
}

message Config {
  // Location at which to store VCS repositories.
  optional string vcs_location = 1 [deprecated=true];

  // Location to store logs. Can either be a filesystem path or a http
  // location, for use with GCS or S3.
  optional string logs_location = 2;

  optional string apt_location = 3;

  // postgresql URL for database connection
  optional string database_location = 4;

  // Default committer to use when committing changes.
  optional string committer = 5;

  repeated Distribution distribution = 7;

  // Origin in published archives
  optional string origin = 8;

  optional OAuth2Provider oauth2_provider = 9;

  // Location to store build results
  optional string artifact_location = 10;

  optional string instance_name = 11;

  // Location for zipkin server
  optional string zipkin_address = 12;

  repeated Campaign campaign = 13;
}

message Env {
  optional string key = 1;
  optional string value = 2;
};

message MergeProposalConfig {
   optional int32 value_threshold = 1;

   optional string commit_message = 2;

   optional string title = 3;

   repeated string label = 4;
};

message Suite {
  // Name of the suite. E.g. "lintian-fixes"
  optional string name = 1;

  // VCS branch name to use
  optional string branch_name = 2;

  optional MergeProposalConfig merge_proposal = 5;

  // Force building even if the command did not make any changes.
  optional bool force_build = 6 [default=false];

  oneof build {
    DebianBuild debian_build = 3;
    GenericBuild generic_build = 4;
  }
}

message Campaign {
  // Name of the campaign. E.g. "lintian-fixes"
  optional string name = 1;

  // VCS branch name to use
  optional string branch_name = 2;

  optional MergeProposalConfig merge_proposal = 5;

  // Force building even if the command did not make any changes.
  optional bool force_build = 6 [default=false];

  oneof build {
    DebianBuild debian_build = 3;
    GenericBuild generic_build = 4;
  }

  // Does this campaign fix issues based on the repository contents
  // or some external source?
  optional bool webhook_trigger = 7 [default=false];
}

message GenericBuild {
  optional string chroot = 1;
}

message DebianBuild {
  // Extra distributions to pull in packages from when building
  repeated string extra_build_distribution = 1;

  // Sbuild environment override
  repeated Env sbuild_env = 2;

  optional string base_distribution = 3;

  // Optional chroot, if different from that of base_distribution
  optional string chroot = 4;

  // Human-readable description of the archive. Used in e.g. apt Release file.
  optional string archive_description = 5;

  // Distribution to target when building
  optional string build_distribution = 6;

  // Suffix to add to version in changelog on build.
  optional string build_suffix = 7;

  optional string build_command = 8;
};

message OAuth2Provider {
  optional string client_id = 1;

  optional string client_secret = 2;

  // A URL such as https://salsa.debian.org/
  // Used for finding e.g. token and authorize URLs
  optional string base_url = 3;

  // Name of the OpenID group for QA reviewers
  optional string qa_reviewer_group = 4;

  // Name of the OpenID group for admins
  optional string admin_group = 5;
};
