Skip to content

Instantly share code, notes, and snippets.

@cpuguy83
Last active April 5, 2024 21:03
Show Gist options
  • Save cpuguy83/c570f3ea97af215af63264061cac94af to your computer and use it in GitHub Desktop.
Save cpuguy83/c570f3ea97af215af63264061cac94af to your computer and use it in GitHub Desktop.
name: hello
version: 0.0.1
revision: "1"
website: https://example.com
description: Example patching go mods
license: MIT
vendor: Microsoft
packager: Microsoft
x-md2man: &md2man
git:
url: https://github.com/cpuguy83/go-md2man.git
commit: v2.0.4
x-md2manPatch: &md2manPatch
inline:
file:
contents: |
diff --git a/go.mod b/go.mod
index 0bc888d..3e95299 100644
--- a/go.mod
+++ b/go.mod
@@ -1,5 +1,13 @@
module github.com/cpuguy83/go-md2man/v2
-go 1.11
+go 1.21
-require github.com/russross/blackfriday/v2 v2.1.0
+require (
+ github.com/containerd/log v0.1.0
+ github.com/russross/blackfriday/v2 v2.1.0
+)
+
+require (
+ github.com/sirupsen/logrus v1.9.3 // indirect
+ golang.org/x/sys v0.7.0 // indirect
+)
diff --git a/go.sum b/go.sum
index 502a072..c62a87e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,2 +1,21 @@
+github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
+github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
+github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
+github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
+golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/md2man.go b/md2man.go
index 4ff873b..2a75c4d 100644
--- a/md2man.go
+++ b/md2man.go
@@ -1,11 +1,13 @@
package main
import (
+ "context"
"flag"
"fmt"
"io/ioutil"
"os"
+ "github.com/containerd/log"
"github.com/cpuguy83/go-md2man/v2/md2man"
)
@@ -18,6 +20,8 @@ func main() {
var err error
flag.Parse()
+ log.G(context.TODO()).Info("Adding an import for a patching example")
+
inFile := os.Stdin
if *inFilePath != "" {
inFile, err = os.Open(*inFilePath)
sources:
src:
<<: *md2man
gomods:
path: "/go/pkg/mod"
image:
ref: golang:1.21
cmd:
dir: "/work/src"
mounts:
- dest: "/work/src"
spec:
<<: *md2man
- dest: "/patch"
spec:
<<: *md2manPatch
steps:
- command: |
set -e
apt-get update
apt-get install -y patch
patch -p1 < /patch/gomods # Note: the path `/patch/gomods` looks like a bug in dalec, this should just be `/patch` or even `/patch/patch`
go mod download
patch:
<<: *md2manPatch
dependencies:
build:
msft-golang:
patches:
src:
- source: patch
build:
steps:
- command: |
export GOMODCACHE="${PWD}/gomods"
export GOPROXY=""
cd src; go build
artifacts:
binaries:
src/md2man: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment