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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ lint:
allowStateFlow: false
insecureAuthorization:
enabled: false
stepLength:
stepCount:
enabled: true
max: 30
multipleMutations:
Expand Down Expand Up @@ -208,7 +208,7 @@ lint:
- https://docs.tailor.tech/reference/service-lifecycle-policy
- Enabled by default to promote migration away from deprecated features
- **insecureAuthorization** - Detect insecure authorization patterns
- **stepLength** - Ensure pipeline steps don't exceed maximum length
- **stepCount** - Ensure pipeline steps don't exceed maximum count
- **multipleMutations** - Identify multiple mutations in a single operation
- **queryBeforeMutation** - Check for queries before mutations

Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Rules struct {
type Pipeline struct {
DeprecatedFeature PipelineDeprecatedFeature `yaml:"deprecatedFeature,omitempty,omitzero"`
InsecureAuthorization InsecureAuthorization `yaml:"insecureAuthorization,omitempty,omitzero"`
StepLength StepLength `yaml:"stepLength,omitempty,omitzero"`
StepCount StepCount `yaml:"stepCount,omitempty,omitzero"`
MultipleMutations MultipleMutations `yaml:"multipleMutations,omitempty,omitzero"`
QueryBeforeMutation QueryBeforeMutation `yaml:"queryBeforeMutation,omitempty,omitzero"`
}
Expand All @@ -43,7 +43,7 @@ type InsecureAuthorization struct {
Enabled bool `default:"true" yaml:"enabled,omitempty"`
}

type StepLength struct {
type StepCount struct {
Enabled bool `default:"true" yaml:"enabled,omitempty"`
Max int `default:"30" yaml:"max,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion tailor/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func createTestConfig(t *testing.T) *config.Config {
InsecureAuthorization: config.InsecureAuthorization{
Enabled: true,
},
StepLength: config.StepLength{
StepCount: config.StepCount{
Enabled: true,
Max: 10,
},
Expand Down
8 changes: 4 additions & 4 deletions tailor/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ func (c *Client) Lint(resources *Resources) ([]*LintWarn, error) {
})
}

stepLength := len(r.Steps)
// Pipeline/StepLength
if c.cfg.Lint.Rules.Pipeline.StepLength.Enabled && stepLength > c.cfg.Lint.Rules.Pipeline.StepLength.Max {
stepCount := len(r.Steps)
// Pipeline/StepCount
if c.cfg.Lint.Rules.Pipeline.StepCount.Enabled && stepCount > c.cfg.Lint.Rules.Pipeline.StepCount.Max {
warns = append(warns, &LintWarn{
Type: LintTargetTypePipeline,
Name: fmt.Sprintf("%s/%s", p.NamespaceName, r.Name),
Message: fmt.Sprintf("resolver has too many steps (%d > %d)", stepLength, c.cfg.Lint.Rules.Pipeline.StepLength.Max),
Message: fmt.Sprintf("resolver has too many steps (%d > %d)", stepCount, c.cfg.Lint.Rules.Pipeline.StepCount.Max),
})
}

Expand Down
4 changes: 2 additions & 2 deletions tailor/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ func TestClient_Lint_Pipeline(t *testing.T) {
{
name: "step length warning",
configMod: func(c *config.Config) {
c.Lint.Rules.Pipeline.StepLength.Enabled = true
c.Lint.Rules.Pipeline.StepLength.Max = 1
c.Lint.Rules.Pipeline.StepCount.Enabled = true
c.Lint.Rules.Pipeline.StepCount.Max = 1
},
resources: &Resources{
Pipelines: []*Pipeline{
Expand Down