Skip to content
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
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"
Comment thread
estroz marked this conversation as resolved.
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