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
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ The metrics command outputs detailed JSON data about your workspace resources.
Patterner uses a `.patterner.yml` file for configuration. The configuration includes various lint rules for different Tailor Platform components:

```yaml
workspaceID: xxxxxxxXXxxxxxxxxxxxxx
lint:
pipeline:
deprecatedFeature:
Expand All @@ -106,8 +107,6 @@ lint:
enabled: true
allowDraft: false
allowCELHooks: false
legacyPermission:
enabled: true
stateflow:
deprecatedFeature:
enabled: true
Expand All @@ -116,12 +115,13 @@ lint:
### Lint Rules

#### Pipeline Rules
- **deprecatedFeature** - Identify deprecated features including legacy script/validation patterns and recommend modern alternatives
- **deprecatedFeature** - Identify deprecated features and promote modern alternatives
- `enabled` (default: true) - Enable/disable deprecated feature detection
- `allowCELScript` (default: false) - Allow CEL script usage in pipelines
- `allowDraft` (default: false) - Allow draft resources in pipeline configurations
- `allowStateFlow` (default: false) - Allow StateFlow resources in pipeline configurations
- Detects legacy script patterns (`pre_validation`, `pre_script`, `post_script`, `post_validation`) and recommends modern hook alternatives (`pre_hook`, `post_hook`)
- Detects deprecated patterns and recommends modern Pipeline alternatives
- 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
Expand All @@ -134,13 +134,14 @@ lint:
- `allowDraft` (default: false) - Allow draft resources in TailorDB configurations
- `allowCELHooks` (default: false) - Allow CEL hook usage in TailorDB configurations
- Detects deprecated patterns and recommends modern TailorDB alternatives
- https://docs.tailor.tech/reference/service-lifecycle-policy
- Enabled by default to promote migration away from deprecated features
- **legacyPermission** - Identify legacy permission patterns

#### StateFlow Rules
- **deprecatedFeature** - Identify deprecated StateFlow features and promote modern alternatives
- `enabled` (default: true) - Enable/disable deprecated feature detection
- Detects deprecated StateFlow patterns and recommends modern alternatives
- https://docs.tailor.tech/reference/service-lifecycle-policy
- Enabled by default to promote migration away from deprecated features

## Command Reference
Expand Down
9 changes: 2 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,12 @@ type QueryBeforeMutation struct {

type TailorDB struct {
DeprecatedFeature TailorDBDeprecatedFeature `yaml:"deprecatedFeature,omitempty,omitzero"`
LegacyPermission LegacyPermission `yaml:"legacyPermission,omitempty,omitzero"`
}

type TailorDBDeprecatedFeature struct {
Enabled bool `default:"true" yaml:"enabled,omitempty"`
AllowDraft bool `default:"false" yaml:"allowDraft,omitempty"`
AllowCELHooks bool `default:"false" yaml:"allowCELHooks,omitempty"`
}

type LegacyPermission struct {
Enabled bool `default:"true" yaml:"enabled,omitempty"`
AllowDraft bool `default:"false" yaml:"allowDraft,omitempty"`
AllowCELHooks bool `default:"false" yaml:"allowCELHooks,omitempty"`
AllowTypePermission bool `default:"false" yaml:"allowTypePermission,omitempty"`
AllowRecordPermission bool `default:"false" yaml:"allowRecordPermission,omitempty"`
}
Expand Down
7 changes: 2 additions & 5 deletions tailor/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ func createTestConfig(t *testing.T) *config.Config {
Lint: config.Lint{
TailorDB: config.TailorDB{
DeprecatedFeature: config.TailorDBDeprecatedFeature{
Enabled: true,
AllowDraft: false,
AllowCELHooks: false,
},
LegacyPermission: config.LegacyPermission{
Enabled: true,
AllowDraft: false,
AllowCELHooks: false,
AllowTypePermission: false,
AllowRecordPermission: false,
},
Expand Down
11 changes: 4 additions & 7 deletions tailor/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,18 @@ func (c *Client) Lint(resources *Resources) ([]*LintWarn, error) {
Message: "Draft feature is deprecated",
})
}
}

if c.cfg.Lint.TailorDB.LegacyPermission.Enabled {
if !c.cfg.Lint.TailorDB.LegacyPermission.AllowTypePermission && t.TypePermission != nil {
if !c.cfg.Lint.TailorDB.DeprecatedFeature.AllowTypePermission && t.TypePermission != nil {
warns = append(warns, &LintWarn{
Type: LintTargetTypeTailorDB,
Name: fmt.Sprintf("%s/%s", db.NamespaceName, t.Name),
Message: "Type-level permission is legacy. Use `Permission` or `GQLPermission` instead",
Message: "Type-level permission is deprecated. Use `Permission` or `GQLPermission` instead",
})
}
if !c.cfg.Lint.TailorDB.LegacyPermission.AllowRecordPermission && t.RecordPermission != nil {
if !c.cfg.Lint.TailorDB.DeprecatedFeature.AllowRecordPermission && t.RecordPermission != nil {
warns = append(warns, &LintWarn{
Type: LintTargetTypeTailorDB,
Name: fmt.Sprintf("%s/%s", db.NamespaceName, t.Name),
Message: "Record-level permission is legacy. Use `Permission` or `GQLPermission` instead",
Message: "Record-level permission is deprecated. Use `Permission` or `GQLPermission` instead",
})
}
}
Expand Down
12 changes: 6 additions & 6 deletions tailor/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func TestClient_Lint_TailorDB(t *testing.T) {
{
name: "legacy type permission warning",
configMod: func(c *config.Config) {
c.Lint.TailorDB.LegacyPermission.Enabled = true
c.Lint.TailorDB.LegacyPermission.AllowTypePermission = false
c.Lint.TailorDB.DeprecatedFeature.Enabled = true
c.Lint.TailorDB.DeprecatedFeature.AllowTypePermission = false
},
resources: &Resources{
TailorDBs: []*TailorDB{
Expand All @@ -142,13 +142,13 @@ func TestClient_Lint_TailorDB(t *testing.T) {
},
},
},
expectedMsgs: []string{"Type-level permission is legacy. Use `Permission` or `GQLPermission` instead"},
expectedMsgs: []string{"Type-level permission is deprecated. Use `Permission` or `GQLPermission` instead"},
},
{
name: "legacy record permission warning",
configMod: func(c *config.Config) {
c.Lint.TailorDB.LegacyPermission.Enabled = true
c.Lint.TailorDB.LegacyPermission.AllowRecordPermission = false
c.Lint.TailorDB.DeprecatedFeature.Enabled = true
c.Lint.TailorDB.DeprecatedFeature.AllowRecordPermission = false
},
resources: &Resources{
TailorDBs: []*TailorDB{
Expand All @@ -163,7 +163,7 @@ func TestClient_Lint_TailorDB(t *testing.T) {
},
},
},
expectedMsgs: []string{"Record-level permission is legacy. Use `Permission` or `GQLPermission` instead"},
expectedMsgs: []string{"Record-level permission is deprecated. Use `Permission` or `GQLPermission` instead"},
},
{
name: "CEL hooks deprecated warning",
Expand Down