mirror of https://github.com/harness/drone.git
feat: [CDE-202]: infra provider resource cache (#2639)
* feat: [CDE-202]: infra provider resource cache * feat: [CDE-202]: infra provider resource cacheCODE-2402
parent
5cfd41ae1a
commit
ec7eca7491
|
@ -40,7 +40,7 @@ func (c *Controller) Find(
|
|||
return nil, fmt.Errorf("failed to authorize: %w", err)
|
||||
}
|
||||
|
||||
res, err := c.gitspaceSvc.Find(ctx, space.ID, identifier)
|
||||
res, err := c.gitspaceSvc.Find(ctx, space.Path, identifier)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to find gitspace: %w", err)
|
||||
}
|
||||
|
|
|
@ -27,12 +27,16 @@ import (
|
|||
|
||||
func (c *Service) Find(
|
||||
ctx context.Context,
|
||||
spaceID int64,
|
||||
spaceRef string,
|
||||
identifier string,
|
||||
) (*types.GitspaceConfig, error) {
|
||||
var gitspaceConfigResult *types.GitspaceConfig
|
||||
txErr := c.tx.WithTx(ctx, func(ctx context.Context) error {
|
||||
gitspaceConfig, err := c.gitspaceConfigStore.FindByIdentifier(ctx, spaceID, identifier)
|
||||
space, err := c.spaceStore.FindByRef(ctx, spaceRef)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find space: %w", err)
|
||||
}
|
||||
gitspaceConfig, err := c.gitspaceConfigStore.FindByIdentifier(ctx, space.ID, identifier)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find gitspace config: %w", err)
|
||||
}
|
||||
|
@ -52,6 +56,7 @@ func (c *Service) Find(
|
|||
gitspaceConfig.State = enum.GitspaceStateUninitialized
|
||||
}
|
||||
gitspaceConfigResult = gitspaceConfig
|
||||
gitspaceConfig.SpacePath = space.Path
|
||||
return nil
|
||||
}, dbtx.TxDefaultReadOnly)
|
||||
if txErr != nil {
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s *Service) handleGitspaceInfraEvent(
|
|||
payload := event.Payload
|
||||
|
||||
config, fetchErr := s.getConfig(
|
||||
ctx, payload.Infra.SpaceID, payload.Infra.GitspaceConfigIdentifier)
|
||||
ctx, payload.Infra.SpacePath, payload.Infra.GitspaceConfigIdentifier)
|
||||
if fetchErr != nil {
|
||||
return fetchErr
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ func (s *Service) handleGitspaceInfraEvent(
|
|||
|
||||
func (s *Service) getConfig(
|
||||
ctx context.Context,
|
||||
spaceID int64,
|
||||
spaceRef string,
|
||||
identifier string,
|
||||
) (*types.GitspaceConfig, error) {
|
||||
config, err := s.gitspaceSvc.Find(ctx, spaceID, identifier)
|
||||
config, err := s.gitspaceSvc.Find(ctx, spaceRef, identifier)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"failed to find gitspace config during infra event handling, identifier %s: %w", identifier, err)
|
||||
|
|
Loading…
Reference in New Issue