Documentation
¶
Overview ¶
Package provider implements the Terraform Provider for Jira.
Highlights:
- Auth: API token for Jira Cloud (recommended) and basic auth for self-hosted Jira.
- Timeouts & retries: configurable HTTP timeout and capped exponential backoff; honors Retry-After.
- Concurrency: safe for parallel plans; declare explicit dependencies when API ordering matters.
- Deterministic outputs: data sources/resources avoid spurious diffs via stable IDs and sorting.
Further reading (canonical docs):
- Configuration & env vars: docs/index.md#configuration
- Retries, timeouts, and rate limits: docs/index.md#provider-retries-and-timeouts
- Troubleshooting: docs/index.md#troubleshooting
- Examples: docs/ and examples/
Index ¶
- Constants
- func BackoffDuration(attempt int, base, max time.Duration, jitter float64) time.Duration
- func DoListToMap[TAPI APIListConstraint, TOut OutModelConstraint](ctx context.Context, h ListHooks[TAPI, TOut]) (map[string]TOut, diag.Diagnostics)
- func DoListToMapWithLimit[TAPI APIListConstraint, TOut OutModelConstraint](ctx context.Context, h ListHooks[TAPI, TOut], opts ListOptions) (map[string]TOut, diag.Diagnostics)
- func EnsureSuccessOrDiagFromScheme(ctx context.Context, op string, rs *models.ResponseScheme, err error, ...) bool
- func EnsureSuccessOrDiagFromSchemeWithOptions(ctx context.Context, op string, rs *models.ResponseScheme, err error, ...) bool
- func ErrorFromScheme(ctx context.Context, op string, rs *models.ResponseScheme, err error) (string, string)
- func ErrorFromSchemeWithOptions(ctx context.Context, op string, rs *models.ResponseScheme, err error, ...) (string, string)
- func HTTPStatusFromScheme(rs *models.ResponseScheme) int
- func HTTPStatusStrictFromScheme(rs *models.ResponseScheme) (int, error)
- func IsContextError(err error) bool
- func IsSuccess(code int) bool
- func New(version string) func() provider.Provider
- func NewFieldResource() resource.Resource
- func NewProjectCategoriesDataSource() datasource.DataSource
- func NewProjectCategoryResource() resource.Resource
- func NewProjectDataSource() datasource.DataSource
- func NewProjectResource() resource.Resource
- func NewProjectsDataSource() datasource.DataSource
- func NewWorkTypeResource() resource.Resource
- func NewWorkTypesDataSource() datasource.DataSource
- func ParseRetryAfter(h http.Header) time.Duration
- func RedactHeaders(h http.Header) http.Header
- func RedactJoin(parts []string, sep string) string
- func RedactSecrets(s string) string
- func ShouldRetry(status int, err error) bool
- type APIConstraint
- type APIListConstraint
- type AttrTypesFunc
- type CRUDHooks
- type CRUDRunner
- func (r CRUDRunner[TState, TPayload, TAPI]) DoCreate(ctx context.Context, ...) diag.Diagnostics
- func (r CRUDRunner[TState, TPayload, TAPI]) DoDelete(ctx context.Context, ...) diag.Diagnostics
- func (r CRUDRunner[TState, TPayload, TAPI]) DoImport(ctx context.Context, id string, ...) diag.Diagnostics
- func (r CRUDRunner[TState, TPayload, TAPI]) DoRead(ctx context.Context, ...) diag.Diagnostics
- func (r CRUDRunner[TState, TPayload, TAPI]) DoUpdate(ctx context.Context, ...) diag.Diagnostics
- type CreateFunc
- type DeleteFunc
- type EnsureSuccessOrDiagOptions
- type ExtractIDFunc
- type FilterFunc
- type JiraProvider
- func (j *JiraProvider) Configure(ctx context.Context, req provider.ConfigureRequest, ...)
- func (j *JiraProvider) DataSources(_ context.Context) []func() datasource.DataSource
- func (j *JiraProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse)
- func (j *JiraProvider) Resources(_ context.Context) []func() resource.Resource
- func (j *JiraProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse)
- func (j *JiraProvider) ValidateConfig(ctx context.Context, req provider.ValidateConfigRequest, ...)
- type JiraProviderModel
- type KeyOfFunc
- type ListFunc
- type ListHooks
- type ListOptions
- type ListPageFunc
- type MapToOutFunc
- type MapToStateFunc
- type OperationTimeoutsModel
- type OutModelConstraint
- type PayloadBuilderFunc
- type PayloadConstraint
- type PostAPIHook
- type ReadFunc
- type ServiceClient
- type StateConstraint
- type UpdateFunc
Constants ¶
const HierarchyDescription = `` /* 634-byte string literal not displayed */
HierarchyDescription provides details about the levels of work types in the Jira issue type hierarchy. It includes: - -1: Sub-task (child issue type) - 0: Standard issue type (default level) - 1: Epic (Epic level) Higher levels (2+) are available in Jira Software Premium with Advanced Roadmaps.
Variables ¶
This section is empty.
Functions ¶
func BackoffDuration ¶ added in v0.5.0
BackoffDuration computes capped exponential backoff for the given attempt (1-based), starting from base and capped at max. A jitter fraction in [0,1] expands/shrinks the delay uniformly within [1-jitter, 1+jitter]. Values outside bounds are clamped.
func DoListToMap ¶ added in v0.8.0
func DoListToMap[TAPI APIListConstraint, TOut OutModelConstraint]( ctx context.Context, h ListHooks[TAPI, TOut], ) (map[string]TOut, diag.Diagnostics)
DoListToMap builds a map[string]TOut using hooks (legacy convenience). Use DoListToMapWithLimit for large datasets and guardrails.
Steps 1) List: fetch all items (may include server-side pagination). 2) Filter (optional): keep only items where Filter returns true. 3) KeyOf: compute the stable key for each item. 4) MapToOut: convert each API item into the Terraform object model. 5) Aggregate: return a map keyed by the stable string key.
Notes - Diagnostics from List and MapToOut are accumulated and returned. - If diagnostics contain errors at any point, the partial result is not returned.
func DoListToMapWithLimit ¶ added in v0.8.0
func DoListToMapWithLimit[TAPI APIListConstraint, TOut OutModelConstraint]( ctx context.Context, h ListHooks[TAPI, TOut], opts ListOptions, ) (map[string]TOut, diag.Diagnostics)
DoListToMapWithLimit builds a map[string]TOut using hooks with guardrails for large datasets.
Behavior - If hooks.ListPage is provided, pages are fetched incrementally with a default page size (200). - Filter (when provided) is applied before mapping to avoid unnecessary allocations. - The result map is pre-allocated using a conservative capacity derived from PreallocCap/MaxItems/input size. - Last write wins for duplicate keys (documented behavior). - If MaxItems > 0, mapping stops after that many kept items; a warning is added indicating capping. - If WarnThreshold > 0 and kept >= threshold, a warning is added (once). - If RespectContext is true, ctx.Done() is checked every 1000 processed items and early termination returns a warning.
Diagnostics - Diagnostics from List/ListPage and MapToOut are appended and on error return immediately (no partial results). - Soft warnings (WarnThreshold, MaxItems cap, context cancellation) are added and a partial, coherent result is returned.
func EnsureSuccessOrDiagFromScheme ¶ added in v0.5.0
func EnsureSuccessOrDiagFromScheme(ctx context.Context, op string, rs *models.ResponseScheme, err error, diags *diag.Diagnostics) bool
EnsureSuccessOrDiagFromScheme validates success and adds diagnostics on failure.
func EnsureSuccessOrDiagFromSchemeWithOptions ¶ added in v0.5.0
func EnsureSuccessOrDiagFromSchemeWithOptions(ctx context.Context, op string, rs *models.ResponseScheme, err error, diags *diag.Diagnostics, opts *EnsureSuccessOrDiagOptions) bool
EnsureSuccessOrDiagFromSchemeWithOptions validates success according to options.
func ErrorFromScheme ¶ added in v0.5.0
func ErrorFromScheme(ctx context.Context, op string, rs *models.ResponseScheme, err error) (string, string)
ErrorFromScheme returns redacted summary and detail without body/header snippets.
func ErrorFromSchemeWithOptions ¶ added in v0.5.0
func ErrorFromSchemeWithOptions(ctx context.Context, op string, rs *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) (string, string)
ErrorFromSchemeWithOptions includes body/headers snippets when requested.
func HTTPStatusFromScheme ¶ added in v0.5.0
func HTTPStatusFromScheme(rs *models.ResponseScheme) int
HTTPStatusFromScheme returns the HTTP status from the response scheme or 0 if unavailable.
func HTTPStatusStrictFromScheme ¶ added in v0.5.0
func HTTPStatusStrictFromScheme(rs *models.ResponseScheme) (int, error)
HTTPStatusStrictFromScheme validates and returns the status or an error when missing/invalid.
func IsContextError ¶ added in v0.5.0
IsContextError reports if err indicates context cancellation or deadline exceeded.
func IsSuccess ¶ added in v0.5.0
IsSuccess reports whether the given HTTP status code is in 2xx range.
func NewFieldResource ¶ added in v0.8.0
NewFieldResource creates and returns a new instance of the fieldResource, representing a Jira custom field resource.
func NewProjectCategoriesDataSource ¶ added in v0.7.0
func NewProjectCategoriesDataSource() datasource.DataSource
NewProjectCategoriesDataSource returns the Terraform data source implementation for jira_project_categories.
func NewProjectCategoryResource ¶ added in v0.7.0
NewProjectCategoryResource returns the Terraform resource implementation for jira_project_category.
func NewProjectDataSource ¶ added in v0.5.0
func NewProjectDataSource() datasource.DataSource
NewProjectDataSource returns the Terraform data source implementation for jira_project (lookup by key/ID).
func NewProjectResource ¶ added in v0.5.0
NewProjectResource returns the Terraform resource implementation for jira_project.
func NewProjectsDataSource ¶ added in v0.6.0
func NewProjectsDataSource() datasource.DataSource
NewProjectsDataSource returns the Terraform data source implementation for jira_projects (list/filter; pagination).
func NewWorkTypeResource ¶ added in v0.1.0
NewWorkTypeResource returns the Terraform resource implementation for jira_work_type.
func NewWorkTypesDataSource ¶ added in v0.2.0
func NewWorkTypesDataSource() datasource.DataSource
NewWorkTypesDataSource returns the Terraform data source implementation for jira_work_types.
func ParseRetryAfter ¶ added in v0.5.0
ParseRetryAfter returns a server-specified delay indicated by the Retry-After header. It supports both seconds and HTTP-date formats. Returns 0 when absent/invalid or when the computed delay would be negative.
func RedactHeaders ¶ added in v0.5.0
RedactHeaders returns a safe copy of the provided headers with sensitive keys redacted. It operates on a copy; the input is not mutated.
func RedactJoin ¶ added in v0.5.0
RedactJoin is a small helper to join strings with a separator after redaction.
func RedactSecrets ¶ added in v0.5.0
RedactSecrets scans the provided string and masks common sensitive values such as Authorization tokens, basic credentials, emails, and URLs with embedded credentials. It is idempotent and safe to call multiple times.
func ShouldRetry ¶ added in v0.5.0
ShouldRetry classifies whether a request should be retried for given status/err. Policy: - Never retry context cancellation/deadline errors (caller controls lifetime). - Retry on HTTP 429 and 5xx (server signaled throttling or transient server failure). - Transport-level retries are restricted to likely-transient conditions only:
- net.Error with Timeout()==true (includes DNS/socket timeouts)
- io.ErrUnexpectedEOF (truncated responses)
- Connection reset/aborted/broken pipe (syscall ECONNRESET/ECONNABORTED/EPIPE)
- Do NOT blanket-retry all status==0 errors; e.g., DNS resolution failures like "no such host" are treated as non-retryable unless they reported a timeout.
Types ¶
type APIConstraint ¶ added in v0.8.0
type APIConstraint interface {
*models.ProjectScheme |
*models.IssueTypeScheme |
*models.ProjectCategoryScheme |
*models.IssueFieldScheme
}
APIConstraint enumerates the supported go‑atlassian API models returned by service calls.
type APIListConstraint ¶ added in v0.8.0
type APIListConstraint interface {
*models.ProjectScheme | *models.ProjectCategoryScheme | *models.IssueTypeScheme
}
Generic type constraints restricted to available provider types.
What these do - APIListConstraint enumerates the supported go-atlassian API models that appear in lists. - OutModelConstraint enumerates the supported Terraform object models (map values).
How to extend - Add new API and output model types to the unions below when introducing a new data source.
type AttrTypesFunc ¶ added in v0.8.0
type CRUDHooks ¶ added in v0.8.0
type CRUDHooks[TState StateConstraint, TPayload PayloadConstraint, TAPI APIConstraint] struct { // Required BuildPayload PayloadBuilderFunc[TState, TPayload] // API calls APICreate CreateFunc[TPayload, TAPI] APIRead ReadFunc[TAPI] APIUpdate UpdateFunc[TPayload, TAPI] APIDelete DeleteFunc // State helpers ExtractID ExtractIDFunc[TState] MapToState MapToStateFunc[TState, TAPI] // Optional hook for Create flows that need a follow-up read PostCreate PostAPIHook[TState, TAPI] PostRead PostAPIHook[TState, TAPI] PostUpdate PostAPIHook[TState, TAPI] // Per-operation status options AcceptableCreateStatuses []int AcceptableUpdateStatuses []int AcceptableDeleteStatuses []int TreatDelete404AsSuccess bool }
CRUDHooks defines per‑resource behavior consumed by the generic runner.
Provide only the resource‑specific logic here; the runner coordinates the flow.
Required - BuildPayload: Construct the API payload from planned state (Create/Update). - APICreate/APIRead/APIUpdate/APIDelete: Call the concrete go‑atlassian client methods. - ExtractID: Return the stable identifier from state (used for Read/Update/Delete). - MapToState: Map the API model to Terraform state (also used by Import).
Optional - PostCreateRead: If Create returns a partial object, fetch the full model (Create → Get). - Acceptable*Statuses: Override HTTP statuses that should be treated as success per operation. - TreatDelete404AsSuccess: Make Delete idempotent by treating 404 as success.
Typical wiring - Define a hooks() method on each resource that returns CRUDHooks with all fields set. - Use ensureWith(&resp.Diagnostics) (see shared_helpers.go) to bind diagnostics in Do* calls. - Use shared mappers (map*SchemeToModel) for MapToState to keep behavior consistent.
type CRUDRunner ¶ added in v0.8.0
type CRUDRunner[TState StateConstraint, TPayload PayloadConstraint, TAPI APIConstraint] struct { // contains filtered or unexported fields }
CRUDRunner coordinates the CRUD lifecycle using the per‑resource CRUDHooks. It is generic over TState (Terraform model), TPayload (API payload), and TAPI (API model).
func NewCRUDRunner ¶ added in v0.8.0
func NewCRUDRunner[TState StateConstraint, TPayload PayloadConstraint, TAPI APIConstraint](hooks CRUDHooks[TState, TPayload, TAPI]) CRUDRunner[TState, TPayload, TAPI]
NewCRUDRunner constructs a CRUDRunner bound to the provided hooks. Typical usage: runner := NewCRUDRunner(r.hooks())
func (CRUDRunner[TState, TPayload, TAPI]) DoCreate ¶ added in v0.8.0
func (r CRUDRunner[TState, TPayload, TAPI]) DoCreate( ctx context.Context, getPlan func(ctx context.Context, dst *TState) diag.Diagnostics, setState func(ctx context.Context, src *TState) diag.Diagnostics, ensure func(ctx context.Context, action string, resp *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) bool, ) diag.Diagnostics
DoCreate orchestrates the Create lifecycle:
Steps 1) getPlan: Read the Terraform planned state into TState. 2) BuildPayload: Build the API payload (TPayload) from TState. 3) APICreate: Call the service to create the resource. 4) PostCreate (optional): Fetch the full model if Create returns a partial object. 5) MapToState: Map the API model (TAPI) back into TState. 6) setState: Persist the final state back to Terraform.
ensure - Pass ensureWith(&resp.Diagnostics) to bind resource diagnostics to the Ensure helper. - Configure AcceptableCreateStatuses on hooks if non‑default statuses should be treated as success.
func (CRUDRunner[TState, TPayload, TAPI]) DoDelete ¶ added in v0.8.0
func (r CRUDRunner[TState, TPayload, TAPI]) DoDelete( ctx context.Context, getState func(ctx context.Context, dst *TState) diag.Diagnostics, ensure func(ctx context.Context, action string, resp *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) bool, ) diag.Diagnostics
DoDelete removes the resource remotely.
Steps
- getState to obtain the ID
- APIDelete call
- ensure handles success/HTTP codes; if TreatDelete404AsSuccess is set on hooks, a 404 is treated as success for idempotent destroys.
func (CRUDRunner[TState, TPayload, TAPI]) DoImport ¶ added in v0.8.0
func (r CRUDRunner[TState, TPayload, TAPI]) DoImport( ctx context.Context, id string, setState func(ctx context.Context, src *TState) diag.Diagnostics, ensure func(ctx context.Context, action string, resp *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) bool, ) diag.Diagnostics
DoImport mirrors Read using an arbitrary import identifier.
Steps - APIRead fetches the remote model using the import ID. - MapToState converts the API model into Terraform state. - setState persists the state.
Guidance - Pass ensureWith(&response.Diagnostics) for ensure. - Reuse your resource’s MapToState hook implementation for consistency.
func (CRUDRunner[TState, TPayload, TAPI]) DoRead ¶ added in v0.8.0
func (r CRUDRunner[TState, TPayload, TAPI]) DoRead( ctx context.Context, getState func(ctx context.Context, dst *TState) diag.Diagnostics, setState func(ctx context.Context, src *TState) diag.Diagnostics, remove func(ctx context.Context), ensure func(ctx context.Context, action string, resp *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) bool, httpStatus func(*models.ResponseScheme) int, ) diag.Diagnostics
DoRead refreshes state from the remote API.
Behavior - Reads current state (for ID) via getState. - Invokes APIRead; if httpStatus(response) == 404, remove() is called to drop the resource from state. - Otherwise maps API → state (MapToState) and writes it using setState. - Any HTTP/transport errors are reported via ensure.
func (CRUDRunner[TState, TPayload, TAPI]) DoUpdate ¶ added in v0.8.0
func (r CRUDRunner[TState, TPayload, TAPI]) DoUpdate( ctx context.Context, getPlan func(ctx context.Context, dst *TState) diag.Diagnostics, setState func(ctx context.Context, src *TState) diag.Diagnostics, ensure func(ctx context.Context, action string, resp *models.ResponseScheme, err error, opts *EnsureSuccessOrDiagOptions) bool, ) diag.Diagnostics
DoUpdate applies changes to the remote API and updates state.
Steps - getPlan → BuildPayload → APIUpdate - MapToState → setState
Notes - AcceptableUpdateStatuses default to 200/204; override on hooks if needed. - Use ensureWith(&resp.Diagnostics) for consistent error/HTTP handling.
type CreateFunc ¶ added in v0.8.0
type CreateFunc[TPayload PayloadConstraint, TAPI APIConstraint] func(ctx context.Context, p TPayload) (api TAPI, apiResp *models.ResponseScheme, err error)
CreateFunc invokes the concrete API Create call and returns the created API model (TAPI). The models.ResponseScheme is threaded for Ensure* handling (status/body diagnostics).
type DeleteFunc ¶ added in v0.8.0
DeleteFunc invokes the concrete API Delete call; Ensure* handles status evaluation and 404 semantics.
type EnsureSuccessOrDiagOptions ¶ added in v0.5.0
type EnsureSuccessOrDiagOptions struct {
AcceptableStatuses []int
TreatRead404AsNotFound bool
TreatDelete404AsSuccess bool
IncludeBodySnippet bool
MaxBodyBytes int
}
EnsureSuccessOrDiagOptions configures success and diagnostics behavior per operation. AcceptableStatuses extends success criteria beyond 2xx. TreatRead404AsNotFound means callers will handle state removal on 404 reads. TreatDelete404AsSuccess makes delete idempotent. IncludeBodySnippet appends a truncated response body and select headers.
type ExtractIDFunc ¶ added in v0.8.0
type ExtractIDFunc[TState StateConstraint] func(st *TState) string
ExtractIDFunc returns the stable identifier from the current state (typically id string).
type FilterFunc ¶ added in v0.8.0
type FilterFunc[TAPI APIListConstraint] func(ctx context.Context, item TAPI) bool
type JiraProvider ¶
type JiraProvider struct {
// contains filtered or unexported fields
}
JiraProvider defines the provider implementation.
func (*JiraProvider) Configure ¶
func (j *JiraProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse)
Configure establishes the Jira API client and validates authentication. It attaches the configured client to resources and data sources for use in operations.
func (*JiraProvider) DataSources ¶
func (j *JiraProvider) DataSources(_ context.Context) []func() datasource.DataSource
DataSources returns the set of Terraform data sources supported by the provider.
func (*JiraProvider) Metadata ¶
func (j *JiraProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse)
Metadata sets the provider type name and version for Terraform.
func (*JiraProvider) Resources ¶
func (j *JiraProvider) Resources(_ context.Context) []func() resource.Resource
Resources returns the set of Terraform resources supported by the provider.
func (*JiraProvider) Schema ¶
func (j *JiraProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse)
Schema returns the provider schema describing configuration attributes.
func (*JiraProvider) ValidateConfig ¶
func (j *JiraProvider) ValidateConfig(ctx context.Context, req provider.ValidateConfigRequest, resp *provider.ValidateConfigResponse)
type JiraProviderModel ¶
type JiraProviderModel struct {
// Base Configuration
Endpoint types.String `tfsdk:"endpoint"`
AuthMethod types.String `tfsdk:"auth_method"`
// Logging
Debug types.Bool `tfsdk:"debug"`
OperationTimeouts *OperationTimeoutsModel `tfsdk:"operation_timeouts"`
// HTTP Settings
HTTPTimeoutSeconds types.Int64 `tfsdk:"http_timeout_seconds"`
RetryOn4295xx types.Bool `tfsdk:"retry_on_429_5xx"`
RetryMaxAttempts types.Int64 `tfsdk:"retry_max_attempts"`
RetryInitialBackoffMs types.Int64 `tfsdk:"retry_initial_backoff_ms"`
RetryMaxBackoffMs types.Int64 `tfsdk:"retry_max_backoff_ms"`
// API Token Authentication
APIToken types.String `tfsdk:"api_token"`
APIAuthEmail types.String `tfsdk:"api_auth_email"`
// Basic Authentication
Username types.String `tfsdk:"username"`
Password types.String `tfsdk:"password"`
// Privacy & Redaction
EmailRedactionMode types.String `tfsdk:"email_redaction_mode"`
}
JiraProviderModel describes the provider data model.
type KeyOfFunc ¶ added in v0.8.0
type KeyOfFunc[TAPI APIListConstraint] func(item TAPI) string
type ListFunc ¶ added in v0.8.0
type ListFunc[TAPI APIListConstraint] func(ctx context.Context) ([]TAPI, diag.Diagnostics)
Function type aliases for list-to-map flows.
Why aliases? - Keep the ListHooks signatures concise and intention-revealing (list, filter, key-of, mapper). - Centralize call signatures so future changes won’t ripple across all data sources. - Combine with constraints below to catch type mismatches at compile time.
Usage: - Implement List to fetch all items (handle pagination internally). - Optionally implement Filter to apply client-side filtering. - KeyOf must return a stable string key (e.g., ID as string). - MapToOut converts an API item to the Terraform object model (struct of types.* fields).
type ListHooks ¶ added in v0.8.0
type ListHooks[TAPI APIListConstraint, TOut OutModelConstraint] struct { // List should fetch all items (handle pagination internally if needed). List ListFunc[TAPI] // Optional paginated fetcher. If provided, DoListToMapWithLimit will iterate via pages // using a default page size and aggregate incrementally. This avoids holding all items in memory. ListPage ListPageFunc[TAPI] // Optional filter applied client-side (return true to keep). Filter FilterFunc[TAPI] // KeyOf must return the stable string key (e.g., ID string). KeyOf KeyOfFunc[TAPI] // MapToOut converts API item to Terraform object model. MapToOut MapToOutFunc[TAPI, TOut] // AttrTypes returns the ObjectType attribute types for TOut. AttrTypes AttrTypesFunc }
ListHooks defines list-to-map helpers for data sources. TAPI: API model per item (constrained by APIListConstraint). TOut: Terraform object model per item (constrained by OutModelConstraint).
type ListOptions ¶ added in v0.8.0
ListOptions configures DoListToMapWithLimit behavior.
Fields - MaxItems: hard cap on kept items (post-filter). 0 = unlimited (default). - WarnThreshold: soft threshold that adds a warning once kept items reach/exceed it. 0 = disabled. - PreallocCap: explicit capacity for result map. 0 = auto (based on input length or MaxItems when known). - RespectContext: if true, checks ctx.Done() periodically and returns early with a warning if canceled.
type ListPageFunc ¶ added in v0.8.0
type ListPageFunc[TAPI APIListConstraint] func(ctx context.Context, startAt, max int) (items []TAPI, isLast bool, d diag.Diagnostics)
ListPageFunc optionally streams pages of items. Return items, whether this is the last page, and diagnostics. - startAt: zero-based offset of the first item to return for the page - max: desired maximum page size. Implementations may return fewer items. When provided, DoListToMapWithLimit will iterate pages until isLast=true, context cancellation, or reaching MaxItems.
type MapToOutFunc ¶ added in v0.8.0
type MapToOutFunc[TAPI APIListConstraint, TOut OutModelConstraint] func(ctx context.Context, item TAPI) (TOut, diag.Diagnostics)
type MapToStateFunc ¶ added in v0.8.0
type MapToStateFunc[TState StateConstraint, TAPI APIConstraint] func(ctx context.Context, api TAPI, st *TState) diag.Diagnostics
MapToStateFunc maps the API model (TAPI) into the Terraform state model (TState). Return diagnostics when mapping encounters unexpected values or schema mismatches.
type OperationTimeoutsModel ¶ added in v0.5.0
type OutModelConstraint ¶ added in v0.8.0
type OutModelConstraint interface {
projectResourceModel | projectCategoryResourceModel | workTypeResourceModel
}
type PayloadBuilderFunc ¶ added in v0.8.0
type PayloadBuilderFunc[TState StateConstraint, TPayload PayloadConstraint] func(ctx context.Context, st *TState) (TPayload, diag.Diagnostics)
PayloadBuilderFunc builds the API payload (TPayload) from the planned Terraform state (TState). Return diagnostics for validation or value derivation errors encountered during build.
type PayloadConstraint ¶ added in v0.8.0
type PayloadConstraint interface {
*models.ProjectPayloadScheme |
*models.IssueTypePayloadScheme |
*models.ProjectCategoryPayloadScheme |
*models.CustomFieldScheme
}
PayloadConstraint enumerates the supported go‑atlassian payload types used in Create/Update.
type PostAPIHook ¶ added in v0.8.0
type PostAPIHook[TState StateConstraint, TAPI APIConstraint] func(ctx context.Context, api TAPI, st *TState) (apiOut TAPI, apiResp *models.ResponseScheme, err error)
PostAPIHook is an optional extra step after Create to fetch the full TAPI model. Use this when Create returns a partial object and a subsequent Get is needed.
type ReadFunc ¶ added in v0.8.0
type ReadFunc[TAPI APIConstraint] func(ctx context.Context, id string) (api TAPI, apiResp *models.ResponseScheme, err error)
ReadFunc invokes the concrete API Read/Get call using a stable identifier and returns TAPI.
type ServiceClient ¶ added in v0.8.0
type ServiceClient struct {
// contains filtered or unexported fields
}
type StateConstraint ¶ added in v0.8.0
type StateConstraint interface {
projectResourceModel |
workTypeResourceModel |
projectCategoryResourceModel |
fieldResourceModel
}
StateConstraint enumerates the Terraform state models supported by the CRUD runner.
type UpdateFunc ¶ added in v0.8.0
type UpdateFunc[TPayload PayloadConstraint, TAPI APIConstraint] func(ctx context.Context, id string, p TPayload) (api TAPI, apiResp *models.ResponseScheme, err error)
UpdateFunc invokes the concrete API Update call with payload and returns the refreshed TAPI. Some services may issue Update → Get to return a full object; both patterns are supported.
Source Files
¶
- crud_runner.go
- doc.go
- field_resource.go
- list_runner.go
- project_categories_data_source.go
- project_category_resource.go
- project_category_types.go
- project_data_source.go
- project_resource.go
- project_types.go
- projects_data_source.go
- provider.go
- provider_config.go
- provider_config_types.go
- provider_constants.go
- provider_env.go
- provider_helpers.go
- provider_http_client.go
- provider_redaction.go
- provider_types.go
- shared_helpers.go
- shared_types.go
- work_type_resource.go
- work_type_types.go
- work_types_data_source.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package testhelpers provides shared testing utilities used across unit and acceptance tests.
|
Package testhelpers provides shared testing utilities used across unit and acceptance tests. |