entc/gen: keep internal feature-flags private (#3832)

This commit is contained in:
Ariel Mashraki
2023-11-16 09:39:27 +02:00
committed by GitHub
parent 77eedb01dd
commit 4640d8e0ec
3 changed files with 6 additions and 27 deletions

View File

@@ -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.

View File

@@ -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
} }

View File

@@ -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)