From 831c0c49210146f7aa3724a006f4c843b8032a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Garc=C3=ADa=20Veytia=20=28Puerco=29?= Date: Fri, 14 Jul 2023 14:07:40 -0600 Subject: [PATCH] Make the default namespace configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new vex.DefaultNamespace variable that is used to set the namespace used in node and document identifiers. It is set by default to the OpenVEX public namespace. Signed-off-by: Adolfo GarcĂ­a Veytia (Puerco) --- pkg/vex/vex.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/vex/vex.go b/pkg/vex/vex.go index d07da82..d2bb366 100644 --- a/pkg/vex/vex.go +++ b/pkg/vex/vex.go @@ -48,6 +48,10 @@ const ( errMsgParse = "error" ) +// DefaultNamespace is the URL that will be used to generate new IRIs for generated +// documents and nodes. It is set to the OpenVEX public namespace by default. +var DefaultNamespace = PublicNamespace + // The VEX type represents a VEX document and all of its contained information. type VEX struct { Metadata @@ -386,7 +390,7 @@ func (vexDoc *VEX) GenerateCanonicalID() (string, error) { } // For common namespaced documents we namespace them into /public - vexDoc.ID = fmt.Sprintf("%s/public/vex-%s", PublicNamespace, cHash) + vexDoc.ID = fmt.Sprintf("%s/public/vex-%s", DefaultNamespace, cHash) return vexDoc.ID, nil }