Skip to content

Commit

Permalink
fix: also version indirect dependencies to ensure compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Dustin Scott <dustin.scott18@gmail.com>
  • Loading branch information
scottd018 committed Jun 20, 2022
1 parent e11a3ad commit 392e70c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8
k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
Expand Down
20 changes: 17 additions & 3 deletions internal/plugins/workload/v1/scaffolds/templates/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ type GoMod struct {
machinery.TemplateMixin
machinery.RepositoryMixin

GoVersionMinimum string
Dependencies map[string]string
GoVersionMinimum string
Dependencies map[string]string
IndirectDependencies map[string]string
}

// goModDependencyMap pins the versions within the go.mod file so that they
Expand All @@ -45,13 +46,20 @@ func goModDependencyMap() map[string]string {
}
}

func goModIndirectDependencyMap() map[string]string {
return map[string]string{
"gopkg.in/check.v1": "v1.0.0-20201130134442-10cb98267c6c",
}
}

func (f *GoMod) SetTemplateDefaults() error {
if f.Path == "" {
f.Path = "go.mod"
}

f.GoVersionMinimum = GoVersionMinimum
f.Dependencies = goModDependencyMap()
f.IndirectDependencies = goModIndirectDependencyMap()
f.TemplateBody = goModTemplate
f.IfExistsAction = machinery.OverwriteFile

Expand All @@ -66,6 +74,12 @@ go {{ .GoVersionMinimum }}
require (
{{ range $package, $version := $.Dependencies }}
"{{ $package }}" {{ $version }}
{{ end -}}
{{- end }}
)
require (
{{ range $package, $version := $.IndirectDependencies }}
"{{ $package }}" {{ $version }}
{{- end }}
)
`

0 comments on commit 392e70c

Please sign in to comment.