-
Notifications
You must be signed in to change notification settings - Fork 136
Make kong2tf plugin aware #1979
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package kong2tf | ||
|
|
||
| var availablePlugins = []string{ | ||
| "ace", | ||
| "acl", | ||
| "acme", | ||
| "ai-a2a-proxy", | ||
| "ai-aws-guardrails", | ||
| "ai-azure-content-safety", | ||
| "ai-custom-guardrail", | ||
| "ai-gcp-model-armor", | ||
| "ai-lakera-guard", | ||
| "ai-llm-as-judge", | ||
| "ai-mcp-oauth2", | ||
| "ai-mcp-proxy", | ||
| "ai-prompt-compressor", | ||
| "ai-prompt-decorator", | ||
| "ai-prompt-guard", | ||
| "ai-prompt-template", | ||
| "ai-proxy", | ||
| "ai-proxy-advanced", | ||
| "ai-rag-injector", | ||
| "ai-rate-limiting-advanced", | ||
| "ai-request-transformer", | ||
| "ai-response-transformer", | ||
| "ai-sanitizer", | ||
| "ai-semantic-cache", | ||
| "ai-semantic-prompt-guard", | ||
| "ai-semantic-response-guard", | ||
| "app-dynamics", | ||
| "aws-lambda", | ||
| "azure-functions", | ||
| "basic-auth", | ||
| "bot-detection", | ||
| "canary", | ||
| "confluent", | ||
| "confluent-consume", | ||
| "correlation-id", | ||
| "cors", | ||
| "datadog", | ||
| "datakit", | ||
| "degraphql", | ||
| "exit-transformer", | ||
| "file-log", | ||
| "forward-proxy", | ||
| "graphql-proxy-cache-advanced", | ||
| "graphql-rate-limiting-advanced", | ||
| "grpc-gateway", | ||
| "grpc-web", | ||
| "header-cert-auth", | ||
| "hmac-auth", | ||
| "http-log", | ||
| "injection-protection", | ||
| "ip-restriction", | ||
| "jq", | ||
| "json-threat-protection", | ||
| "jwe-decrypt", | ||
| "jwt", | ||
| "jwt-signer", | ||
| "kafka-consume", | ||
| "kafka-log", | ||
| "kafka-upstream", | ||
| "key-auth", | ||
| "key-auth-enc", | ||
| "konnect-application-auth", | ||
| "ldap-auth", | ||
| "ldap-auth-advanced", | ||
| "loggly", | ||
| "metering-and-billing", | ||
| "mocking", | ||
| "mtls-auth", | ||
| "oas-validation", | ||
| "oauth2", | ||
| "oauth2-introspection", | ||
| "opa", | ||
| "openid-connect", | ||
| "opentelemetry", | ||
| "post-function", | ||
| "pre-function", | ||
| "prometheus", | ||
| "proxy-cache", | ||
| "proxy-cache-advanced", | ||
| "rate-limiting", | ||
| "rate-limiting-advanced", | ||
| "redirect", | ||
| "request-callout", | ||
| "request-size-limiting", | ||
| "request-termination", | ||
| "request-transformer", | ||
| "request-transformer-advanced", | ||
| "request-validator", | ||
| "response-ratelimiting", | ||
| "response-transformer", | ||
| "response-transformer-advanced", | ||
| "route-by-header", | ||
| "route-transformer-advanced", | ||
| "saml", | ||
| "service-protection", | ||
| "session", | ||
| "solace-consume", | ||
| "solace-log", | ||
| "solace-upstream", | ||
| "standard-webhooks", | ||
| "statsd", | ||
| "statsd-advanced", | ||
| "syslog", | ||
| "tcp-log", | ||
| "tls-handshake-modifier", | ||
| "tls-metadata-headers", | ||
| "udp-log", | ||
| "upstream-oauth", | ||
| "upstream-timeout", | ||
| "vault-auth", | ||
| "websocket-size-limit", | ||
| "websocket-validator", | ||
| "xml-threat-protection", | ||
| "zipkin", | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,9 +94,34 @@ func generateResourceWithCustomizations( | |
| delete(entity, k) | ||
| } | ||
|
|
||
| isCustomPlugin := false | ||
| var s string | ||
| if entityType == "gateway_plugin" { | ||
| entityType = fmt.Sprintf("%s_%s", entityType, name) | ||
| delete(entity, "name") | ||
| // If `name` is not in availablePlugins, then it's a custom plugin and | ||
| // we should use the plugin name as the resource name | ||
| if !contains(availablePlugins, entity["name"].(string)) { | ||
| isCustomPlugin = true | ||
| if customizations == nil { | ||
| customizations = map[string]string{} | ||
| } | ||
| customizations["config"] = "jsonencode" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we do jsonencode - underlying value of I don't think we need to block this PR though. |
||
|
|
||
| s = fmt.Sprintf(` | ||
| resource "konnect_gateway_custom_plugin" "%s" { | ||
| %s | ||
|
|
||
| %s control_plane_id = var.control_plane_id%s | ||
| } | ||
| `, | ||
| slugify(name), | ||
| strings.TrimRight(output(entityType, entity, 1, true, "\n", customizations, oneOfFields), "\n"), | ||
| generateParents(parents), | ||
| generateLifecycle(lifecycle)) | ||
|
|
||
| } else { | ||
| entityType = fmt.Sprintf("%s_%s", entityType, name) | ||
| delete(entity, "name") | ||
| } | ||
| } | ||
|
|
||
| // We don't need to prefix SNIs with the Cert name | ||
|
|
@@ -107,17 +132,19 @@ func generateResourceWithCustomizations( | |
| } | ||
| } | ||
|
|
||
| s := fmt.Sprintf(` | ||
| if !isCustomPlugin { | ||
| s = fmt.Sprintf(` | ||
| resource "konnect_%s" "%s" { | ||
| %s | ||
|
|
||
| %s control_plane_id = var.control_plane_id%s | ||
| } | ||
| `, | ||
| entityType, slugify(name), | ||
| strings.TrimRight(output(entityType, entity, 1, true, "\n", customizations, oneOfFields), "\n"), | ||
| generateParents(parents), | ||
| generateLifecycle(lifecycle)) | ||
| entityType, slugify(name), | ||
| strings.TrimRight(output(entityType, entity, 1, true, "\n", customizations, oneOfFields), "\n"), | ||
| generateParents(parents), | ||
| generateLifecycle(lifecycle)) | ||
| } | ||
|
|
||
| // Generate imports | ||
| if imports.controlPlaneID != nil && entityID != "" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a new plugin is introduced in a new kong gateway version - wouldn't the previously released versions of deck treat it as custom plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. That's the tradeoff we're making (it would still work, just without schema checks in TF)