Skip to content

Commit

Permalink
go-1.18 and updates (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Jul 1, 2022
1 parent 81a176e commit c9b0783
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 385 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM metalstack/builder:latest as builder

FROM alpine:3.15
FROM alpine:3.16
RUN apk add --no-cache tini ca-certificates
COPY --from=builder /work/bin/metal-robot /metal-robot
CMD ["/metal-robot"]
48 changes: 25 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module github.com/metal-stack/metal-robot

go 1.17
go 1.18

require (
github.com/atedja/go-multilock v0.0.0-20170315063113-31d195f255fb
github.com/blang/semver/v4 v4.0.0
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4
github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2
github.com/go-playground/validator/v10 v10.10.1
github.com/go-playground/webhooks/v6 v6.0.0-rc.1
github.com/google/go-cmp v0.5.7
github.com/google/go-github/v43 v43.0.0
github.com/go-playground/validator/v10 v10.11.0
github.com/go-playground/webhooks/v6 v6.0.1
github.com/google/go-cmp v0.5.8
github.com/google/go-github/v45 v45.2.0
github.com/metal-stack/v v1.0.3
github.com/mitchellh/mapstructure v1.4.3
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1
github.com/tidwall/gjson v1.14.0
github.com/mitchellh/mapstructure v1.5.0
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
github.com/tidwall/gjson v1.14.1
github.com/tidwall/sjson v1.2.4
go.uber.org/zap v1.21.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
sigs.k8s.io/yaml v1.3.0
)

Expand All @@ -29,7 +29,7 @@ require (
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
Expand All @@ -42,25 +42,27 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
393 changes: 67 additions & 326 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/clients/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/metal-stack/metal-robot/pkg/config"
"go.uber.org/zap"

v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
)

type Github struct {
Expand Down
16 changes: 8 additions & 8 deletions pkg/config/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package config
type WebhookActions []WebhookAction

type WebhookAction struct {
Type string `json:"type" description:"name of the webhook action"`
Client string `json:"client" description:"client that this webhook action uses"`
Args map[string]interface{} `json:"args" description:"action configuration"`
Type string `json:"type" description:"name of the webhook action"`
Client string `json:"client" description:"client that this webhook action uses"`
Args map[string]any `json:"args" description:"action configuration"`
}
type RepositoryMaintainersConfig struct {
Suffix *string `mapstructure:"suffix" description:"suffix for maintainers group"`
Expand All @@ -26,7 +26,7 @@ type AggregateReleasesConfig struct {
}

type IssuesCommentHandlerConfig struct {
TargetRepos map[string]interface{} `mapstructure:"repos" description:"the repositories for which issue comment handling will be applied"`
TargetRepos map[string]any `mapstructure:"repos" description:"the repositories for which issue comment handling will be applied"`
}

type DistributeReleasesConfig struct {
Expand Down Expand Up @@ -64,10 +64,10 @@ type TargetRepo struct {
}

type ReleaseDraftConfig struct {
Repos map[string]interface{} `mapstructure:"repos" description:"the repositories for that a release draft will be pushed"`
RepositoryName string `mapstructure:"repository" description:"the name of the release repo"`
ReleaseTitleTemplate *string `mapstructure:"title-template" description:"custom template for the release title"`
DraftHeadline *string `mapstructure:"draft-headline" description:"custom headline for the release draft"`
Repos map[string]any `mapstructure:"repos" description:"the repositories for that a release draft will be pushed"`
RepositoryName string `mapstructure:"repository" description:"the name of the release repo"`
ReleaseTitleTemplate *string `mapstructure:"title-template" description:"custom template for the release title"`
DraftHeadline *string `mapstructure:"draft-headline" description:"custom headline for the release draft"`

MergedPRsHeadline *string `mapstructure:"merged-prs-section-headline" description:"custom headline for the section of merged pull requests"`
MergedPRsDescription *string `mapstructure:"merged-prs-section-description" description:"description for the merged pull requests section"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/modifiers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package config

type Modifier struct {
Type string `json:"type" description:"name of the modifier"`
Args map[string]interface{} `json:"args" description:"modifier configuration"`
Type string `json:"type" description:"name of the modifier"`
Args map[string]any `json:"args" description:"modifier configuration"`
}

type LinePatchConfig struct {
Expand Down
10 changes: 5 additions & 5 deletions pkg/markdown/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ func headingLevel(l string) int {
}

func ExtractAnnotatedBlock(annotation string, s string) (string, error) {
parts := strings.SplitN(s, "```"+annotation, 2)
if len(parts) != 2 {
_, contentWithTicks, found := strings.Cut(s, "```"+annotation)
if !found {
return "", NoSuchBlockError
}

parts = strings.SplitN(parts[1], "```", 2)
if len(parts) != 2 {
content, _, found := strings.Cut(contentWithTicks, "```")
if !found {
return "", NoSuchBlockError
}

return strings.TrimSpace(parts[0]), nil
return strings.TrimSpace(content), nil
}

func ToListItem(lines string) []string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/github/actions/aggregate_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/atedja/go-multilock"
"github.com/blang/semver/v4"
v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/metal-stack/metal-robot/pkg/git"
Expand All @@ -38,7 +38,7 @@ type AggregateReleaseParams struct {
TagName string
}

func NewAggregateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*AggregateReleases, error) {
func NewAggregateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*AggregateReleases, error) {
var (
branch = "develop"
commitMessageTemplate = "Bump %s to version %s"
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/github/actions/distribute_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"errors"

"github.com/atedja/go-multilock"
v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/metal-stack/metal-robot/pkg/git"
Expand Down Expand Up @@ -41,7 +41,7 @@ type targetRepo struct {
url string
}

func newDistributeReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*distributeReleases, error) {
func newDistributeReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*distributeReleases, error) {
var (
commitMessageTemplate = "Bump %s to version %s"
branchTemplate = "auto-generate/%s"
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/github/actions/docs_preview_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/mitchellh/mapstructure"
Expand All @@ -24,7 +24,7 @@ type docsPreviewCommentParams struct {
PullRequestNumber int
}

func newDocsPreviewComment(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*docsPreviewComment, error) {
func newDocsPreviewComment(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*docsPreviewComment, error) {
var (
commentTemplate = "#%d"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/github/actions/issues_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type IssuesActionParams struct {
CommentID int64
}

func NewIssuesAction(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*IssuesAction, error) {
func NewIssuesAction(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*IssuesAction, error) {
var typedConfig config.IssuesCommentHandlerConfig
err := mapstructure.Decode(rawConfig, &typedConfig)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/webhooks/github/actions/release_drafter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"strings"

"github.com/blang/semver/v4"
"github.com/google/go-github/v43/github"
"github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/metal-stack/metal-robot/pkg/markdown"
"github.com/metal-stack/metal-robot/pkg/utils"
"github.com/mitchellh/mapstructure"
"go.uber.org/zap"

v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
)

var (
Expand Down Expand Up @@ -55,7 +55,7 @@ type releaseDrafterParams struct {
ReleaseURL string
}

func newReleaseDrafter(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*releaseDrafter, error) {
func newReleaseDrafter(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*releaseDrafter, error) {
var (
releaseTitleTemplate = "%s"
draftHeadline = "General"
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/github/actions/release_drafter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/blang/semver/v4"
"github.com/google/go-cmp/cmp"
v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"go.uber.org/zap/zaptest"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/github/actions/repository_maintainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/mitchellh/mapstructure"
Expand All @@ -23,7 +23,7 @@ type repositoryMaintainersParams struct {
Creator string
}

func newCreateRepositoryMaintainers(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*repositoryMaintainers, error) {
func newCreateRepositoryMaintainers(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*repositoryMaintainers, error) {
var (
suffix = "-maintainers"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/github/actions/yaml_translate_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/atedja/go-multilock"
"github.com/blang/semver/v4"
v3 "github.com/google/go-github/v43/github"
v3 "github.com/google/go-github/v45/github"
"github.com/metal-stack/metal-robot/pkg/clients"
"github.com/metal-stack/metal-robot/pkg/config"
"github.com/metal-stack/metal-robot/pkg/git"
Expand Down Expand Up @@ -49,7 +49,7 @@ type yamlTranslateReleaseParams struct {
TagName string
}

func newYAMLTranslateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]interface{}) (*yamlTranslateReleases, error) {
func newYAMLTranslateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*yamlTranslateReleases, error) {
var (
branch = "develop"
commitMessageTemplate = "Bump %s to version %s"
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhooks/modifiers/file-patchers/line_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type LinePatch struct {
replaceTemplate *string
}

func newLinePatch(rawConfig map[string]interface{}) (*LinePatch, error) {
func newLinePatch(rawConfig map[string]any) (*LinePatch, error) {
var typedConfig config.LinePatchConfig
err := mapstructure.Decode(rawConfig, &typedConfig)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhooks/modifiers/file-patchers/yaml_path_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type YAMLPathPatch struct {
versionCompare bool
}

func newYAMLPathPatch(rawConfig map[string]interface{}) (*YAMLPathPatch, error) {
func newYAMLPathPatch(rawConfig map[string]any) (*YAMLPathPatch, error) {
var typedConfig config.YAMLPathPatchConfig
err := mapstructure.Decode(rawConfig, &typedConfig)
if err != nil {
Expand Down Expand Up @@ -98,7 +98,7 @@ func (p YAMLPathPatch) Apply(cn ContentReader, cw ContentWriter, newValue string
return nil
}

func setYAML(data []byte, path string, value interface{}) ([]byte, error) {
func setYAML(data []byte, path string, value any) ([]byte, error) {
json, err := yamlconv.YAMLToJSON(data)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Test_setYAML(t *testing.T) {
type args struct {
data []byte
path string
value interface{}
value any
}
tests := []struct {
name string
Expand Down

0 comments on commit c9b0783

Please sign in to comment.