Skip to content

Commit

Permalink
fix: deleted json tags from models
Browse files Browse the repository at this point in the history
  • Loading branch information
ArshiaBP committed Dec 26, 2024
1 parent 5a0364d commit 1b7b81f
Show file tree
Hide file tree
Showing 16 changed files with 1,068 additions and 272 deletions.
292 changes: 259 additions & 33 deletions pkg/sdk/es/resources_clients.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/sdk/runable/steampipe_es_client_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func main() {
type {{ .Name }} struct {
ResourceID string ` + "`json:\"resource_id\"`" + `
PlatformID string ` + "`json:\"platform_id\"`" + `
Description {{ .IntegrationType }}.{{ .Name }}Description ` + "`json:\"description\"`" + `
Description {{ .IntegrationType }}.{{ .Name }}Description ` + "`json:\"Description\"`" + `
Metadata {{ .IntegrationType }}.Metadata ` + "`json:\"metadata\"`" + `
DescribedBy string ` + "`json:\"described_by\"`" + `
ResourceType string ` + "`json:\"resource_type\"`" + `
Expand Down
32 changes: 24 additions & 8 deletions provider/describer/blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ func GetBlueprint(ctx context.Context, handler *RenderAPIHandler, resourceID str
ID: blueprint.ID,
Name: blueprint.Name,
Description: JSONAllFieldsMarshaller{
Value: blueprint,
Value: model.BlueprintDescription{
ID: blueprint.ID,
Name: blueprint.Name,
Status: blueprint.Status,
AutoSync: blueprint.AutoSync,
Repo: blueprint.Repo,
Branch: blueprint.Branch,
LastSync: blueprint.LastSync,
},
},
}
return &value, nil
}

func processBlueprints(ctx context.Context, handler *RenderAPIHandler, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var blueprints []model.BlueprintDescription
var blueprints []model.BlueprintJSON
var blueprintListResponse []model.BlueprintResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/blueprints"
Expand Down Expand Up @@ -110,13 +118,21 @@ func processBlueprints(ctx context.Context, handler *RenderAPIHandler, renderCha
}
for _, blueprint := range blueprints {
wg.Add(1)
go func(blueprint model.BlueprintDescription) {
go func(blueprint model.BlueprintJSON) {
defer wg.Done()
value := models.Resource{
ID: blueprint.ID,
Name: blueprint.Name,
Description: JSONAllFieldsMarshaller{
Value: blueprint,
Value: model.BlueprintDescription{
ID: blueprint.ID,
Name: blueprint.Name,
Status: blueprint.Status,
AutoSync: blueprint.AutoSync,
Repo: blueprint.Repo,
Branch: blueprint.Branch,
LastSync: blueprint.LastSync,
},
},
}
renderChan <- value
Expand All @@ -125,8 +141,8 @@ func processBlueprints(ctx context.Context, handler *RenderAPIHandler, renderCha
return nil
}

func processBlueprint(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.ProjectDescription, error) {
var project model.ProjectDescription
func processBlueprint(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.BlueprintJSON, error) {
var blueprint model.BlueprintJSON
var resp *http.Response
baseURL := "https://api.render.com/v1/blueprints/"

Expand All @@ -144,7 +160,7 @@ func processBlueprint(ctx context.Context, handler *RenderAPIHandler, resourceID
}
defer resp.Body.Close()

if e = json.NewDecoder(resp.Body).Decode(&project); e != nil {
if e = json.NewDecoder(resp.Body).Decode(&blueprint); e != nil {
return nil, fmt.Errorf("failed to decode response: %w", e)
}
return resp, e
Expand All @@ -154,5 +170,5 @@ func processBlueprint(ctx context.Context, handler *RenderAPIHandler, resourceID
if err != nil {
return nil, fmt.Errorf("error during request handling: %w", err)
}
return &project, nil
return &blueprint, nil
}
25 changes: 22 additions & 3 deletions provider/describer/deploys.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ListDeploys(ctx context.Context, handler *RenderAPIHandler, stream *models.
}

func processDeploys(ctx context.Context, handler *RenderAPIHandler, serviceID string, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var deploys []model.DeployDescription
var deploys []model.DeployJSON
var deployListResponse []model.DeployResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/services/"
Expand Down Expand Up @@ -100,13 +100,32 @@ func processDeploys(ctx context.Context, handler *RenderAPIHandler, serviceID st
}
for _, deploy := range deploys {
wg.Add(1)
go func(deploy model.DeployDescription) {
go func(deploy model.DeployJSON) {
defer wg.Done()
commit := model.Commit{
ID: deploy.Commit.ID,
Message: deploy.Commit.Message,
CreatedAt: deploy.Commit.CreatedAt,
}
image := model.Image{
Ref: deploy.Image.Ref,
SHA: deploy.Image.SHA,
RegistryCredential: deploy.Image.RegistryCredential,
}
value := models.Resource{
ID: deploy.ID,
Name: deploy.Status,
Description: JSONAllFieldsMarshaller{
Value: deploy,
Value: model.DeployDescription{
ID: deploy.ID,
Commit: commit,
Image: image,
Status: deploy.Status,
Trigger: deploy.Trigger,
FinishedAt: deploy.FinishedAt,
CreatedAt: deploy.CreatedAt,
UpdatedAt: deploy.UpdatedAt,
},
},
}
renderChan <- value
Expand Down
28 changes: 22 additions & 6 deletions provider/describer/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ func GetDisk(ctx context.Context, handler *RenderAPIHandler, resourceID string)
ID: disk.ID,
Name: disk.Name,
Description: JSONAllFieldsMarshaller{
Value: disk,
Value: model.DiskDescription{
ID: disk.ID,
Name: disk.Name,
SizeGB: disk.SizeGB,
MountPath: disk.MountPath,
ServiceID: disk.ServiceID,
CreatedAt: disk.CreatedAt,
UpdatedAt: disk.UpdatedAt,
},
},
}
return &value, nil
}

func processDisks(ctx context.Context, handler *RenderAPIHandler, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var disks []model.DiskDescription
var disks []model.DiskJSON
var diskListResponse []model.DiskResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/disks"
Expand Down Expand Up @@ -110,13 +118,21 @@ func processDisks(ctx context.Context, handler *RenderAPIHandler, renderChan cha
}
for _, disk := range disks {
wg.Add(1)
go func(disk model.DiskDescription) {
go func(disk model.DiskJSON) {
defer wg.Done()
value := models.Resource{
ID: disk.ID,
Name: disk.Name,
Description: JSONAllFieldsMarshaller{
Value: disk,
Value: model.DiskDescription{
ID: disk.ID,
Name: disk.Name,
SizeGB: disk.SizeGB,
MountPath: disk.MountPath,
ServiceID: disk.ServiceID,
CreatedAt: disk.CreatedAt,
UpdatedAt: disk.UpdatedAt,
},
},
}
renderChan <- value
Expand All @@ -125,8 +141,8 @@ func processDisks(ctx context.Context, handler *RenderAPIHandler, renderChan cha
return nil
}

func processDisk(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.DiskDescription, error) {
var disk model.DiskDescription
func processDisk(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.DiskJSON, error) {
var disk model.DiskJSON
var resp *http.Response
baseURL := "https://api.render.com/v1/disks/"

Expand Down
44 changes: 38 additions & 6 deletions provider/describer/env_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,34 @@ func GetEnvGroup(ctx context.Context, handler *RenderAPIHandler, resourceID stri
if err != nil {
return nil, err
}
var serviceLinks []model.ServiceLink
for _, serviceLink := range envGroup.ServiceLinks {
serviceLinks = append(serviceLinks, model.ServiceLink{
ID: serviceLink.ID,
Name: serviceLink.Name,
Type: serviceLink.Type,
})
}
value := models.Resource{
ID: envGroup.ID,
Name: envGroup.Name,
Description: JSONAllFieldsMarshaller{
Value: envGroup,
Value: model.EnvGroupDescription{
ID: envGroup.ID,
Name: envGroup.Name,
OwnerID: envGroup.OwnerID,
CreatedAt: envGroup.CreatedAt,
UpdatedAt: envGroup.UpdatedAt,
ServiceLinks: serviceLinks,
EnvironmentID: envGroup.EnvironmentID,
},
},
}
return &value, nil
}

func processEnvGroups(ctx context.Context, handler *RenderAPIHandler, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var envGroups []model.EnvGroupDescription
var envGroups []model.EnvGroupJSON
var envGroupResp []model.EnvGroupResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/env-groups"
Expand Down Expand Up @@ -110,13 +126,29 @@ func processEnvGroups(ctx context.Context, handler *RenderAPIHandler, renderChan
}
for _, envGroup := range envGroups {
wg.Add(1)
go func(envGroup model.EnvGroupDescription) {
go func(envGroup model.EnvGroupJSON) {
defer wg.Done()
var serviceLinks []model.ServiceLink
for _, serviceLink := range envGroup.ServiceLinks {
serviceLinks = append(serviceLinks, model.ServiceLink{
ID: serviceLink.ID,
Name: serviceLink.Name,
Type: serviceLink.Type,
})
}
value := models.Resource{
ID: envGroup.ID,
Name: envGroup.Name,
Description: JSONAllFieldsMarshaller{
Value: envGroup,
Value: model.EnvGroupDescription{
ID: envGroup.ID,
Name: envGroup.Name,
OwnerID: envGroup.OwnerID,
CreatedAt: envGroup.CreatedAt,
UpdatedAt: envGroup.UpdatedAt,
ServiceLinks: serviceLinks,
EnvironmentID: envGroup.EnvironmentID,
},
},
}
renderChan <- value
Expand All @@ -125,8 +157,8 @@ func processEnvGroups(ctx context.Context, handler *RenderAPIHandler, renderChan
return nil
}

func processEnvGroup(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.EnvGroupDescription, error) {
var envGroup model.EnvGroupDescription
func processEnvGroup(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.EnvGroupJSON, error) {
var envGroup model.EnvGroupJSON
var resp *http.Response
baseURL := "https://api.render.com/v1/env-groups/"

Expand Down
30 changes: 24 additions & 6 deletions provider/describer/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,23 @@ func GetEnvironment(ctx context.Context, handler *RenderAPIHandler, resourceID s
ID: environment.ID,
Name: environment.Name,
Description: JSONAllFieldsMarshaller{
Value: environment,
Value: model.EnvironmentDescription{
ID: environment.ID,
Name: environment.Name,
ProjectID: resourceID,
DatabasesIDs: environment.DatabasesIDs,
RedisIDs: environment.RedisIDs,
ServiceIDs: environment.ServiceIDs,
EnvGroupIDs: environment.EnvGroupIDs,
ProtectedStatus: environment.ProtectedStatus,
},
},
}
return &value, nil
}

func processEnvironments(ctx context.Context, handler *RenderAPIHandler, projectID string, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var environments []model.EnvironmentDescription
var environments []model.EnvironmentJSON
var environmentListResponse []model.EnvironmentResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/environments"
Expand Down Expand Up @@ -117,13 +126,22 @@ func processEnvironments(ctx context.Context, handler *RenderAPIHandler, project
}
for _, environment := range environments {
wg.Add(1)
go func(environment model.EnvironmentDescription) {
go func(environment model.EnvironmentJSON) {
defer wg.Done()
value := models.Resource{
ID: environment.ID,
Name: environment.Name,
Description: JSONAllFieldsMarshaller{
Value: environment,
Value: model.EnvironmentDescription{
ID: environment.ID,
Name: environment.Name,
ProjectID: projectID,
DatabasesIDs: environment.DatabasesIDs,
RedisIDs: environment.RedisIDs,
ServiceIDs: environment.ServiceIDs,
EnvGroupIDs: environment.EnvGroupIDs,
ProtectedStatus: environment.ProtectedStatus,
},
},
}
renderChan <- value
Expand All @@ -132,8 +150,8 @@ func processEnvironments(ctx context.Context, handler *RenderAPIHandler, project
return nil
}

func processEnvironment(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.EnvironmentDescription, error) {
var environment model.EnvironmentDescription
func processEnvironment(ctx context.Context, handler *RenderAPIHandler, resourceID string) (*model.EnvironmentJSON, error) {
var environment model.EnvironmentJSON
var resp *http.Response
baseURL := "https://api.render.com/v1/environments/"

Expand Down
11 changes: 8 additions & 3 deletions provider/describer/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ListHeaders(ctx context.Context, handler *RenderAPIHandler, stream *models.
}

func processHeaders(ctx context.Context, handler *RenderAPIHandler, serviceID string, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var headers []model.HeaderDescription
var headers []model.HeaderJSON
var headerListResponse []model.HeaderResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/services/"
Expand Down Expand Up @@ -102,13 +102,18 @@ func processHeaders(ctx context.Context, handler *RenderAPIHandler, serviceID st
}
for _, header := range headers {
wg.Add(1)
go func(header model.HeaderDescription) {
go func(header model.HeaderJSON) {
defer wg.Done()
value := models.Resource{
ID: header.ID,
Name: header.Name,
Description: JSONAllFieldsMarshaller{
Value: header,
Value: model.HeaderDescription{
ID: header.ID,
Path: header.Path,
Name: header.Name,
Value: header.Value,
},
},
}
renderChan <- value
Expand Down
15 changes: 12 additions & 3 deletions provider/describer/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ListJobs(ctx context.Context, handler *RenderAPIHandler, stream *models.Str
}

func processJobs(ctx context.Context, handler *RenderAPIHandler, serviceID string, renderChan chan<- models.Resource, wg *sync.WaitGroup) error {
var jobs []model.JobDescription
var jobs []model.JobJSON
var jobListResponse []model.JobResponse
var resp *http.Response
baseURL := "https://api.render.com/v1/services/"
Expand Down Expand Up @@ -101,13 +101,22 @@ func processJobs(ctx context.Context, handler *RenderAPIHandler, serviceID strin
}
for _, job := range jobs {
wg.Add(1)
go func(job model.JobDescription) {
go func(job model.JobJSON) {
defer wg.Done()
value := models.Resource{
ID: job.ID,
Name: job.Status,
Description: JSONAllFieldsMarshaller{
Value: job,
Value: model.JobDescription{
ID: job.ID,
ServiceID: serviceID,
StartCommand: job.StartCommand,
PlanID: job.PlanID,
Status: job.Status,
CreatedAt: job.CreatedAt,
StartedAt: job.StartedAt,
FinishedAt: job.FinishedAt,
},
},
}
renderChan <- value
Expand Down
Loading

0 comments on commit 1b7b81f

Please sign in to comment.