Skip to content

Commit

Permalink
Merge pull request #27 from eclipse/fix/genEsModule
Browse files Browse the repository at this point in the history
fix: genEsModule sets type enum on fields which uses a enum type
  • Loading branch information
veith committed Jun 13, 2022
2 parents 80a6217 + 054c016 commit 6d1014c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion furo/cmd/root.go
Expand Up @@ -50,7 +50,7 @@ Modify your default flow in the .furo config file to your needs. You can set any
Run: func(cmd *cobra.Command, args []string) {
runner.Run(cmd, args)
},
Version: "1.36.0",
Version: "1.36.1",
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
2 changes: 1 addition & 1 deletion furo/flow_test.go
Expand Up @@ -18,7 +18,7 @@ func TestRunCommand(t *testing.T) {
rco.Execute()

require.Equal(t, true, test.FileExist(path.Join(dir, ".furo")))
require.Equal(t, "1d5bc788b2dddab1c7cc1e3e62e6682e", test.MustMd5Sum(path.Join(dir, ".furo")))
require.Equal(t, "f5dfacb251ad443ddd69f569b36665b0", test.MustMd5Sum(path.Join(dir, ".furo")))

os.Args = []string{"cmd", "install"}
rco.Execute()
Expand Down
2 changes: 1 addition & 1 deletion furo/init_test.go
Expand Up @@ -18,6 +18,6 @@ func TestInitCommand(t *testing.T) {
rco.Execute()

require.Equal(t, true, test.FileExist(path.Join(dir, ".furo")))
require.Equal(t, "1d5bc788b2dddab1c7cc1e3e62e6682e", test.MustMd5Sum(path.Join(dir, ".furo")))
require.Equal(t, "f5dfacb251ad443ddd69f569b36665b0", test.MustMd5Sum(path.Join(dir, ".furo")))

}
2 changes: 1 addition & 1 deletion furo/installer_test.go
Expand Up @@ -18,7 +18,7 @@ func TestInstallCommand(t *testing.T) {
rco.Execute()

require.Equal(t, true, test.FileExist(path.Join(dir, ".furo")))
require.Equal(t, "1d5bc788b2dddab1c7cc1e3e62e6682e", test.MustMd5Sum(path.Join(dir, ".furo")))
require.Equal(t, "f5dfacb251ad443ddd69f569b36665b0", test.MustMd5Sum(path.Join(dir, ".furo")))

os.Args = []string{"cmd", "install"}
rco.Execute()
Expand Down
9 changes: 8 additions & 1 deletion furo/internal/cmd/genEsModule/genEsModule.go
Expand Up @@ -51,17 +51,24 @@ func Run(cmd *cobra.Command, args []string) {

field.Meta.Options.Flags = append(field.Meta.Options.Flags, "enum")
// loop all enum values to build the options
isenum := false
for enum := allTypes[field.Type].Values.Oldest(); enum != nil; enum = enum.Next() {
option := map[string]interface{}{}
option["display_name"] = strings.ToLower("enum." + field.Type + "." + enum.Key.(string) + ".label")
option["id"] = enum.Value.(*int32)
option["@type"] = "type.googleapis.com/furo.Optionitem"
option["selected"] = false
field.Meta.Options.List = append(field.Meta.Options.List, &option)
isenum = true
}

// fmt.Println(k, allTypes[field.Type].Values)
// set the type on the field to enum
if isenum {
field.Meta.Typespecific = &map[string]interface{}{"enum": field.Type}
field.Type = "enum"
}
}

}
}

Expand Down
6 changes: 3 additions & 3 deletions furo/spec2muSpec_test.go
Expand Up @@ -47,9 +47,9 @@ func TestSpec2muSpecCommand(t *testing.T) {
require.Equal(t, true, test.FileExist(path.Join(dir, "muspecs")))

// initial were 2 files in muspec, spec2Muspec creates one file per spec, so we have 4 files now
require.Equal(t, "f9456cc68a2b69691d5cbca5a7fcb5aa", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "Sample.types.yaml")))
require.Equal(t, "102b3562851cc4bac750b6d409344f6e", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "SampleCollection.types.yaml")))
require.Equal(t, "cecdceb48471dc1b2ebc958ce30e97bb", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "SampleEntity.types.yaml")))
require.Equal(t, "6e90ff428e600c214b2d54b649f3e29f", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "Sample.types.yaml")))
require.Equal(t, "cbbcb8c070aebbaf7d7db052c77065cf", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "SampleCollection.types.yaml")))
require.Equal(t, "744327bcc82804c191f9c85c0d2f37be", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "SampleEntity.types.yaml")))
require.Equal(t, "32ab721229ebbea7fe4fc42bc4a34a1a", test.MustMd5Sum(path.Join(dir, "muspecs", "sample", "Samples.services.yaml")))

}

0 comments on commit 6d1014c

Please sign in to comment.