pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

terraform: Make providers usable by OpenTofu



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Sun Nov 17 11:44:57 2024 +0100
Changeset:	83736492b403093e45f81344d84e9624c0e5f3b0

Modified Files:
	terraform/provider.mk

Log Message:
terraform: Make providers usable by OpenTofu

Terraform Registry (registry.terraform.io) could not be used by OpenTofu
because that would violate the Terraform Registry Terms of Use.

While in pkgsrc we do not use Terraform Registry but all the
terraform-provider-* are intended to be used as `filesystem_mirror`
OpenTofu could not get them in any ways without patching (but by
patching it we can violate the Terraform Registry Terms of Use).

Create a symbolic link to registry.opentofu.org so that they can be
used by OpenTofu too.

Now terraform-provider-* are usable by both Terraform and OpenTofu.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=83736492b403093e45f81344d84e9624c0e5f3b0

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 terraform/provider.mk | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diffs:
diff --git a/terraform/provider.mk b/terraform/provider.mk
index 7c468f99d5..127d0733c9 100644
--- a/terraform/provider.mk
+++ b/terraform/provider.mk
@@ -9,6 +9,11 @@
 #
 #	Default: registry.terraform.io
 #
+# OPENTOFU_PROVIDER_HOSTNAME (optional)
+#	Hostname of the OpenTofu registry that distributes the provider.
+#
+#	Default: registry.opentofu.org
+#
 # TERRAFORM_PROVIDER_BIN
 #	Binary name of the provider that will be installed under
 #       TERRAFORM_PROVIDER_DIR.
@@ -29,6 +34,11 @@
 #
 #	Default: share/terraform/plugins/${TERRAFORM_PROVIDER_HOSTNAME}/${TERRAFORM_PROVIDER_NAMESPACE}/${TERRAFORM_PROVIDER_TYPE}/${TERRAFORM_PROVIDER_VERSION}/${GO_PLATFORM}
 #
+# OPENTOFU_PROVIDER_DIR (optional)
+#	Directory where the provider will be installed.
+#
+#	Default: share/terraform/plugins/${OPENTOFU_PROVIDER_HOSTNAME}/${TERRAFORM_PROVIDER_NAMESPACE}/${TERRAFORM_PROVIDER_TYPE}/${TERRAFORM_PROVIDER_VERSION}/${GO_PLATFORM}
+#
 # Keywords: terraform
 #
 
@@ -40,17 +50,25 @@ TERRAFORM_PROVIDER_HOSTNAME?=	registry.terraform.io
 TERRAFORM_PROVIDER_VERSION?=	${PKGVERSION_NOREV}
 TERRAFORM_PROVIDER_DIR?=	share/terraform/plugins/${TERRAFORM_PROVIDER_HOSTNAME}/${TERRAFORM_PROVIDER_NAMESPACE}/${TERRAFORM_PROVIDER_TYPE}/${TERRAFORM_PROVIDER_VERSION}/${GO_PLATFORM}
 
+OPENTOFU_PROVIDER_HOSTNAME?=	registry.opentofu.org
+OPENTOFU_PROVIDER_DIR?=		share/terraform/plugins/${OPENTOFU_PROVIDER_HOSTNAME}/${TERRAFORM_PROVIDER_NAMESPACE}/${TERRAFORM_PROVIDER_TYPE}/${TERRAFORM_PROVIDER_VERSION}/${GO_PLATFORM}
+
 PLIST_SUBST+=		TERRAFORM_PROVIDER_HOSTNAME=${TERRAFORM_PROVIDER_HOSTNAME}
 PLIST_SUBST+=		TERRAFORM_PROVIDER_NAMESPACE=${TERRAFORM_PROVIDER_NAMESPACE}
 PLIST_SUBST+=		TERRAFORM_PROVIDER_TYPE=${TERRAFORM_PROVIDER_TYPE}
 PLIST_SUBST+=		TERRAFORM_PROVIDER_VERSION=${TERRAFORM_PROVIDER_VERSION}
 
+PLIST_SUBST+=		OPENTOFU_PROVIDER_HOSTNAME=${OPENTOFU_PROVIDER_HOSTNAME}
+
 PRINT_PLIST_AWK+=	{ sub("${TERRAFORM_PROVIDER_HOSTNAME}", "$${TERRAFORM_PROVIDER_HOSTNAME}") }
 PRINT_PLIST_AWK+=	{ sub("${TERRAFORM_PROVIDER_NAMESPACE}", "$${TERRAFORM_PROVIDER_NAMESPACE}") }
 PRINT_PLIST_AWK+=	{ sub("${TERRAFORM_PROVIDER_TYPE}", "$${TERRAFORM_PROVIDER_TYPE}") }
 PRINT_PLIST_AWK+=	{ sub("${TERRAFORM_PROVIDER_VERSION}", "$${TERRAFORM_PROVIDER_VERSION}") }
 
+PRINT_PLIST_AWK+=	{ sub("${OPENTOFU_PROVIDER_HOSTNAME}", "$${OPENTOFU_PROVIDER_HOSTNAME}") }
+
 INSTALLATION_DIRS+=	${TERRAFORM_PROVIDER_DIR}
+INSTALLATION_DIRS+=	${OPENTOFU_PROVIDER_DIR}
 
 #
 # This should be overwritten via `do-install:' target, however
@@ -62,11 +80,15 @@ pre-install:
 	if [ -f ${WRKDIR}/.gopath/bin/${TERRAFORM_PROVIDER_BIN} ]; then \
 		${INSTALL_PROGRAM} ${WRKDIR}/.gopath/bin/${TERRAFORM_PROVIDER_BIN} \
 		    ${DESTDIR}${PREFIX}/${TERRAFORM_PROVIDER_DIR} ; \
+		${LN} -sf ${PREFIX}/${TERRAFORM_PROVIDER_DIR}/${TERRAFORM_PROVIDER_BIN} \
+		    ${DESTDIR}${PREFIX}/${OPENTOFU_PROVIDER_DIR}/${TERRAFORM_PROVIDER_BIN} ; \
 		{ [ -d ${WRKDIR}/.gopath ] && chmod -R +w ${WRKDIR}/.gopath || ${TRUE} ; } ; \
 		${RM} -rf ${WRKDIR}/.gopath/bin ; \
 	elif [ -f ${WRKDIR}/bin/${TERRAFORM_PROVIDER_BIN} ]; then \
 		${INSTALL_PROGRAM} ${WRKDIR}/bin/${TERRAFORM_PROVIDER_BIN} \
 		    ${DESTDIR}${PREFIX}/${TERRAFORM_PROVIDER_DIR} ; \
+		${LN} -sf ${PREFIX}/${TERRAFORM_PROVIDER_DIR}/${TERRAFORM_PROVIDER_BIN} \
+		    ${DESTDIR}${PREFIX}/${OPENTOFU_PROVIDER_DIR}/${TERRAFORM_PROVIDER_BIN} ; \
 		${RM} -rf ${WRKDIR}/bin ; \
 		${RM} -rf ${WRKDIR}/pkg ; \
 	fi


Home | Main Index | Thread Index | Old Index