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

feat: allow scanning for all changed flags #79

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ This action does not support monorepos or searching for flags across LaunchDarkl
| environment-key | LaunchDarkly environment key for creating flag links | `false` | production |
| placeholder-comment | Comment on PR when no flags are found. If flags are found in later commits, this comment will be updated. | `false` | false |
| include-archived-flags | Scan for archived flags | `false` | true |
| max-flags | Maximum number of flags to find per PR | `false` | 5 |
| max-flags | Maximum number of flags to find per PR. Set to `-1` to find all changed flags. | `false` | 5 |
| base-uri | The base URI for the LaunchDarkly server. Most users should use the default value. | `false` | https://app.launchdarkly.com |
<!-- action-docs-inputs -->

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inputs:
required: false
default: 'true'
max-flags:
description: Maximum number of flags to find per PR
description: Maximum number of flags to find per PR. Set to `-1` to find all changed flags.
required: false
default: '5'
base-uri:
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func ValidateInputandParse(ctx context.Context) (*Config, error) {
return nil, err
}
config.MaxFlags = int(maxFlags)
if config.MaxFlags == 0 || config.MaxFlags < -1 {
return nil, errors.New("`max-flags` must be a positive integer or -1 to search for all changed flags")
}

if placholderComment, err := strconv.ParseBool(os.Getenv("INPUT_PLACEHOLDER-COMMENT")); err == nil {
// ignore error - default is false
Expand Down
5 changes: 4 additions & 1 deletion flags/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func NewReferenceBuilder(max int) *ReferenceBuilder {
}

func (b *ReferenceBuilder) MaxReferences() bool {
return len(b.foundFlags) >= b.max
if b.max > 0 {
return len(b.foundFlags) >= b.max
}
return false
}

func (b *ReferenceBuilder) AddReference(flagKey string, op diff_util.Operation, aliases []string) error {
Expand Down