diff --git a/admin/database/database.go b/admin/database/database.go index 257202f1037..d0f1517a8b9 100644 --- a/admin/database/database.go +++ b/admin/database/database.go @@ -293,7 +293,7 @@ type DB interface { DeleteProjectVariables(ctx context.Context, projectID, environment string, vars []string) error FindProvisionerResourcesForDeployment(ctx context.Context, deploymentID string) ([]*ProvisionerResource, error) - FindProvisionerResourceByName(ctx context.Context, deploymentID, typ, name string) (*ProvisionerResource, error) + FindProvisionerResourceByTypeAndName(ctx context.Context, deploymentID, typ, name string) (*ProvisionerResource, error) InsertProvisionerResource(ctx context.Context, opts *InsertProvisionerResourceOptions) (*ProvisionerResource, error) UpdateProvisionerResource(ctx context.Context, id string, opts *UpdateProvisionerResourceOptions) (*ProvisionerResource, error) DeleteProvisionerResource(ctx context.Context, id string) error diff --git a/admin/database/postgres/postgres.go b/admin/database/postgres/postgres.go index 14da4b9f025..e5630fd5883 100644 --- a/admin/database/postgres/postgres.go +++ b/admin/database/postgres/postgres.go @@ -2232,7 +2232,7 @@ func (c *connection) FindProvisionerResourcesForDeployment(ctx context.Context, return c.provisionerResourcesFromDTOs(res) } -func (c *connection) FindProvisionerResourceByName(ctx context.Context, deploymentID, typ, name string) (*database.ProvisionerResource, error) { +func (c *connection) FindProvisionerResourceByTypeAndName(ctx context.Context, deploymentID, typ, name string) (*database.ProvisionerResource, error) { res := &provisionerResourceDTO{} err := c.getDB(ctx).QueryRowxContext(ctx, `SELECT * FROM provisioner_resources WHERE deployment_id = $1 AND "type" = $2 AND name = $3`, deploymentID, typ, name).StructScan(res) if err != nil { diff --git a/admin/deployments.go b/admin/deployments.go index 81181ea7cea..4e8e49978a2 100644 --- a/admin/deployments.go +++ b/admin/deployments.go @@ -505,7 +505,7 @@ func (s *Service) provisionRuntime(ctx context.Context, opts *provisionRuntimeOp } func (s *Service) findProvisionedRuntimeResource(ctx context.Context, deploymentID string) (*database.ProvisionerResource, bool, error) { - pr, err := s.DB.FindProvisionerResourceByName(ctx, deploymentID, string(provisioner.ResourceTypeRuntime), "") + pr, err := s.DB.FindProvisionerResourceByTypeAndName(ctx, deploymentID, string(provisioner.ResourceTypeRuntime), "") if err != nil { if errors.Is(err, database.ErrNotFound) { return nil, false, nil diff --git a/admin/provision.go b/admin/provision.go index 864846faba9..b0c659a3ab4 100644 --- a/admin/provision.go +++ b/admin/provision.go @@ -22,7 +22,7 @@ type ProvisionOptions struct { func (s *Service) Provision(ctx context.Context, opts *ProvisionOptions) (*database.ProvisionerResource, error) { // Attempt to find an existing provisioned resource - pr, err := s.DB.FindProvisionerResourceByName(ctx, opts.DeploymentID, string(opts.Type), opts.Name) + pr, err := s.DB.FindProvisionerResourceByTypeAndName(ctx, opts.DeploymentID, string(opts.Type), opts.Name) if err != nil && !errors.Is(err, database.ErrNotFound) { return nil, err } @@ -89,7 +89,7 @@ func (s *Service) Provision(ctx context.Context, opts *ProvisionOptions) (*datab } // The resource must have been created concurrently by another process, so we try to find it again. - pr, err = s.DB.FindProvisionerResourceByName(ctx, opts.DeploymentID, string(opts.Type), opts.Name) + pr, err = s.DB.FindProvisionerResourceByTypeAndName(ctx, opts.DeploymentID, string(opts.Type), opts.Name) if err != nil { return nil, fmt.Errorf("failed to find expected provisioner resource: %w", err) } diff --git a/admin/server/provision.go b/admin/server/provision.go index eed08a4ec36..eb9a924b117 100644 --- a/admin/server/provision.go +++ b/admin/server/provision.go @@ -49,7 +49,7 @@ func (s *Server) Provision(ctx context.Context, req *adminv1.ProvisionRequest) ( } // If the resource is OK, return it immediately. - res, err := s.admin.DB.FindProvisionerResourceByName(ctx, depl.ID, req.Type, req.Name) + res, err := s.admin.DB.FindProvisionerResourceByTypeAndName(ctx, depl.ID, req.Type, req.Name) if err != nil && !errors.Is(err, database.ErrNotFound) { return nil, err }