From 201ee334e82903222433d129f10bb9766585aa58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Mon, 19 Oct 2020 16:47:32 +0200 Subject: [PATCH] Add replaces directive (#10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- README.md | 5 +++++ internal/builder/config.go | 1 + internal/scaffold/gomod.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index a2150eb..6d51f85 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,8 @@ The `import` might specify a more specific path than what is specified in the `g The `name` will typically be omitted, except when multiple components have the same name. In such case, set a unique name for each module. +Optionally, a list of `go mod` replace entries can be provided, in case custom overrides are needed. This is typically necessary when a processor or some of its transitive dependencies have dependency problems. + ```yaml dist: module: github.com/observatorium/opentelemetry-collector-builder # the module name for the new distribution, following Go mod conventions. Optional, but recommended. @@ -80,4 +82,7 @@ exporters: import: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" # the import path for the component. Optional. name: "alibabacloudlogserviceexporter" # package name to use in the generated sources. Optional. path: "./alibabacloudlogserviceexporter" # in case a local version should be used for the module, the path relative to the current dir, or a full path can be specified. Optional. +replaces: + # a list of "replaces" directives that will be part of the resulting go.mod + - github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.12.0 ``` diff --git a/internal/builder/config.go b/internal/builder/config.go index e58b60a..bb34821 100644 --- a/internal/builder/config.go +++ b/internal/builder/config.go @@ -40,6 +40,7 @@ type Config struct { Extensions []Module `mapstructure:"extensions"` Receivers []Module `mapstructure:"receivers"` Processors []Module `mapstructure:"processors"` + Replaces []string `mapstructure:"replaces"` } // Distribution holds the parameters for the final binary diff --git a/internal/scaffold/gomod.go b/internal/scaffold/gomod.go index 53dcd8d..126d304 100644 --- a/internal/scaffold/gomod.go +++ b/internal/scaffold/gomod.go @@ -47,4 +47,7 @@ require ( {{- range .Processors}} {{if ne .Path ""}}replace {{.GoMod}} => {{.Path}}{{end}} {{- end}} +{{- range .Replaces}} +replace {{.}} +{{- end}} `