feat: [CDE-332]: remove unused and duplicate templateID gitspaces (#2884)

* feat: [CDE-332]: remove unused and duplicate templateID gitspaces
* 

feat: [CDE-332]: remove unused and duplicate templateID gitspaces
* 

feat: [CDE-332]: remove unused and duplicate templateID gitspaces
devcontainer-setup
Ansuman Satapathy 2024-10-28 13:04:17 +00:00 committed by Harness
parent f94bc6b462
commit 0d84fa85ff
3 changed files with 32 additions and 42 deletions

View File

@ -38,18 +38,17 @@ type CreateInput struct {
}
type ResourceInput struct {
Identifier string `json:"identifier" yaml:"identifier"`
Name string `json:"name" yaml:"name"`
InfraProviderType enum.InfraProviderType `json:"infra_provider_type" yaml:"infra_provider_type"`
CPU *string `json:"cpu" yaml:"cpu"`
Memory *string `json:"memory" yaml:"memory"`
Disk *string `json:"disk" yaml:"disk"`
Network *string `json:"network" yaml:"network"`
Region []string `json:"region" yaml:"region"`
Metadata map[string]string `json:"metadata" yaml:"metadata"`
GatewayHost *string `json:"gateway_host" yaml:"gateway_host"`
GatewayPort *string `json:"gateway_port" yaml:"gateway_port"`
TemplateIdentifier *string `json:"template_identifier" yaml:"template_identifier"`
Identifier string `json:"identifier" yaml:"identifier"`
Name string `json:"name" yaml:"name"`
InfraProviderType enum.InfraProviderType `json:"infra_provider_type" yaml:"infra_provider_type"`
CPU *string `json:"cpu" yaml:"cpu"`
Memory *string `json:"memory" yaml:"memory"`
Disk *string `json:"disk" yaml:"disk"`
Network *string `json:"network" yaml:"network"`
Region []string `json:"region" yaml:"region"`
Metadata map[string]string `json:"metadata" yaml:"metadata"`
GatewayHost *string `json:"gateway_host" yaml:"gateway_host"`
GatewayPort *string `json:"gateway_port" yaml:"gateway_port"`
}
type TemplateInput struct {

View File

@ -46,8 +46,7 @@ const (
ipreso_disk,
ipreso_network,
ipreso_region,
ipreso_opentofu_params,
ipreso_infra_provider_template_id
ipreso_opentofu_params
`
infraProviderResourceSelectColumns = "ipreso_id," + infraProviderResourceInsertColumns
infraProviderResourceTable = `infra_provider_resources`
@ -66,7 +65,6 @@ type infraProviderResource struct {
Network null.String `db:"ipreso_network"`
Region string `db:"ipreso_region"` // need list maybe
OpenTofuParams []byte `db:"ipreso_opentofu_params"`
TemplateID null.Int `db:"ipreso_infra_provider_template_id"`
Created int64 `db:"ipreso_created"`
Updated int64 `db:"ipreso_updated"`
}
@ -168,7 +166,6 @@ func (s infraProviderResourceStore) Create(
infraProviderResource.Network,
infraProviderResource.Region,
jsonBytes,
infraProviderResource.TemplateID,
).
Suffix(ReturningClause + infraProviderResourceIDColumn)
sql, args, err := stmt.ToSql()
@ -233,8 +230,8 @@ func (s infraProviderResourceStore) DeleteByIdentifier(ctx context.Context, spac
func mapToInfraProviderResource(_ context.Context,
in *infraProviderResource) (*types.InfraProviderResource, error) {
openTofuParamsMap := make(map[string]string)
marshalErr := json.Unmarshal(in.OpenTofuParams, &openTofuParamsMap)
metadataParamsMap := make(map[string]string)
marshalErr := json.Unmarshal(in.OpenTofuParams, &metadataParamsMap)
if marshalErr != nil {
return nil, marshalErr
}
@ -250,8 +247,7 @@ func mapToInfraProviderResource(_ context.Context,
Disk: in.Disk.Ptr(),
Network: in.Network.Ptr(),
Region: in.Region,
Metadata: openTofuParamsMap,
TemplateID: in.TemplateID.Ptr(),
Metadata: metadataParamsMap,
Created: in.Created,
Updated: in.Updated,
}, nil
@ -275,7 +271,6 @@ func (s infraProviderResourceStore) mapToInternalInfraProviderResource(_ context
Network: null.StringFromPtr(in.Network),
Region: in.Region,
OpenTofuParams: jsonBytes,
TemplateID: null.IntFromPtr(in.TemplateID),
Created: in.Created,
Updated: in.Updated,
}, nil
@ -330,7 +325,7 @@ func (i InfraProviderResourceView) FindMany(ctx context.Context, ids []int64) ([
stmt := database.Builder.
Select(infraProviderResourceSelectColumns).
From(infraProviderResourceTable).
Where(squirrel.Eq{infraProviderTemplateIDColumn: ids})
Where(squirrel.Eq{infraProviderResourceIDColumn: ids})
sql, args, err := stmt.ToSql()
if err != nil {

View File

@ -32,26 +32,22 @@ type InfraProviderConfig struct {
}
type InfraProviderResource struct {
ID int64 `json:"-"`
UID string `json:"identifier"`
Name string `json:"name"`
InfraProviderConfigID int64 `json:"-"`
InfraProviderConfigIdentifier string `json:"config_identifier"`
CPU *string `json:"cpu"`
Memory *string `json:"memory"`
Disk *string `json:"disk"`
Network *string `json:"network"`
Region string `json:"region"`
Metadata map[string]string `json:"metadata"`
// Deprecated. Set template identifier in Metadata.
TemplateID *int64 `json:"-"`
// Deprecated. Set template identifier in Metadata.
TemplateIdentifier *string `json:"template_identifier"`
SpaceID int64 `json:"-"`
SpacePath string `json:"space_path"`
InfraProviderType enum.InfraProviderType `json:"infra_provider_type"`
Created int64 `json:"created"`
Updated int64 `json:"updated"`
ID int64 `json:"-"`
UID string `json:"identifier"`
Name string `json:"name"`
InfraProviderConfigID int64 `json:"-"`
InfraProviderConfigIdentifier string `json:"config_identifier"`
CPU *string `json:"cpu"`
Memory *string `json:"memory"`
Disk *string `json:"disk"`
Network *string `json:"network"`
Region string `json:"region"`
Metadata map[string]string `json:"metadata"`
SpaceID int64 `json:"-"`
SpacePath string `json:"space_path"`
InfraProviderType enum.InfraProviderType `json:"infra_provider_type"`
Created int64 `json:"created"`
Updated int64 `json:"updated"`
}
func (i *InfraProviderResource) Identifier() int64 {