chainguard-dev / terraform-provider-oci

Terraform provider to perform OCI image operations
https://registry.terraform.io/providers/chainguard-dev/oci
Mozilla Public License 2.0
13 stars 11 forks source link

new functions: `parse` and `get` #131

Closed imjasonh closed 6 months ago

imjasonh commented 6 months ago

Provider-defined functions are new in Terraform 1.8+ (and opentofu 1.7+)

This is expected to be a replacement for the oci_string and oci_ref datasources, which perform the same logic, but have their results persisted in state, which adds to slowness.

Usage

output "parsed" {
  value = provider::oci::parse("cgr.dev/chainguard/static@sha256:abc...").digest  # sha256:abcdef...
}

locals {
  parsed = provider::oci::parse("cgr.dev/chainguard/static@sha256:abc...").digest  # sha256:abcdef...
  gotten = provider::oci::get("cgr.dev/chainguard/static").digest  # sha256:...
}

Docs

https://developer.hashicorp.com/terraform/plugin/framework/functions/concepts https://developer.hashicorp.com/terraform/plugin/framework/functions/returns/object https://developer.hashicorp.com/terraform/plugin/framework/functions/testing