-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hasura/release/v0.2.0
Add support for native queries and aggregation by nested fields
- Loading branch information
Showing
45 changed files
with
2,030 additions
and
745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ go.work.sum | |
|
||
# codegen assets | ||
.codegen/ | ||
ndc-elasticsearch | ||
ndc-elasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"os" | ||
"encoding/json" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/hasura/ndc-elasticsearch/internal" | ||
"github.com/hasura/ndc-elasticsearch/types" | ||
) | ||
|
||
const ConfigFileName = "configuration.json" | ||
|
||
// initialize creates a configuration file at the specified path. | ||
func initialize(configPath string) error { | ||
configFilePath := filepath.Join(configPath, ConfigFileName) | ||
file, err := os.Create(configFilePath) | ||
// initializeConfig creates a configuration file at the specified path. | ||
// It returns an error if the configuration file already exists. | ||
// It creates an empty configuration file with "indices" and "queries" fields. | ||
func initializeConfig(path string) error { | ||
configPath := filepath.Join(path, ConfigFileName) | ||
|
||
// Return an error if the configuration file already exists | ||
if internal.FileExists(configPath) { | ||
return fmt.Errorf("configuration file already exists at %s", configPath) | ||
} | ||
|
||
// Create an empty configuration file | ||
config := types.Configuration{ | ||
Indices: make(map[string]interface{}), | ||
Queries: make(map[string]types.NativeQuery), | ||
} | ||
|
||
data, err := json.MarshalIndent(config, "", " ") | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to marshal JSON: %w", err) | ||
} | ||
defer file.Close() | ||
return nil | ||
|
||
// Write the configuration file | ||
err = internal.WriteJsonFile(configPath, data) | ||
return err | ||
} |
Oops, something went wrong.