@@ -21,18 +21,17 @@ import (
2121 "io/ioutil"
2222 "path/filepath"
2323
24+ "github.com/gojektech/feast/cli/feast/pkg/parse"
2425 "github.com/gojektech/feast/go-feast-proto/feast/core"
2526
26- "feast/cli/feast/pkg/parse"
27-
2827 "github.com/spf13/cobra"
2928)
3029
31- // registerCmd represents the register command
32- var registerCmd = & cobra.Command {
33- Use : "register [resource] [filepaths...]" ,
34- Short : "Register a resource given one or many yaml files." ,
35- Long : `Register a resource from one or multiple yamls.
30+ // applyCmd represents the apply command
31+ var applyCmd = & cobra.Command {
32+ Use : "apply [resource] [filepaths...]" ,
33+ Short : "Apply a resource given one or many yaml files." ,
34+ Long : `Apply a resource from one or multiple yamls.
3635
3736Valid resources include:
3837- entity
@@ -41,17 +40,17 @@ Valid resources include:
4140- storage
4241
4342Examples:
44- - feast register entity entity.yml
45- - feast register storage storage1.yml storage2.yml
46- - feast register feature *-feature.yml` ,
43+ - feast apply entity entity.yml
44+ - feast apply storage storage1.yml storage2.yml
45+ - feast apply feature *-feature.yml` ,
4746 RunE : func (cmd * cobra.Command , args []string ) error {
4847 if len (args ) == 0 {
4948 return cmd .Help ()
5049 }
5150
5251 if len (args ) < 2 {
5352 fmt .Println (args )
54- return errors .New ("invalid number of arguments for register command" )
53+ return errors .New ("invalid number of arguments for apply command" )
5554 }
5655
5756 initConn ()
@@ -62,75 +61,75 @@ Examples:
6261
6362 for _ , fp := range paths {
6463 if isYaml (fp ) {
65- fmt .Printf ("Registering %s at %s\n " , resource , fp )
66- regID , err := register (ctx , coreCli , resource , fp )
64+ fmt .Printf ("Applying %s at %s\n " , resource , fp )
65+ regID , err := apply (ctx , coreCli , resource , fp )
6766 if err != nil {
68- return fmt .Errorf ("failed to register %s at path %s: %v" , resource , fp , err )
67+ return fmt .Errorf ("failed to apply %s at path %s: %v" , resource , fp , err )
6968 }
70- fmt .Printf ("Successfully registered %s %s\n " , resource , regID )
69+ fmt .Printf ("Successfully applied %s %s\n " , resource , regID )
7170 }
7271 }
7372 return nil
7473 },
7574}
7675
7776func init () {
78- rootCmd .AddCommand (registerCmd )
77+ rootCmd .AddCommand (applyCmd )
7978}
8079
81- func register (ctx context.Context , coreCli core.CoreServiceClient , resource string , fileLocation string ) (string , error ) {
80+ func apply (ctx context.Context , coreCli core.CoreServiceClient , resource string , fileLocation string ) (string , error ) {
8281 yml , err := ioutil .ReadFile (fileLocation )
8382 if err != nil {
8483 return "" , fmt .Errorf ("error reading file at %s: %v" , fileLocation , err )
8584 }
8685
8786 switch resource {
8887 case "feature" :
89- return registerFeature (ctx , coreCli , yml )
88+ return applyFeature (ctx , coreCli , yml )
9089 case "featureGroup" :
91- return registerFeatureGroup (ctx , coreCli , yml )
90+ return applyFeatureGroup (ctx , coreCli , yml )
9291 case "entity" :
93- return registerEntity (ctx , coreCli , yml )
92+ return applyEntity (ctx , coreCli , yml )
9493 case "storage" :
95- return registerStorage (ctx , coreCli , yml )
94+ return applyStorage (ctx , coreCli , yml )
9695 default :
9796 return "" , fmt .Errorf ("invalid resource %s: please choose one of [feature, featureGroup, entity, storage]" , resource )
9897 }
9998}
10099
101- func registerFeature (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
100+ func applyFeature (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
102101 fs , err := parse .YamlToFeatureSpec (yml )
103102 if err != nil {
104103 return "" , err
105104 }
106- _ , err = coreCli .RegisterFeature (ctx , fs )
105+ _ , err = coreCli .ApplyFeature (ctx , fs )
107106 return fs .GetId (), err
108107}
109108
110- func registerFeatureGroup (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
109+ func applyFeatureGroup (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
111110 fgs , err := parse .YamlToFeatureGroupSpec (yml )
112111 if err != nil {
113112 return "" , err
114113 }
115- _ , err = coreCli .RegisterFeatureGroup (ctx , fgs )
114+ _ , err = coreCli .ApplyFeatureGroup (ctx , fgs )
116115 return fgs .GetId (), err
117116}
118117
119- func registerEntity (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
118+ func applyEntity (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
120119 es , err := parse .YamlToEntitySpec (yml )
121120 if err != nil {
122121 return "" , err
123122 }
124- _ , err = coreCli .RegisterEntity (ctx , es )
123+ _ , err = coreCli .ApplyEntity (ctx , es )
125124 return es .GetName (), err
126125}
127126
128- func registerStorage (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
127+ func applyStorage (ctx context.Context , coreCli core.CoreServiceClient , yml []byte ) (string , error ) {
129128 ss , err := parse .YamlToStorageSpec (yml )
130129 if err != nil {
131130 return "" , err
132131 }
133- _ , err = coreCli .RegisterStorage (ctx , ss )
132+ _ , err = coreCli .ApplyStorage (ctx , ss )
134133 return ss .GetId (), err
135134}
136135
0 commit comments