Documentation
¶
Overview ¶
Package create is the single owner of project, issue-type, and priority resolution for gadak create (CLI and REST). Both surfaces must call these functions so a default cannot exist on one path and not the other.
Need* errors carry catalogue data only. The CLI formats flag names; REST maps them to stable wire codes. This package does not name CLI flags.
Index ¶
- Constants
- func FillNeedProject(err error, catalog []origin.CreateMetaProject) error
- func FormatProjectKeys(meta []origin.CreateMetaProject) string
- func FormatTypes(types []origin.NamedID) string
- func MetaFor(meta []origin.CreateMetaProject, project string, cfg *config.Config) (origin.CreateMetaProject, []origin.CreateMetaIssueType, error)
- func MetaForWithCatalog(ctx context.Context, c CreateMetaSource, meta []origin.CreateMetaProject, ...) (origin.CreateMetaProject, []origin.CreateMetaIssueType, error)
- func Priority(want string, list []origin.NamedID) (id string, err error)
- func PriorityField(id string) map[string]string
- type AmbiguousTypeError
- type CreateMetaSource
- type NeedPriorityError
- type NeedProjectError
- type NeedTypeError
- type Resolved
- func ParentCatalogProject(parentKey string, catalog []origin.CreateMetaProject) (Resolved, bool)
- func Project(want string, cfg *config.Config) (Resolved, error)
- func SoleCatalogProject(catalog []origin.CreateMetaProject) (Resolved, bool)
- func Type(want string, types []origin.CreateMetaIssueType, cfg *config.Config, ...) (Resolved, error)
Constants ¶
const ( SourceFlag = "flag" SourceConfig = "config" SourceSole = "sole" SourceAlias = "alias" SourceCatalog = "catalog" // the site's createmeta said it, not the profile (GDK-1733) SourceParent = "parent" // a --parent key named it (GDK-1620) SourceMirror = "mirror" // the local mirror's rows settled it (GDK-1458) )
Source names recorded on --json / the REST create response so a caller can see why a project or type was chosen. Alias is a match that was not the catalog id or display name — untranslatedName, a hierarchy-derived epic/subtask token, or the small standard-name locale table.
Variables ¶
This section is empty.
Functions ¶
func FillNeedProject ¶ added in v0.17.0
func FillNeedProject(err error, catalog []origin.CreateMetaProject) error
FillNeedProject copies origin-known keys onto an empty NeedProjectError so a paired workspace (no local DefaultProject / Projects) can still print `configured: STD, IDEA`. Catalog empty leaves the error unchanged.
func FormatProjectKeys ¶ added in v0.17.0
func FormatProjectKeys(meta []origin.CreateMetaProject) string
FormatProjectKeys is the "KEY, KEY" list used in project-resolution errors.
func FormatTypes ¶
FormatTypes is the "Name (id N); …" list used in type-resolution errors.
func MetaFor ¶
func MetaFor(meta []origin.CreateMetaProject, project string, cfg *config.Config) (origin.CreateMetaProject, []origin.CreateMetaIssueType, error)
MetaFor picks the createmeta project (case-insensitive key) and its types. A miss lists the keys in meta the same way Type lists the issue-type catalog. Types stay as CreateMetaIssueType so Type can see hierarchy and untranslatedName; NamedID flattening is FormatTypes / NeedTypeError only.
func MetaForWithCatalog ¶ added in v0.17.0
func MetaForWithCatalog(ctx context.Context, c CreateMetaSource, meta []origin.CreateMetaProject, project string, cfg *config.Config) (origin.CreateMetaProject, []origin.CreateMetaIssueType, error)
MetaForWithCatalog is MetaFor, then the site catalog when the first answer had no keys to list (Jira's createmeta filtered to a missing key is empty). The catalog is fetched only on that fallback path, scoped to the profile's projects. CLI and REST both route here so they print the same available list.
func Priority ¶
Priority resolves a user-supplied name or id against the site catalog. Names follow the account language; the return is always the catalog id.
func PriorityField ¶
PriorityField is the Jira fields.priority value: always an id, never a localized name. Create and edit both send this shape.
Types ¶
type AmbiguousTypeError ¶ added in v0.22.0
AmbiguousTypeError is returned when one type name matches more than one catalog entry — a site whose admin duplicated a type (GDK-1458). Hits carries the duplicates so a surface with more context than the catalog (the local mirror's own rows) can still settle the pair.
func (*AmbiguousTypeError) Error ¶ added in v0.22.0
func (e *AmbiguousTypeError) Error() string
type CreateMetaSource ¶ added in v0.17.0
type CreateMetaSource interface {
CreateMeta(ctx context.Context, projects []string) ([]origin.CreateMetaProject, error)
}
CreateMetaSource is the origin verb MetaForWithCatalog uses on the empty-filter fallback. origin.Writer and *jira.Client both satisfy it.
type NeedPriorityError ¶
NeedPriorityError is returned when a priority name or id was required but empty. Available is the site catalog. Surfaces format this.
func (*NeedPriorityError) Error ¶
func (e *NeedPriorityError) Error() string
type NeedProjectError ¶
type NeedProjectError struct {
Configured []string
}
NeedProjectError is returned when create cannot resolve a project. Configured is the profile project list (may be empty). Surfaces format this.
func (*NeedProjectError) Error ¶
func (e *NeedProjectError) Error() string
type NeedTypeError ¶
NeedTypeError is returned when create cannot resolve an issue type. Available is the createmeta catalog. Surfaces format this.
func (*NeedTypeError) Error ¶
func (e *NeedTypeError) Error() string
type Resolved ¶
Resolved is one filled create field and where it came from.
func ParentCatalogProject ¶ added in v0.22.0
func ParentCatalogProject(parentKey string, catalog []origin.CreateMetaProject) (Resolved, bool)
ParentCatalogProject resolves the project from a --parent issue key: the key's project prefix names where the child must live, so `--parent NMB-1` is itself the `--project NMB` answer (GDK-1620). Case-insensitive against the catalog keys; a prefix with no catalog match or a key without a "-" (a bare id is not a key) leaves the choice open.
func Project ¶
Project resolves the create project:
- explicit flag / request field
- profile DefaultProject
- the sole configured project
- otherwise fail — inventing a project is not a default.
func SoleCatalogProject ¶ added in v0.22.0
func SoleCatalogProject(catalog []origin.CreateMetaProject) (Resolved, bool)
SoleCatalogProject resolves the project when the site's createmeta offers exactly one createable project — the paired-workspace shape where the profile carries no DefaultProject/Projects but the origin answer leaves nothing to choose (GDK-1733). The catalog, not a guess, is the authority; zero or two projects still refuse.
func Type ¶
func Type(want string, types []origin.CreateMetaIssueType, cfg *config.Config, project string) (Resolved, error)
Type resolves the create issue type:
- explicit flag / request field (matchType: id, name, then aliases)
- profile DefaultIssueTypeID, matched by id only
- the project has exactly one createmeta type
- otherwise fail
types[0] is deliberately not a fallback. The web dialog may pick types[0] because the person can see and change it before submit. A headless CLI or REST caller never sees that value, so the same fallback would silently file as the wrong type.