Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go 1.13 and removing support for --dep-manager=dep #1949

Merged
merged 4 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ cache:
- $HOME/.cache/go-build

go:
- 1.12.x
- 1.13.x
jmrodri marked this conversation as resolved.
Show resolved Hide resolved

# The `x_base_steps` top-level key is unknown to travis,
# so we can use it to create a bunch of common build step
# YAML anchors which we use in our build jobs.
x_base_steps:
# before_install for jobs that require dep
- &dep_before_install
before_install:
- travis_retry make tidy

# before_install for jobs that require go builds and do not run for doc-only changes
- &go_before_install
before_install:
Expand Down Expand Up @@ -151,7 +146,6 @@ jobs:
name: Unit, Sanity, and Markdown Tests
# Currently, prow/api-ci tests all PRs that target master; use travis for post merge testing and non-master PRs
if: type != pull_request OR branch != master
<<: *dep_before_install
script: make test-sanity test-unit test-markdown
after_success: echo 'Tests Passed'
after_failure: echo 'Failure in unit, sanity, or markdown test'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

### Changed

- **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))

### Deprecated

### Removed

- 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))

### Bug Fixes

- OLM internal manager is not returning errors in the initialization. ([#1976](https://github.com/operator-framework/operator-sdk/pull/1976))
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ The following workflow is for a new **Helm** operator:
## Prerequisites

- [git][git_tool]
- [go][go_tool] version v1.12+.
- [go][go_tool] version v1.13+.
- [mercurial][mercurial_tool] version 3.9+
jmrodri marked this conversation as resolved.
Show resolved Hide resolved
- [docker][docker_tool] version 17.03+.
- Alternatively [podman][podman_tool] `v1.2.0+` or [buildah][buildah_tool] `v1.7+`
- [kubectl][kubectl_tool] version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
- Optional: [dep][dep_tool] version v0.5.0+.
- Optional: [delve](https://github.com/go-delve/delve/tree/master/Documentation/installation) version 1.2.0+ (for `up local --enable-delve`).

## Quick Start
Expand Down Expand Up @@ -181,7 +180,6 @@ Operator SDK is under Apache 2.0 license. See the [LICENSE][license_file] file f
[contrib]: ./CONTRIBUTING.MD
[bug_guide]:./doc/dev/reporting_bugs.md
[license_file]:./LICENSE
[dep_tool]:https://golang.github.io/dep/docs/installation.html
[git_tool]:https://git-scm.com/downloads
[go_tool]:https://golang.org/dl/
[mercurial_tool]:https://www.mercurial-scm.org/downloads
Expand Down
2 changes: 1 addition & 1 deletion ci/dockerfiles/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openshift/origin-release:golang-1.12
FROM openshift/origin-release:golang-1.13

WORKDIR /go/src/github.com/operator-framework/operator-sdk
ENV GOPATH=/go PATH=/go/src/github.com/operator-framework/operator-sdk/build:$PATH GOPROXY=https://proxy.golang.org/ GO111MODULE=on
Expand Down
1 change: 0 additions & 1 deletion cmd/operator-sdk/build/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func buildFunc(cmd *cobra.Command, args []string) error {
PackagePath: path.Join(projutil.GetGoPkg(), filepath.ToSlash(scaffold.ManagerDir)),
Args: args,
Env: goBuildEnv,
GoMod: projutil.IsDepManagerGoMod(),
}
if err := projutil.GoBuild(opts); err != nil {
return fmt.Errorf("failed to build operator binary: (%v)", err)
Expand Down
42 changes: 6 additions & 36 deletions cmd/operator-sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package main

import (
"fmt"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -56,7 +55,7 @@ func main() {
log.SetLevel(log.DebugLevel)
log.Debug("Debug logging is set")
}
if err := checkDepManagerForCmd(cmd); err != nil {
if err := checkGoModulesForCmd(cmd); err != nil {
log.Fatal(err)
}
},
Expand Down Expand Up @@ -87,29 +86,25 @@ func main() {
}
}

func checkDepManagerForCmd(cmd *cobra.Command) (err error) {
func checkGoModulesForCmd(cmd *cobra.Command) (err error) {
// Certain commands are able to be run anywhere or handle this check
// differently in their CLI code.
if skipCheckForCmd(cmd) {
return nil
}
// Do not perform this check if the project is non-Go, as they will not have
// a (Go) dep manager.
// Do not perform this check if the project is non-Go, as they will not
// be using go modules.
if !projutil.IsOperatorGo() {
return nil
}
// Do not perform a dep manager check if the working directory is not in
// Do not perform a go modules check if the working directory is not in
// the project root, as some sub-commands might not require project root.
// Individual subcommands will perform this check as needed.
if err := projutil.CheckProjectRoot(); err != nil {
return nil
}

dm, err := projutil.GetDepManagerType()
if err != nil {
return err
}
return checkDepManager(dm)
return projutil.CheckGoModules()
}

var commandsToSkip = map[string]struct{}{
Expand All @@ -136,28 +131,3 @@ func skipCheckForCmd(cmd *cobra.Command) (skip bool) {
})
return skip
}

func checkDepManager(dm projutil.DepManagerType) error {
switch dm {
case projutil.DepManagerGoMod:
goModOn, err := projutil.GoModOn()
if err != nil {
return err
}
if !goModOn {
return fmt.Errorf(`dependency manager "modules" requires working directory to be in $GOPATH/src` +
` 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`)
}
case projutil.DepManagerDep:
inGopathSrc, err := projutil.WdInGoPathSrc()
if err != nil {
return err
}
if !inGopathSrc {
return fmt.Errorf(`dependency manager "dep" requires working directory to be in $GOPATH/src`)
}
default:
return projutil.ErrInvalidDepManager(dm)
}
return nil
}
45 changes: 6 additions & 39 deletions cmd/operator-sdk/migrate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import (
"github.com/operator-framework/operator-sdk/internal/scaffold/input"
"github.com/operator-framework/operator-sdk/internal/util/projutil"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

var (
depManager string
headerFile string
repo string
)
Expand All @@ -45,9 +43,8 @@ func NewCmd() *cobra.Command {
RunE: migrateRun,
}

newCmd.Flags().StringVar(&depManager, "dep-manager", "modules", `Dependency manager the new project will use (choices: "dep", "modules")`)
newCmd.Flags().StringVar(&headerFile, "header-file", "", "Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt")
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")
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)")

return newCmd
}
Expand Down Expand Up @@ -76,7 +73,7 @@ func migrateRun(cmd *cobra.Command, args []string) error {
}

func verifyFlags() error {
err := projutil.CheckDepManagerWithRepo(projutil.DepManagerType(depManager), repo)
err := projutil.CheckRepo(repo)
if err != nil {
return err
}
Expand Down Expand Up @@ -119,11 +116,9 @@ func migrateAnsible() error {
s.BoilerplatePath = headerFile
}

if err := scaffoldAnsibleDepManager(s, cfg); err != nil {
return errors.Wrap(err, "migrate Ansible dependency manager file scaffold failed")
}

err = s.Execute(cfg,
&ansible.GoMod{},
&scaffold.Tools{},
&ansible.Main{},
&dockerfile,
&ansible.Entrypoint{},
Expand Down Expand Up @@ -160,11 +155,9 @@ func migrateHelm() error {
s.BoilerplatePath = headerFile
}

if err := scaffoldHelmDepManager(s, cfg); err != nil {
return errors.Wrap(err, "migrate Helm dependency manager file scaffold failed")
}

err := s.Execute(cfg,
&helm.GoMod{},
&scaffold.Tools{},
&helm.Main{},
&helm.DockerfileHybrid{
Watches: true,
Expand All @@ -189,29 +182,3 @@ func renameDockerfile() error {
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)
return nil
}

func scaffoldHelmDepManager(s *scaffold.Scaffold, cfg *input.Config) error {
var files []input.File
switch m := projutil.DepManagerType(depManager); m {
case projutil.DepManagerDep:
files = append(files, &helm.GopkgToml{})
case projutil.DepManagerGoMod:
files = append(files, &helm.GoMod{}, &scaffold.Tools{})
default:
return projutil.ErrInvalidDepManager(depManager)
}
return s.Execute(cfg, files...)
}

func scaffoldAnsibleDepManager(s *scaffold.Scaffold, cfg *input.Config) error {
var files []input.File
switch m := projutil.DepManagerType(depManager); m {
case projutil.DepManagerDep:
files = append(files, &ansible.GopkgToml{})
case projutil.DepManagerGoMod:
files = append(files, &ansible.GoMod{}, &scaffold.Tools{})
default:
return projutil.ErrInvalidDepManager(depManager)
}
return s.Execute(cfg, files...)
}
Loading