-
Notifications
You must be signed in to change notification settings - Fork 1.8k
cmd/.../gen-csv: use --include
instead of CSV config
#2249
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
Closed
estroz
wants to merge
9
commits into
operator-framework:master
from
estroz:osdk-674-remove-csv-config
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
54d675e
cmd/operator-sdk/olmcatalog: use new Config in scaffolds, remove
estroz 42894f3
set version correctly and copy string in closure
estroz 3393058
add test case and improve CLI doc
estroz afdfaa9
Merge branch 'master' into osdk-674-remove-csv-config
estroz 02e5833
CHANGELOG.md: add --exlude
estroz 6f7108b
Merge branch 'master' into osdk-674-remove-csv-config
estroz 891c90f
exclude -> include behavior
estroz f5c84cf
update docs
estroz 269aa73
update docs
estroz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2019 The Operator-SDK Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package genutil | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/operator-framework/operator-sdk/internal/util/projutil" | ||
) | ||
|
||
// Config configures a generator with common operator project information. | ||
type Config struct { | ||
// OperatorName is the operator's name, ex. app-operator | ||
OperatorName string | ||
// InputDir is a dir containing relevant input files. If not set, a default | ||
// is used on a per-generator basis. | ||
InputDir string | ||
// OutputDir is a dir in which to generate output files. If not set, a | ||
// default is used on a per-generator basis. | ||
OutputDir string | ||
// IncludeFuncs contains a set of filters for paths that a generator | ||
// may encounter while gathering data for generation. If any func returns | ||
// true, that path will be included by the generator. | ||
IncludeFuncs IncludeFuncs | ||
} | ||
|
||
// IncludeFuncs is a slice of filter funcs. A string passing any func in | ||
// IncludeFuncs satisfies the filter. | ||
type IncludeFuncs []func(string) bool | ||
|
||
// MakeIncludeFuncs creates a set of closures around each path in paths | ||
// to populate Config.IncludeFuncs. If the argument to the closure has | ||
// a prefix of path, it returns true. | ||
func MakeIncludeFuncs(paths ...string) (includes IncludeFuncs) { | ||
pathSet := map[string]struct{}{} | ||
for _, path := range paths { | ||
pathSet[filepath.Clean(path)] = struct{}{} | ||
} | ||
wd := projutil.MustGetwd() + string(filepath.Separator) | ||
for path := range pathSet { | ||
// Copy the string for the closure. | ||
pb := strings.Builder{} | ||
pb.WriteString(path) | ||
includes = append(includes, func(p string) bool { | ||
// Handle absolute paths referencing the project directory. | ||
p = strings.TrimPrefix(p, wd) | ||
return strings.HasPrefix(filepath.Clean(p), pb.String()) | ||
}) | ||
} | ||
return includes | ||
} | ||
|
||
// IsInclude checks if path passes any filter in funcs. | ||
func (funcs IncludeFuncs) IsInclude(path string) bool { | ||
for _, f := range funcs { | ||
if f(path) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.