diff --git a/README.md b/README.md index 22c0ecb..6c0263f 100644 --- a/README.md +++ b/README.md @@ -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: @@ -106,8 +107,6 @@ lint: enabled: true allowDraft: false allowCELHooks: false - legacyPermission: - enabled: true stateflow: deprecatedFeature: enabled: true @@ -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 @@ -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 diff --git a/config/config.go b/config/config.go index b2487cd..20998c3 100644 --- a/config/config.go +++ b/config/config.go @@ -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"` } diff --git a/tailor/helper_test.go b/tailor/helper_test.go index 942e82a..3cdf0eb 100644 --- a/tailor/helper_test.go +++ b/tailor/helper_test.go @@ -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, }, diff --git a/tailor/lint.go b/tailor/lint.go index 1b10b6e..7ef66c4 100644 --- a/tailor/lint.go +++ b/tailor/lint.go @@ -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", }) } } diff --git a/tailor/lint_test.go b/tailor/lint_test.go index 2062b92..13899b2 100644 --- a/tailor/lint_test.go +++ b/tailor/lint_test.go @@ -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{ @@ -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{ @@ -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",