Skip to content

Commit 44b0fac

Browse files
authored
Merge pull request #5 from tailor-platform/deprecate-legacy-permission
fix: replace legacy permission support to deprecated
2 parents 599a976 + f14e2e7 commit 44b0fac

5 files changed

Lines changed: 20 additions & 30 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ The metrics command outputs detailed JSON data about your workspace resources.
8585
Patterner uses a `.patterner.yml` file for configuration. The configuration includes various lint rules for different Tailor Platform components:
8686

8787
```yaml
88+
workspaceID: xxxxxxxXXxxxxxxxxxxxxx
8889
lint:
8990
pipeline:
9091
deprecatedFeature:
@@ -106,8 +107,6 @@ lint:
106107
enabled: true
107108
allowDraft: false
108109
allowCELHooks: false
109-
legacyPermission:
110-
enabled: true
111110
stateflow:
112111
deprecatedFeature:
113112
enabled: true
@@ -116,12 +115,13 @@ lint:
116115
### Lint Rules
117116
118117
#### Pipeline Rules
119-
- **deprecatedFeature** - Identify deprecated features including legacy script/validation patterns and recommend modern alternatives
118+
- **deprecatedFeature** - Identify deprecated features and promote modern alternatives
120119
- `enabled` (default: true) - Enable/disable deprecated feature detection
121120
- `allowCELScript` (default: false) - Allow CEL script usage in pipelines
122121
- `allowDraft` (default: false) - Allow draft resources in pipeline configurations
123122
- `allowStateFlow` (default: false) - Allow StateFlow resources in pipeline configurations
124-
- Detects legacy script patterns (`pre_validation`, `pre_script`, `post_script`, `post_validation`) and recommends modern hook alternatives (`pre_hook`, `post_hook`)
123+
- Detects deprecated patterns and recommends modern Pipeline alternatives
124+
- https://docs.tailor.tech/reference/service-lifecycle-policy
125125
- Enabled by default to promote migration away from deprecated features
126126
- **insecureAuthorization** - Detect insecure authorization patterns
127127
- **stepLength** - Ensure pipeline steps don't exceed maximum length
@@ -134,13 +134,14 @@ lint:
134134
- `allowDraft` (default: false) - Allow draft resources in TailorDB configurations
135135
- `allowCELHooks` (default: false) - Allow CEL hook usage in TailorDB configurations
136136
- Detects deprecated patterns and recommends modern TailorDB alternatives
137+
- https://docs.tailor.tech/reference/service-lifecycle-policy
137138
- Enabled by default to promote migration away from deprecated features
138-
- **legacyPermission** - Identify legacy permission patterns
139139

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

146147
## Command Reference

config/config.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,12 @@ type QueryBeforeMutation struct {
5353

5454
type TailorDB struct {
5555
DeprecatedFeature TailorDBDeprecatedFeature `yaml:"deprecatedFeature,omitempty,omitzero"`
56-
LegacyPermission LegacyPermission `yaml:"legacyPermission,omitempty,omitzero"`
5756
}
5857

5958
type TailorDBDeprecatedFeature struct {
60-
Enabled bool `default:"true" yaml:"enabled,omitempty"`
61-
AllowDraft bool `default:"false" yaml:"allowDraft,omitempty"`
62-
AllowCELHooks bool `default:"false" yaml:"allowCELHooks,omitempty"`
63-
}
64-
65-
type LegacyPermission struct {
6659
Enabled bool `default:"true" yaml:"enabled,omitempty"`
60+
AllowDraft bool `default:"false" yaml:"allowDraft,omitempty"`
61+
AllowCELHooks bool `default:"false" yaml:"allowCELHooks,omitempty"`
6762
AllowTypePermission bool `default:"false" yaml:"allowTypePermission,omitempty"`
6863
AllowRecordPermission bool `default:"false" yaml:"allowRecordPermission,omitempty"`
6964
}

tailor/helper_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ func createTestConfig(t *testing.T) *config.Config {
1414
Lint: config.Lint{
1515
TailorDB: config.TailorDB{
1616
DeprecatedFeature: config.TailorDBDeprecatedFeature{
17-
Enabled: true,
18-
AllowDraft: false,
19-
AllowCELHooks: false,
20-
},
21-
LegacyPermission: config.LegacyPermission{
2217
Enabled: true,
18+
AllowDraft: false,
19+
AllowCELHooks: false,
2320
AllowTypePermission: false,
2421
AllowRecordPermission: false,
2522
},

tailor/lint.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,18 @@ func (c *Client) Lint(resources *Resources) ([]*LintWarn, error) {
4444
Message: "Draft feature is deprecated",
4545
})
4646
}
47-
}
48-
49-
if c.cfg.Lint.TailorDB.LegacyPermission.Enabled {
50-
if !c.cfg.Lint.TailorDB.LegacyPermission.AllowTypePermission && t.TypePermission != nil {
47+
if !c.cfg.Lint.TailorDB.DeprecatedFeature.AllowTypePermission && t.TypePermission != nil {
5148
warns = append(warns, &LintWarn{
5249
Type: LintTargetTypeTailorDB,
5350
Name: fmt.Sprintf("%s/%s", db.NamespaceName, t.Name),
54-
Message: "Type-level permission is legacy. Use `Permission` or `GQLPermission` instead",
51+
Message: "Type-level permission is deprecated. Use `Permission` or `GQLPermission` instead",
5552
})
5653
}
57-
if !c.cfg.Lint.TailorDB.LegacyPermission.AllowRecordPermission && t.RecordPermission != nil {
54+
if !c.cfg.Lint.TailorDB.DeprecatedFeature.AllowRecordPermission && t.RecordPermission != nil {
5855
warns = append(warns, &LintWarn{
5956
Type: LintTargetTypeTailorDB,
6057
Name: fmt.Sprintf("%s/%s", db.NamespaceName, t.Name),
61-
Message: "Record-level permission is legacy. Use `Permission` or `GQLPermission` instead",
58+
Message: "Record-level permission is deprecated. Use `Permission` or `GQLPermission` instead",
6259
})
6360
}
6461
}

tailor/lint_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ func TestClient_Lint_TailorDB(t *testing.T) {
126126
{
127127
name: "legacy type permission warning",
128128
configMod: func(c *config.Config) {
129-
c.Lint.TailorDB.LegacyPermission.Enabled = true
130-
c.Lint.TailorDB.LegacyPermission.AllowTypePermission = false
129+
c.Lint.TailorDB.DeprecatedFeature.Enabled = true
130+
c.Lint.TailorDB.DeprecatedFeature.AllowTypePermission = false
131131
},
132132
resources: &Resources{
133133
TailorDBs: []*TailorDB{
@@ -142,13 +142,13 @@ func TestClient_Lint_TailorDB(t *testing.T) {
142142
},
143143
},
144144
},
145-
expectedMsgs: []string{"Type-level permission is legacy. Use `Permission` or `GQLPermission` instead"},
145+
expectedMsgs: []string{"Type-level permission is deprecated. Use `Permission` or `GQLPermission` instead"},
146146
},
147147
{
148148
name: "legacy record permission warning",
149149
configMod: func(c *config.Config) {
150-
c.Lint.TailorDB.LegacyPermission.Enabled = true
151-
c.Lint.TailorDB.LegacyPermission.AllowRecordPermission = false
150+
c.Lint.TailorDB.DeprecatedFeature.Enabled = true
151+
c.Lint.TailorDB.DeprecatedFeature.AllowRecordPermission = false
152152
},
153153
resources: &Resources{
154154
TailorDBs: []*TailorDB{
@@ -163,7 +163,7 @@ func TestClient_Lint_TailorDB(t *testing.T) {
163163
},
164164
},
165165
},
166-
expectedMsgs: []string{"Record-level permission is legacy. Use `Permission` or `GQLPermission` instead"},
166+
expectedMsgs: []string{"Record-level permission is deprecated. Use `Permission` or `GQLPermission` instead"},
167167
},
168168
{
169169
name: "CEL hooks deprecated warning",

0 commit comments

Comments
 (0)