Skip to content

Commit

Permalink
removal: cleanup over legacy support (#3539)
Browse files Browse the repository at this point in the history
Follow-up of #3533
  • Loading branch information
camilamacedo86 authored Jul 30, 2020
1 parent fc84e60 commit 6bcaff8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
34 changes: 0 additions & 34 deletions internal/cmd/operator-sdk/generate/internal/genutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,40 +99,6 @@ func makeCRDFileName(group, resource string) string {
return fmt.Sprintf("%s_%s.yaml", group, resource)
}

// WriteObjectsToFilesLegacy creates dir then writes each object in objs to a
// file in legacy format in dir.
func WriteObjectsToFilesLegacy(dir string, objs ...interface{}) error {
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}

seenFiles := make(map[string]struct{})
for _, obj := range objs {
var fileName string
switch t := obj.(type) {
case apiextv1.CustomResourceDefinition:
fileName = makeCRDFileNameLegacy(t.Spec.Group, t.Spec.Names.Plural)
case apiextv1beta1.CustomResourceDefinition:
fileName = makeCRDFileNameLegacy(t.Spec.Group, t.Spec.Names.Plural)
default:
return fmt.Errorf("unknown object type: %T", t)
}

if _, hasFile := seenFiles[fileName]; hasFile {
return fmt.Errorf("duplicate file cannot be written: %s", fileName)
}
if err := writeObjectToFile(dir, obj, fileName); err != nil {
return err
}
seenFiles[fileName] = struct{}{}
}
return nil
}

func makeCRDFileNameLegacy(group, resource string) string {
return fmt.Sprintf("%s_%s_crd.yaml", group, resource)
}

// writeObjectToFile marshals crd to bytes and writes them to dir in file.
func writeObjectToFile(dir string, obj interface{}, fileName string) error {
f, err := os.Create(filepath.Join(dir, fileName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import (
"path/filepath"
"regexp"

"github.com/blang/semver"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"

"github.com/blang/semver"
operatorversion "github.com/operator-framework/api/pkg/lib/version"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-registry/pkg/lib/bundle"
Expand Down
6 changes: 3 additions & 3 deletions internal/util/projutil/project_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const (
GoModEnv = "GO111MODULE"
)

// Default config file path.
const configFile = "PROJECT"

// OperatorType - the type of operator
type OperatorType = string

Expand Down Expand Up @@ -76,9 +79,6 @@ func HasProjectFile() bool {
return true
}

// Default config file path.
const configFile = "PROJECT"

// ReadConfig returns a configuration if a file containing one exists at the
// default path (project root).
func ReadConfig() (*config.Config, error) {
Expand Down

0 comments on commit 6bcaff8

Please sign in to comment.