1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
package gen
import (
"os"
"path/filepath"
)
var (
// FeaturePrivacy provides a feature-flag for the privacy extension for ent.
FeaturePrivacy = Feature{
Name: "privacy",
Stage: Alpha,
Default: false,
Description: "Privacy provides a privacy layer for ent through the schema configuration",
cleanup: func(c *Config) error {
return os.RemoveAll(filepath.Join(c.Target, "privacy"))
},
}
// FeatureEntQL provides a feature-flag for the entql extension for ent.
FeatureEntQL = Feature{
Name: "entql",
Stage: Experimental,
Default: false,
Description: "EntQL provides a generic filtering capability at runtime",
cleanup: func(c *Config) error {
return os.RemoveAll(filepath.Join(c.Target, "entql.go"))
},
}
// FeatureSnapshot stores a snapshot of ent/schema and auto-solve merge-conflict (issue #852).
FeatureSnapshot = Feature{
Name: "schema/snapshot",
Stage: Experimental,
Default: false,
Description: "Schema snapshot stores a snapshot of ent/schema and auto-solve merge-conflict (issue #852)",
cleanup: func(c *Config) error {
return os.RemoveAll(filepath.Join(c.Target, "internal"))
},
}
// AllFeatures holds a list of all feature-flags.
AllFeatures = []Feature{
FeaturePrivacy,
FeatureEntQL,
FeatureSnapshot,
}
)
// FeatureStage describes the stage of the codegen feature.
type FeatureStage int
const (
_ FeatureStage = iota
// Experimental features are in development, and actively being tested in the
// integration environment.
Experimental
// Alpha features are features whose initial development was finished, tested
// on the infra of the ent team, but we expect breaking-changes to their APIs.
Alpha
// Beta features are Alpha features that were added to the entgo.io
// documentation, and no breaking-changes are expected for them.
Beta
// Stable features are Beta features that were running for a while on ent
// infra.
Stable
)
// A Feature of the ent codegen.
type Feature struct {
// Name of the feature.
Name string
// Stage of the feature.
Stage FeatureStage
// Default values indicates if this feature is enabled by default.
Default bool
// A Description of this feature.
Description string
// cleanup used to cleanup all changes when a feature-flag is removed.
// e.g. delete files from previous codegen runs.
cleanup func(*Config) error
}
|