edition = "2023";

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

package gitlab.agent.constraint;

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

import "buf/validate/validate.proto";

// See https://github.com/bufbuild/protovalidate/blob/main/docs/predefined-constraints.md.
extend buf.validate.StringRules {
  // https://gitlab.com/gitlab-org/cluster-integration/gitlab-agent/-/blob/master/doc/identity_and_auth.md#agent-identity-and-name
  bool is_agent_name = 193002 [(buf.validate.predefined).cel = {
    id: "string.is_agent_name"
    expression: "!rule || this.matches('^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$')" // is_agent_name==false or is_agent_name==true and matches
    message: "invalid agent name"
  }];
}
