Skip to content

Commit 347aaa1

Browse files
authored
Go 1.13 and removing support for --dep-manager=dep (operator-framework#1949)
* initial jump to go 1.13 * cmd/operator-sdk,internal/util/projutil: fix comment, reuse checkGoModules * CHANGELOG.md: add lines for operator-framework#1949 * doc/*: updates from PR feedback
1 parent d94ad3e commit 347aaa1

32 files changed

+172
-637
lines changed

.travis.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,12 @@ cache:
3030
- $HOME/.cache/go-build
3131

3232
go:
33-
- 1.12.x
33+
- 1.13.x
3434

3535
# The `x_base_steps` top-level key is unknown to travis,
3636
# so we can use it to create a bunch of common build step
3737
# YAML anchors which we use in our build jobs.
3838
x_base_steps:
39-
# before_install for jobs that require dep
40-
- &dep_before_install
41-
before_install:
42-
- travis_retry make tidy
43-
4439
# before_install for jobs that require go builds and do not run for doc-only changes
4540
- &go_before_install
4641
before_install:
@@ -151,7 +146,6 @@ jobs:
151146
name: Unit, Sanity, and Markdown Tests
152147
# Currently, prow/api-ci tests all PRs that target master; use travis for post merge testing and non-master PRs
153148
if: type != pull_request OR branch != master
154-
<<: *dep_before_install
155149
script: make test-sanity test-unit test-markdown
156150
after_success: echo 'Tests Passed'
157151
after_failure: echo 'Failure in unit, sanity, or markdown test'

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
### Changed
99

10+
- **Breaking change:** Changed required Go version from `1.12` to `1.13`. This change applies to the SDK project itself and Go projects scaffolded by the SDK. Projects that import this version of the SDK require Go 1.13 to compile. ([#1949](https://github.com/operator-framework/operator-sdk/pull/1949))
11+
1012
### Deprecated
1113

1214
### Removed
1315

16+
- Removed `--dep-manager` flag and support for `dep`-based projects. Projects will be scaffolded to use Go modules. ([#1949](https://github.com/operator-framework/operator-sdk/pull/1949))
17+
1418
### Bug Fixes
1519

1620
- OLM internal manager is not returning errors in the initialization. ([#1976](https://github.com/operator-framework/operator-sdk/pull/1976))

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ The following workflow is for a new **Helm** operator:
4141
## Prerequisites
4242

4343
- [git][git_tool]
44-
- [go][go_tool] version v1.12+.
44+
- [go][go_tool] version v1.13+.
4545
- [mercurial][mercurial_tool] version 3.9+
4646
- [docker][docker_tool] version 17.03+.
4747
- Alternatively [podman][podman_tool] `v1.2.0+` or [buildah][buildah_tool] `v1.7+`
4848
- [kubectl][kubectl_tool] version v1.11.3+.
4949
- Access to a Kubernetes v1.11.3+ cluster.
50-
- Optional: [dep][dep_tool] version v0.5.0+.
5150
- Optional: [delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) version 1.2.0+ (for `up local --enable-delve`).
5251

5352
## Quick Start
@@ -181,7 +180,6 @@ Operator SDK is under Apache 2.0 license. See the [LICENSE][license_file] file f
181180
[contrib]: ./CONTRIBUTING.MD
182181
[bug_guide]:./doc/dev/reporting_bugs.md
183182
[license_file]:./LICENSE
184-
[dep_tool]:https://golang.github.io/dep/docs/installation.html
185183
[git_tool]:https://git-scm.com/downloads
186184
[go_tool]:https://golang.org/dl/
187185
[mercurial_tool]:https://www.mercurial-scm.org/downloads

ci/dockerfiles/builder.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM openshift/origin-release:golang-1.12
1+
FROM openshift/origin-release:golang-1.13
22

33
WORKDIR /go/src/github.com/operator-framework/operator-sdk
44
ENV GOPATH=/go PATH=/go/src/github.com/operator-framework/operator-sdk/build:$PATH GOPROXY=https://proxy.golang.org/ GO111MODULE=on

cmd/operator-sdk/build/cmd.go

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ func buildFunc(cmd *cobra.Command, args []string) error {
119119
PackagePath: path.Join(projutil.GetGoPkg(), filepath.ToSlash(scaffold.ManagerDir)),
120120
Args: args,
121121
Env: goBuildEnv,
122-
GoMod: projutil.IsDepManagerGoMod(),
123122
}
124123
if err := projutil.GoBuild(opts); err != nil {
125124
return fmt.Errorf("failed to build operator binary: (%v)", err)

cmd/operator-sdk/main.go

+6-36
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package main
1616

1717
import (
18-
"fmt"
1918
"os"
2019

2120
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -56,7 +55,7 @@ func main() {
5655
log.SetLevel(log.DebugLevel)
5756
log.Debug("Debug logging is set")
5857
}
59-
if err := checkDepManagerForCmd(cmd); err != nil {
58+
if err := checkGoModulesForCmd(cmd); err != nil {
6059
log.Fatal(err)
6160
}
6261
},
@@ -87,29 +86,25 @@ func main() {
8786
}
8887
}
8988

90-
func checkDepManagerForCmd(cmd *cobra.Command) (err error) {
89+
func checkGoModulesForCmd(cmd *cobra.Command) (err error) {
9190
// Certain commands are able to be run anywhere or handle this check
9291
// differently in their CLI code.
9392
if skipCheckForCmd(cmd) {
9493
return nil
9594
}
96-
// Do not perform this check if the project is non-Go, as they will not have
97-
// a (Go) dep manager.
95+
// Do not perform this check if the project is non-Go, as they will not
96+
// be using go modules.
9897
if !projutil.IsOperatorGo() {
9998
return nil
10099
}
101-
// Do not perform a dep manager check if the working directory is not in
100+
// Do not perform a go modules check if the working directory is not in
102101
// the project root, as some sub-commands might not require project root.
103102
// Individual subcommands will perform this check as needed.
104103
if err := projutil.CheckProjectRoot(); err != nil {
105104
return nil
106105
}
107106

108-
dm, err := projutil.GetDepManagerType()
109-
if err != nil {
110-
return err
111-
}
112-
return checkDepManager(dm)
107+
return projutil.CheckGoModules()
113108
}
114109

115110
var commandsToSkip = map[string]struct{}{
@@ -136,28 +131,3 @@ func skipCheckForCmd(cmd *cobra.Command) (skip bool) {
136131
})
137132
return skip
138133
}
139-
140-
func checkDepManager(dm projutil.DepManagerType) error {
141-
switch dm {
142-
case projutil.DepManagerGoMod:
143-
goModOn, err := projutil.GoModOn()
144-
if err != nil {
145-
return err
146-
}
147-
if !goModOn {
148-
return fmt.Errorf(`dependency manager "modules" requires working directory to be in $GOPATH/src` +
149-
` and GO111MODULE=on, or outside of $GOPATH/src and GO111MODULE="on", "auto", or unset. More info: https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md#go-modules`)
150-
}
151-
case projutil.DepManagerDep:
152-
inGopathSrc, err := projutil.WdInGoPathSrc()
153-
if err != nil {
154-
return err
155-
}
156-
if !inGopathSrc {
157-
return fmt.Errorf(`dependency manager "dep" requires working directory to be in $GOPATH/src`)
158-
}
159-
default:
160-
return projutil.ErrInvalidDepManager(dm)
161-
}
162-
return nil
163-
}

cmd/operator-sdk/migrate/cmd.go

+6-39
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ import (
2525
"github.com/operator-framework/operator-sdk/internal/scaffold/input"
2626
"github.com/operator-framework/operator-sdk/internal/util/projutil"
2727

28-
"github.com/pkg/errors"
2928
log "github.com/sirupsen/logrus"
3029
"github.com/spf13/cobra"
3130
)
3231

3332
var (
34-
depManager string
3533
headerFile string
3634
repo string
3735
)
@@ -45,9 +43,8 @@ func NewCmd() *cobra.Command {
4543
RunE: migrateRun,
4644
}
4745

48-
newCmd.Flags().StringVar(&depManager, "dep-manager", "modules", `Dependency manager the new project will use (choices: "dep", "modules")`)
4946
newCmd.Flags().StringVar(&headerFile, "header-file", "", "Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt")
50-
newCmd.Flags().StringVar(&repo, "repo", "", "Project repository path. Used as the project's Go import path. This must be set if outside of $GOPATH/src with Go modules, and cannot be set if --dep-manager=dep")
47+
newCmd.Flags().StringVar(&repo, "repo", "", "Project repository path. Used as the project's Go import path. This must be set if outside of $GOPATH/src (e.g. github.com/example-inc/my-operator)")
5148

5249
return newCmd
5350
}
@@ -76,7 +73,7 @@ func migrateRun(cmd *cobra.Command, args []string) error {
7673
}
7774

7875
func verifyFlags() error {
79-
err := projutil.CheckDepManagerWithRepo(projutil.DepManagerType(depManager), repo)
76+
err := projutil.CheckRepo(repo)
8077
if err != nil {
8178
return err
8279
}
@@ -119,11 +116,9 @@ func migrateAnsible() error {
119116
s.BoilerplatePath = headerFile
120117
}
121118

122-
if err := scaffoldAnsibleDepManager(s, cfg); err != nil {
123-
return errors.Wrap(err, "migrate Ansible dependency manager file scaffold failed")
124-
}
125-
126119
err = s.Execute(cfg,
120+
&ansible.GoMod{},
121+
&scaffold.Tools{},
127122
&ansible.Main{},
128123
&dockerfile,
129124
&ansible.Entrypoint{},
@@ -160,11 +155,9 @@ func migrateHelm() error {
160155
s.BoilerplatePath = headerFile
161156
}
162157

163-
if err := scaffoldHelmDepManager(s, cfg); err != nil {
164-
return errors.Wrap(err, "migrate Helm dependency manager file scaffold failed")
165-
}
166-
167158
err := s.Execute(cfg,
159+
&helm.GoMod{},
160+
&scaffold.Tools{},
168161
&helm.Main{},
169162
&helm.DockerfileHybrid{
170163
Watches: true,
@@ -189,29 +182,3 @@ func renameDockerfile() error {
189182
log.Infof("Renamed Dockerfile to %s and replaced with newer version. Compare the new Dockerfile to your old one and manually migrate any customizations", newDockerfilePath)
190183
return nil
191184
}
192-
193-
func scaffoldHelmDepManager(s *scaffold.Scaffold, cfg *input.Config) error {
194-
var files []input.File
195-
switch m := projutil.DepManagerType(depManager); m {
196-
case projutil.DepManagerDep:
197-
files = append(files, &helm.GopkgToml{})
198-
case projutil.DepManagerGoMod:
199-
files = append(files, &helm.GoMod{}, &scaffold.Tools{})
200-
default:
201-
return projutil.ErrInvalidDepManager(depManager)
202-
}
203-
return s.Execute(cfg, files...)
204-
}
205-
206-
func scaffoldAnsibleDepManager(s *scaffold.Scaffold, cfg *input.Config) error {
207-
var files []input.File
208-
switch m := projutil.DepManagerType(depManager); m {
209-
case projutil.DepManagerDep:
210-
files = append(files, &ansible.GopkgToml{})
211-
case projutil.DepManagerGoMod:
212-
files = append(files, &ansible.GoMod{}, &scaffold.Tools{})
213-
default:
214-
return projutil.ErrInvalidDepManager(depManager)
215-
}
216-
return s.Execute(cfg, files...)
217-
}

0 commit comments

Comments
 (0)