Skip to content

Commit

Permalink
fix: [CDE-192]: correctly set resources for infraprovider config. (ha…
Browse files Browse the repository at this point in the history
…rness#2524)

* fix: [CDE-192]: correctly set resources for infraprovider config.
  • Loading branch information
n00bitax authored and Harness committed Aug 16, 2024
1 parent 2ad02f1 commit eccb57f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/api/controller/gitspace/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *Controller) startGitspaceAction(
return err
}
if savedGitspaceInstance == nil || savedGitspaceInstance.State.IsFinalStatus() {
gitspaceInstance, err := c.createGitspaceInstance(config)
gitspaceInstance, err := c.buildGitspaceInstance(config)
if err != nil {
return err
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func (c *Controller) submitAsyncOps(
}()
}

func (c *Controller) createGitspaceInstance(config *types.GitspaceConfig) (*types.GitspaceInstance, error) {
func (c *Controller) buildGitspaceInstance(config *types.GitspaceConfig) (*types.GitspaceInstance, error) {
gitspaceMachineUser := defaultMachineUser
now := time.Now().UnixMilli()
suffixUID, err := gonanoid.Generate(allowedUIDAlphabet, 6)
Expand Down
1 change: 0 additions & 1 deletion app/services/gitspaceinfraevent/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func (s *Service) handleGitspaceInfraEvent(
default:
return fmt.Errorf("unknown event type: %s", event.Payload.Type)
}
instance.Updated = time.Now().UnixMilli()
err = s.gitspaceSvc.UpdateInstance(ctx, instance)
if err != nil {
return fmt.Errorf("failed to update gitspace instance: %w", err)
Expand Down
12 changes: 7 additions & 5 deletions app/services/infraprovider/infraprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ func (c *Service) Find(
infraProviderConfig.Identifier, err)
}
infraProviderConfig.SpacePath = space.Path
values := make([]types.InfraProviderResource, len(infraProviderConfig.Resources))
for i, ptr := range resources {
if ptr != nil {
values[i] = *ptr
if len(resources) > 0 {
providerResources := make([]types.InfraProviderResource, len(resources))
for i, resource := range resources {
if resource != nil {
providerResources[i] = *resource
}
}
infraProviderConfig.Resources = providerResources
}
infraProviderConfig.Resources = values
return infraProviderConfig, nil
}

Expand Down

0 comments on commit eccb57f

Please sign in to comment.