Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new functions: parse and get #131

Merged
merged 7 commits into from
May 7, 2024
Merged

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented May 5, 2024

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

Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh imjasonh changed the title new function: parse new functions: parse and get May 5, 2024
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh imjasonh marked this pull request as ready for review May 6, 2024 02:31
Signed-off-by: Jason Hall <jason@chainguard.dev>
Signed-off-by: Jason Hall <jason@chainguard.dev>
@imjasonh imjasonh merged commit 81b67cb into chainguard-dev:main May 7, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants