mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
entc/gen: keep internal feature-flags private (#3832)
This commit is contained in:
@@ -142,13 +142,14 @@ var (
|
|||||||
FeatureNamedEdges,
|
FeatureNamedEdges,
|
||||||
FeatureSnapshot,
|
FeatureSnapshot,
|
||||||
FeatureSchemaConfig,
|
FeatureSchemaConfig,
|
||||||
featureMultiSchema,
|
|
||||||
FeatureLock,
|
FeatureLock,
|
||||||
FeatureModifier,
|
FeatureModifier,
|
||||||
FeatureExecQuery,
|
FeatureExecQuery,
|
||||||
FeatureUpsert,
|
FeatureUpsert,
|
||||||
FeatureVersionedMigration,
|
FeatureVersionedMigration,
|
||||||
}
|
}
|
||||||
|
// allFeatures includes all public and private features.
|
||||||
|
allFeatures = append(AllFeatures, featureMultiSchema)
|
||||||
)
|
)
|
||||||
|
|
||||||
// FeatureStage describes the stage of the codegen feature.
|
// FeatureStage describes the stage of the codegen feature.
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ func generate(g *Graph) error {
|
|||||||
}
|
}
|
||||||
assets.add(filepath.Join(g.Config.Target, tmpl.Format), b.Bytes())
|
assets.add(filepath.Join(g.Config.Target, tmpl.Format), b.Bytes())
|
||||||
}
|
}
|
||||||
for _, f := range AllFeatures {
|
for _, f := range allFeatures {
|
||||||
if f.cleanup == nil || g.featureEnabled(f) {
|
if f.cleanup == nil || g.featureEnabled(f) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -979,7 +979,7 @@ func (Config) ModuleInfo() (m debug.Module) {
|
|||||||
// ...
|
// ...
|
||||||
// {{ end }}
|
// {{ end }}
|
||||||
func (c Config) FeatureEnabled(name string) (bool, error) {
|
func (c Config) FeatureEnabled(name string) (bool, error) {
|
||||||
for _, f := range AllFeatures {
|
for _, f := range allFeatures {
|
||||||
if name == f.Name {
|
if name == f.Name {
|
||||||
return c.featureEnabled(f), nil
|
return c.featureEnabled(f), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,18 +434,7 @@ func TestGraph_Gen(t *testing.T) {
|
|||||||
Storage: drivers[0],
|
Storage: drivers[0],
|
||||||
Templates: []*Template{external, skipped},
|
Templates: []*Template{external, skipped},
|
||||||
IDType: &field.TypeInfo{Type: field.TypeInt},
|
IDType: &field.TypeInfo{Type: field.TypeInt},
|
||||||
Features: []Feature{
|
Features: AllFeatures,
|
||||||
FeaturePrivacy,
|
|
||||||
FeatureIntercept,
|
|
||||||
FeatureEntQL,
|
|
||||||
FeatureNamedEdges,
|
|
||||||
FeatureSnapshot,
|
|
||||||
FeatureSchemaConfig,
|
|
||||||
FeatureLock,
|
|
||||||
FeatureModifier,
|
|
||||||
FeatureExecQuery,
|
|
||||||
FeatureUpsert,
|
|
||||||
},
|
|
||||||
}, schemas...)
|
}, schemas...)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.NotNil(graph)
|
require.NotNil(graph)
|
||||||
@@ -493,18 +482,7 @@ func TestGraph_Gen(t *testing.T) {
|
|||||||
Storage: drivers[0],
|
Storage: drivers[0],
|
||||||
Templates: []*Template{external, skipped},
|
Templates: []*Template{external, skipped},
|
||||||
IDType: &field.TypeInfo{Type: field.TypeInt},
|
IDType: &field.TypeInfo{Type: field.TypeInt},
|
||||||
Features: []Feature{
|
Features: AllFeatures,
|
||||||
FeaturePrivacy,
|
|
||||||
FeatureIntercept,
|
|
||||||
FeatureEntQL,
|
|
||||||
FeatureNamedEdges,
|
|
||||||
FeatureSnapshot,
|
|
||||||
FeatureSchemaConfig,
|
|
||||||
FeatureLock,
|
|
||||||
FeatureModifier,
|
|
||||||
FeatureExecQuery,
|
|
||||||
FeatureUpsert,
|
|
||||||
},
|
|
||||||
}, schemas...)
|
}, schemas...)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.NotNil(graph)
|
require.NotNil(graph)
|
||||||
|
|||||||
Reference in New Issue
Block a user