{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.138.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package prinfo\n\n## Constants\n\n```go\nconst (\n\t// EvidenceID is the identifier for the PR/MR info material type\n\tEvidenceID = \"CHAINLOOP_PR_INFO\"\n\t// EvidenceSchemaURL is the URL to the JSON schema for PR/MR info\n\tEvidenceSchemaURL = \"https://schemas.chainloop.dev/prinfo/1.3/pr-info.schema.json\"\n\n\t// AuthorTypeUser represents a human user account\n\tAuthorTypeUser = \"User\"\n\t// AuthorTypeBot represents a bot/service account\n\tAuthorTypeBot = \"Bot\"\n\t// AuthorTypeUnknown represents an account with unknown type\n\tAuthorTypeUnknown = \"unknown\"\n)\n```\n\n## Variables\n\n```go\nvar ErrInvalidJSONPayload = errors.New(\"invalid JSON payload\")\n```\nErrInvalidJSONPayload represents an error for an invalid JSON payload.\n\n## Functions\n\n```go\nfunc Schema(version Version) (string, error)\n```\nSchema returns the raw JSON schema document for the given version.\n\n```go\nfunc SchemaURL(version Version) string\n```\nSchemaURL returns the canonical, published URL of the given schema version.\n\n```go\nfunc Validate(data any, version Version) error\n```\nValidate validates a generically-decoded PR/MR info data payload against the given schema version. An empty version defaults to LatestVersion.\n\n## Types\n\n```go\ntype Author struct {\n\tLogin string `json:\"login\" jsonschema:\"required,description=Username of the PR/MR author\"`\n\tType  string `json:\"type\" jsonschema:\"required,enum=User,enum=Bot,enum=unknown,description=Account type of the PR/MR author\"`\n}\n```\nAuthor represents the author of the PR/MR with account type information\n\n```go\ntype Data struct {\n\tPlatform     string     `json:\"platform\" jsonschema:\"required,enum=github,enum=gitlab,description=The CI/CD platform\"`\n\tType         string     `json:\"type\" jsonschema:\"required,enum=pull_request,enum=merge_request,description=The type of change request\"`\n\tNumber       string     `json:\"number\" jsonschema:\"required,description=The PR/MR number or identifier\"`\n\tTitle        string     `json:\"title\" jsonschema:\"description=The PR/MR title\"`\n\tDescription  string     `json:\"description\" jsonschema:\"description=The PR/MR description or body\"`\n\tSourceBranch string     `json:\"source_branch\" jsonschema:\"description=The source branch name\"`\n\tTargetBranch string     `json:\"target_branch\" jsonschema:\"description=The target branch name\"`\n\tURL          string     `json:\"url\" jsonschema:\"required,format=uri,description=Direct URL to the PR/MR\"`\n\tAuthor       *Author    `json:\"author,omitempty\" jsonschema:\"description=The PR/MR author\"`\n\tReviewers    []Reviewer `json:\"reviewers,omitempty\" jsonschema:\"description=List of reviewers who reviewed or were requested to review\"`\n}\n```\nData represents the data payload of the PR/MR info evidence\n\n```go\nfunc (d *Data) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON implements custom JSON unmarshaling for Data to handle backwards compatibility where author can be either a string (v1.0-v1.2) or an object (v1.3+).\n\n```go\ntype Evidence struct {\n\tID     string `json:\"chainloop.material.evidence.id\"`\n\tSchema string `json:\"schema\"`\n\tData   Data   `json:\"data\"`\n}\n```\nEvidence represents the complete evidence structure for PR/MR metadata\n\n```go\nfunc NewEvidence(data Data) *Evidence\n```\nNewEvidence creates a new Evidence instance\n\n```go\ntype Generator struct {\n}\n```\nGenerator handles the generation of JSON schemas for PR info.\n\n```go\nfunc NewGenerator() *Generator\n```\nNewGenerator creates a new schema generator\n\n```go\nfunc (g *Generator) GenerateSchema(version Version) *jsonschema.Schema\n```\nGenerateSchema generates a JSON schema for the PR/MR info data.\n\n```go\nfunc (g *Generator) Save(schema *jsonschema.Schema, outputDir string, version Version) error\n```\nSave writes the schema to a file\n\n```go\ntype Reviewer struct {\n\tLogin        string `json:\"login\" jsonschema:\"required,description=Username of the reviewer\"`\n\tType         string `json:\"type\" jsonschema:\"required,enum=User,enum=Bot,enum=unknown,description=Account type of the reviewer\"`\n\tRequested    bool   `json:\"requested\" jsonschema:\"required,description=Whether the reviewer was explicitly requested to review\"`\n\tReviewStatus string `json:\"review_status,omitempty\" jsonschema:\"enum=APPROVED,enum=CHANGES_REQUESTED,enum=COMMENTED,enum=DISMISSED,enum=PENDING,description=The reviewer's current review state if they have submitted a review\"`\n}\n```\nReviewer represents a reviewer of the PR/MR\n\n```go\ntype Version string\n```\nVersion represents the version of the PR/MR info schema.\n\n```go\nconst (\n\t// Version1_0 represents PR/MR Info version 1.0 schema.\n\tVersion1_0 Version = \"1.0\"\n\t// Version1_1 represents PR/MR Info version 1.1 schema (adds reviewers).\n\tVersion1_1 Version = \"1.1\"\n\t// Version1_2 represents PR/MR Info version 1.2 schema (adds requested and review_status to reviewers).\n\tVersion1_2 Version = \"1.2\"\n\t// Version1_3 represents PR/MR Info version 1.3 schema (author as object with type).\n\tVersion1_3 Version = \"1.3\"\n\n\t// LatestVersion is the schema version emitted by this package.\n\tLatestVersion = Version1_3\n)\n```\n\n```go\nfunc Versions() []Version\n```\nVersions returns the supported schema versions, oldest first.\n\n","path":"github.com/chainloop-dev/chainloop/pkg/prinfo","name":"prinfo","synopsis":"","isRedistributable":true}
