feature: handling replace clauses in plugins passed with --with

This issue has been created since 2022-01-12.

@mholt , by design the replace directives are not being considered.

For example the replace go.mod:

module github.com/greenpau/caddy-git

go 1.16

require (
        github.com/caddyserver/caddy/v2 v2.4.6
        github.com/go-git/go-git/v5 v5.4.2
        github.com/google/go-cmp v0.5.6
        go.uber.org/zap v1.20.0
)

replace github.com/go-git/go-git/v5 v5.4.2 => /home/greenpau/dev/go/src/github.com/go-git/go-git

The replace in plugin's go.mod will not be accounted for when compiling in xcaddy.

What do you think about parsing go.mod files in the plugin's passed with --with for the presence of replace clauses and adding them to the build?

greenpau wrote this answer on 2022-01-12

I can actually pass non-plugin package --with github.com/go-git/go-git/[email protected]=/home/greenpau/dev/go/src/github.com/go-git/go-git and it works. Thought reading the go.mod might be more convenient.

greenpau wrote this answer on 2022-01-12

A potential place to analyze the plugins' go.mod files is here:

xcaddy/environment.go

Lines 111 to 120 in c8b2d00

for _, r := range b.Replacements {
log.Printf("[INFO] Replace %s => %s", r.Old.String(), r.New.String())
cmd := env.newCommand("go", "mod", "edit",
"-replace", fmt.Sprintf("%s=%s", r.Old.Param(), r.New.Param()))
err := env.runCommand(ctx, cmd, 10*time.Second)
if err != nil {
return nil, err
}
replaced[r.Old.String()] = r.New.String()
}

francislavoie wrote this answer on 2022-01-12

I think your --with with the replacement is the intended way to do this. I don't think we should add complexity by reading go.mod files. That's a lot.

mholt wrote this answer on 2022-01-12

The problem with reading go.mod is that there's a couple sources of truth: command line or go.mod, and plus sometimes you want to do a custom build without changing files on disk / in the repo, so your working copy is clean. That's why I opted for a solely command-line-based solution for simple custom builds, at least. It's automating the process of creating a new module with a go.mod file and then running build, so having to edit go.mod would be a little bit redundant. If you're already creating/editing go.mod you don't really need xcaddy.

More Details About Repo
Owner Name caddyserver
Repo Name xcaddy
Full Name caddyserver/xcaddy
Language Go
Created Date 2020-03-21
Updated Date 2022-09-22
Star Count 381
Watcher Count 14
Fork Count 72
Issue Count 3

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Como utilizar SQL Join(Include) para Filtrar 3 2022-05-03 2022-09-22
Couldn't get the valid product image through amazon url 1 2022-04-27 2022-08-03
ECDH Key agreement with default non-volatile keys 2 2021-08-13 2022-08-30
McXtrace mxplot calls mcplot-pyqtgraph when 'x' is pressed. 1 2022-03-08 2022-09-11
Qubes R4.1rc4 installer tries to force EFI boot 2 2022-02-01 2022-09-11
`qubes-gpg-client` hangs forever if the qrexec call is refused 18 2022-02-01 2022-09-12
BIDS validator Error 1: [Code 0] INTERNAL ERROR - SOME VALIDATION STEPS MAY NOT HAVE OCCURRED 7 2022-01-19 2022-09-13
ENOBUFS when calling bin/bids-validator outside of project. 2 2022-01-04 2022-09-19
Notworking gatsby new my-blog-starter https://github.com/JaeYeopHan/gatsby-starter-bee 1 2021-03-08 2022-09-02
Algorithm/2021-02-01/ 1 2021-02-01 2022-09-02
Gatsby/Gatsby%EC%97%90%EC%84%9C%20Markdown%EC%84%A4%EC%A0%95/ 1 2021-04-23 2022-09-02
Method to copy path 2 2012-01-16 2022-01-12
`_apply_stiffness_transpose_operator`: uses einsum in a way that causes high cost 1 2021-07-05 2021-12-26
`_compute_local_gradient` largely duplicates the code of `_apply_stiffness_transpose_operator` 0 2021-07-05 2021-12-19
error: Cannot read properties of undefined (reading 'gameId') 1 2022-06-30 2022-09-01
"re-release" 1.8 with Gradle? 2 2020-07-19 2022-09-19
Maya Export Texture Formats 1 2022-04-01 2022-09-09
`int` could be a valid Java pattern 2 2022-02-02 2022-09-21
Highlight React code 1 2022-05-26 2022-09-17
[I] "Find Note" action does nothing if Note Search panel is not in layout 9 2022-06-05 2022-09-17
Error: Text strings must be rendered within a <Text> component. 1 2022-01-21 2022-08-18
"vim:foldmethod=marker:foldlevel=0" in vimscript triggers folding while inserting "if else ..." 3 2022-05-26 2022-09-05
Webpack 5 support 3 2021-08-09 2021-12-25
GetStories() - Response code is 500. Body 1 2021-11-12 2022-09-22
"Duplicate all selected elements" ignores entity max count rules 1 2022-01-12 2022-07-31
Running the postinstall hook twice is surprising and unexpected, especially with suppressed output 0 2021-12-11 2022-08-21
get error in vscode 1 2021-06-28 2022-01-03
Extension issue 1 2021-12-03 2022-01-21
PubSub wildcard supscriptions do not work with grpc 15 2022-03-31 2022-09-26
Add API to get similar templates 0 2022-01-24 2022-09-14
Reports for Network connectivity (API/Reports) 2 2022-05-02 2022-09-20
ensure the resourceKey is used for file access 1 2021-08-11 2022-09-15
Support for Linux 3 2021-08-16 2022-01-09
LobbyManager.ConnectVoice returns Results.Ok even when the user is not connected to the lobby 3 2020-03-24 2022-07-25
[Bug] Control Colors Locked to Device Theme 0 2022-05-20 2022-09-22
This code not work "Module is not defined error" 0 2019-04-02 2022-09-12
Back and Forward Browser Buttons are Broken 0 2021-10-27 2022-09-17
UDP recv works in Python console, does not work when executed as python3 exploit.py 5 2021-10-05 2022-09-16
GeoSeries.from_df Geocoding Addresses in Wrong Location 2 2022-04-26 2022-09-22
request to http://engine-registry.prod.svc.cluster.local/api/graphql failed, reason: read ECONNRESET 2 2021-11-10 2022-09-28
GitHub Action FAILED 0 2021-02-03 2021-11-21
GitHub Action FAILED 0 2021-02-03 2021-11-21
Simple ScrollView doesn't show text scrollbar 1 2021-04-20 2022-09-18
Cannot compile version 2.1.85 in CentOS7 0 2017-08-01 2022-09-08
Numbered lists without numbers deleted during conversion 2 2021-12-05 2022-09-26
the plugin breaks after upgrading to cypress v7 2 2021-04-13 2022-09-28
qrun TRA model error 5 2022-04-18 2022-09-25
Unclearable overlays 4 2015-04-09 2022-09-15
Host Networking pods get only 1 IP address during fresh deployment or reboot of nodes in dual stack enabled cluster 17 2021-09-28 2022-09-17
pod install failure with glog 10 2020-06-10 2022-08-04