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 ¶
- func BackoffDuration(attempt int, base, max time.Duration, jitter float64) time.Duration
- func CreateResource[C, R any](ctx context.Context, request resource.CreateRequest, ...)
- func DeleteResource(ctx context.Context, request resource.DeleteRequest, ...)
- 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 ImportResource[R any](ctx context.Context, request resource.ImportStateRequest, ...)
- func IsContextError(err error) bool
- func IsSuccess(code int) bool
- func New(version string) func() provider.Provider
- 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 NewWorkflowStatusResource() resource.Resource
- func ParseRetryAfter(h http.Header) time.Duration
- func ReadResource[R any](ctx context.Context, request resource.ReadRequest, ...)
- 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
- func UpdateResource[P, R any](ctx context.Context, request resource.UpdateRequest, ...)
- type APIPayloadGetter
- type EnsureSuccessOrDiagOptions
- type IDer
- 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 OperationTimeoutsModel
- type ResourceTransformer
- type TerraformTransformer
Constants ¶
This section is empty.
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 CreateResource ¶ added in v0.1.0
func CreateResource[C, R any](ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse, resourceModel ResourceTransformer[C, R], createFunc func(ctx context.Context, newResource C) (R, *models.ResponseScheme, error))
CreateResource is a generic helper that reads the plan, calls the API create function, transforms the API response into Terraform state, and sets it on the response.
func DeleteResource ¶ added in v0.1.0
func DeleteResource(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse, resourceModel IDer, deleteFunc func(ctx context.Context, id string) (*models.ResponseScheme, error))
DeleteResource is a generic helper that loads state, calls the API delete function, treats 404 as a successful no-op for idempotency, and returns diagnostics on failure.
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 ImportResource ¶ added in v0.1.0
func ImportResource[R any](ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse, resourceModel TerraformTransformer[R], getFunc func(ctx context.Context, id string) (R, *models.ResponseScheme, error))
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 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 NewWorkflowStatusResource ¶ added in v0.3.0
NewWorkflowStatusResource returns the Terraform resource implementation for jira_workflow_status.
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 ReadResource ¶ added in v0.1.0
func ReadResource[R any](ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse, resourceModel TerraformTransformer[R], readFunc func(ctx context.Context, id string) (R, *models.ResponseScheme, error))
ReadResource is a generic helper that loads state, calls the API read function, handles 404 as not found by removing state, and updates state on success.
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.
func UpdateResource ¶ added in v0.1.0
func UpdateResource[P, R any](ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse, resourceModel ResourceTransformer[P, R], updateFunc func(ctx context.Context, updatedResourceId string, updatedResource P) (R, *models.ResponseScheme, error))
UpdateResource is a generic helper that reads the plan, calls the API update function, transforms the API response into Terraform state, and writes the updated state.
Types ¶
type APIPayloadGetter ¶ added in v0.5.0
type APIPayloadGetter[P any] interface { GetAPIPayload(ctx context.Context) (createPayload P, diags diag.Diagnostics) }
APIPayloadGetter defines a model capable of producing an API payload for create/update operations.
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 IDer ¶ added in v0.1.0
type IDer interface {
GetID() string
}
IDer exposes a stable identifier accessor used by CRUD helpers and import.
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 OperationTimeoutsModel ¶ added in v0.5.0
type ResourceTransformer ¶ added in v0.1.0
type ResourceTransformer[P, R any] interface { APIPayloadGetter[P] TerraformTransformer[R] }
ResourceTransformer combines API payload building and state transformation for a resource model.
type TerraformTransformer ¶ added in v0.1.0
type TerraformTransformer[R any] interface { IDer TransformToState(ctx context.Context, apiModel R) diag.Diagnostics }
TerraformTransformer defines a model that can map an API model into Terraform state.
Source Files
¶
- constants.go
- doc.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
- workflow_status_resource.go
- workflow_status_types.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. |