Skip to content

Commit 657b0ed

Browse files
author
jmccormick2001
committed
update the load command to check the path of the load-config in the CLI, also do more checking on the apiserver side of the yaml structure
1 parent bc4774b commit 657b0ed

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

apiserver/loadservice/loadconfig.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ func (c *LoadConfig) validate() error {
6666
return err
6767
}
6868

69-
func (c *LoadConfig) getConf(yamlFile *bytes.Buffer) *LoadConfig {
69+
func (c *LoadConfig) getConf(yamlFile *bytes.Buffer) (*LoadConfig, error) {
7070

7171
err := yaml.Unmarshal(yamlFile.Bytes(), c)
7272
if err != nil {
73-
log.Fatalf("Unmarshal: %v", err)
73+
log.Errorf("Unmarshal: %v", err)
74+
return c, err
7475
}
7576

76-
return c
77+
return c, err
7778
}
7879

7980
func (c *LoadConfig) print() {

apiserver/loadservice/loadimpl.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ func Load(request *msgs.LoadRequest) msgs.LoadResponse {
6868
LoadConfigTemplate := loadJobTemplateFields{}
6969

7070
var LoadCfg LoadConfig
71-
LoadCfg.getConf(bytes.NewBufferString(request.LoadConfig))
71+
_, err = LoadCfg.getConf(bytes.NewBufferString(request.LoadConfig))
72+
if err != nil {
73+
resp.Status.Code = msgs.Error
74+
resp.Status.Msg = err.Error()
75+
return resp
76+
}
7277

7378
err = LoadCfg.validate()
7479
if err != nil {

examples/load/sample-json-load-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
COImagePrefix: crunchydata
2-
COImageTag: rhel7-3.5.0-rc5
2+
COImageTag: centos7-3.5.0-rc8
33
DbDatabase: userdb
44
DbUser: postgres
55
DbPort: 5432

pgo/cmd/load.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ func createLoad(args []string) {
7777
}
7878

7979
buf, err := ioutil.ReadFile(LoadConfig)
80+
if err != nil {
81+
fmt.Println("Error: " + err.Error())
82+
os.Exit(2)
83+
}
84+
8085
request := msgs.LoadRequest{}
8186
request.LoadConfig = string(buf)
8287
request.Selector = Selector

0 commit comments

Comments
 (0)