Skip to content

Commit

Permalink
Merge pull request #11 from ADorigi/fix-run-jobs
Browse files Browse the repository at this point in the history
fix: fix get job-details
  • Loading branch information
artaasadi authored Sep 16, 2024
2 parents 718aa92 + 4902db8 commit f823e75
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 12 deletions.
62 changes: 50 additions & 12 deletions cmd/get/job_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package get
import (
"encoding/json"
"fmt"
"github.com/adorigi/checkctl/pkg/types"
"io"
"net/http"

"github.com/adorigi/checkctl/pkg/config"
"github.com/adorigi/checkctl/pkg/request"
"github.com/adorigi/checkctl/pkg/types"
"github.com/adorigi/checkctl/pkg/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -71,21 +71,59 @@ var jobDetailsCmd = &cobra.Command{
return nil
}

var job types.GetComplianceJobStatusResponse
err = json.Unmarshal(body, &job)
if err != nil {
return err
}
switch jobType {
case "compliance":
var job types.GetComplianceJobStatusResponse
err = json.Unmarshal(body, &job)
if err != nil {
return err
}

if outputFormat == "table" {
fmt.Println("Table view not supported, use json view: --output json")
//TODO
} else {
js, err := json.MarshalIndent(job, "", " ")
if outputFormat == "table" {
fmt.Println("Table view not supported, use json view: --output json")
//TODO
} else {
js, err := json.MarshalIndent(job, "", " ")
if err != nil {
return err
}
fmt.Print(string(js))
}
case "discovery":
var job types.GetDescribeJobStatusResponse
err = json.Unmarshal(body, &job)
if err != nil {
return err
}
fmt.Print(string(js))

if outputFormat == "table" {
fmt.Println("Table view not supported, use json view: --output json")
//TODO
} else {
js, err := json.MarshalIndent(job, "", " ")
if err != nil {
return err
}
fmt.Print(string(js))
}
case "analytics":
var job types.GetAnalyticsJobStatusResponse
err = json.Unmarshal(body, &job)
if err != nil {
return err
}

if outputFormat == "table" {
fmt.Println("Table view not supported, use json view: --output json")
//TODO
} else {
js, err := json.MarshalIndent(job, "", " ")
if err != nil {
return err
}
fmt.Print(string(js))
}

}

return nil
Expand Down
17 changes: 17 additions & 0 deletions pkg/types/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ type ListJobsByTypeItem struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

type GetDescribeJobStatusResponse struct {
JobId uint `json:"job_id"`
IntegrationInfo IntegrationInfo `json:"integration_info"`
JobStatus string `json:"job_status"`
DiscoveryType string `json:"discovery_type"`
ResourceType string `json:"resource_type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

type GetAnalyticsJobStatusResponse struct {
JobId uint `json:"job_id"`
JobStatus string `json:"job_status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

0 comments on commit f823e75

Please sign in to comment.