Add helper script to give you all the commands to update all go mod dependencies
This commit is contained in:
parent
205559b4f3
commit
947b4fd579
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@ -8,6 +8,12 @@ updates:
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: "gomod"
|
||||
open-pull-requests-limit: 2
|
||||
directory: "/hack/update-go-mod"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
|
5
hack/update-go-mod/go.mod
Normal file
5
hack/update-go-mod/go.mod
Normal file
@ -0,0 +1,5 @@
|
||||
module go.pinniped.dev/update-go-mod
|
||||
|
||||
go 1.18
|
||||
|
||||
require golang.org/x/mod v0.8.0
|
2
hack/update-go-mod/go.sum
Normal file
2
hack/update-go-mod/go.sum
Normal file
@ -0,0 +1,2 @@
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
42
hack/update-go-mod/main.go
Normal file
42
hack/update-go-mod/main.go
Normal file
@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
// Copyright 2023 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/mod/modfile"
|
||||
)
|
||||
|
||||
func main() {
|
||||
goModFilepath := filepath.Clean(os.Args[1])
|
||||
|
||||
if _, err := os.Stat(goModFilepath); err != nil {
|
||||
log.Fatalf("File '%s' does not exist\n", goModFilepath)
|
||||
}
|
||||
|
||||
var (
|
||||
bytes []byte
|
||||
err error
|
||||
)
|
||||
if bytes, err = os.ReadFile(goModFilepath); err != nil {
|
||||
log.Fatalf("Unable to read file '%s'\n", goModFilepath)
|
||||
}
|
||||
|
||||
file, err := modfile.Parse(goModFilepath, bytes, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to parse file '%s'\n", goModFilepath)
|
||||
}
|
||||
|
||||
for _, require := range file.Require {
|
||||
if !require.Indirect {
|
||||
fmt.Printf("go get %s &&\n", require.Mod.Path)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("./hack/module.sh tidy\n")
|
||||
}
|
14
hack/update-go-mod/update-go-mod.sh
Executable file
14
hack/update-go-mod/update-go-mod.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2023 the Pinniped contributors. All Rights Reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
GO_MOD="${SCRIPT_DIR}/../../go.mod"
|
||||
|
||||
pushd "${SCRIPT_DIR}" > /dev/null
|
||||
go run . "${GO_MOD}"
|
||||
popd > /dev/null
|
Loading…
Reference in New Issue
Block a user