Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: code reference API #1395

Merged
merged 34 commits into from
Jan 22, 2025
Merged

feat: code reference API #1395

merged 34 commits into from
Jan 22, 2025

Conversation

Ubisoft-potato
Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato commented Dec 25, 2024

Partf of #888

Add Code Reference API

This PR adds new gRPC service endpoints and related message types for managing code references in the Bucketeer system.

Changes

New Service Endpoints

Added new CodeReferenceService with the following methods:

  • GetCodeReference
  • ListCodeReferences
  • CreateCodeReference
  • UpdateCodeReference
  • DeleteCodeReference

New Event Types

Added new event types for code reference operations:

  • CODE_REFERENCE_CREATED
  • CODE_REFERENCE_UPDATED
  • CODE_REFERENCE_DELETED

New Domain Events

Added corresponding domain event message types:

  • CodeReferenceCreatedEvent
  • CodeReferenceUpdatedEvent
  • CodeReferenceDeletedEvent

@Ubisoft-potato Ubisoft-potato force-pushed the feat-code-ref-table branch 2 times, most recently from c73147d to 762205c Compare December 31, 2024 04:54
@Ubisoft-potato Ubisoft-potato force-pushed the feat-code-ref-table branch 7 times, most recently from 53057e8 to 2929f7f Compare January 10, 2025 03:10
@Ubisoft-potato Ubisoft-potato force-pushed the feat-code-ref-table branch 2 times, most recently from 6264d91 to a4d5fe8 Compare January 13, 2025 02:11
@Ubisoft-potato Ubisoft-potato marked this pull request as ready for review January 13, 2025 04:59
@Ubisoft-potato Ubisoft-potato force-pushed the feat-code-ref-table branch 8 times, most recently from 9c810ff to 68f2265 Compare January 20, 2025 05:38
test/e2e/coderef/code_reference_test.go Outdated Show resolved Hide resolved
EnvironmentId: *environmentID,
}
_, err = client.GetCodeReference(context.Background(), getReq)
assert.Error(t, err) // Should return error as code reference is deleted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must check the response code in case the backend returns any other error than not found.

test/e2e/coderef/code_reference_test.go Show resolved Hide resolved
test/e2e/coderef/code_reference_test.go Show resolved Hide resolved
test/e2e/coderef/code_reference_test.go Show resolved Hide resolved
test/e2e/coderef/code_reference_test.go Show resolved Hide resolved
test/e2e/coderef/code_reference_test.go Show resolved Hide resolved
test/e2e/coderef/code_reference_test.go Outdated Show resolved Hide resolved
Comment on lines 233 to 261
id, err := uuid.NewUUID()
if err != nil {
s.logger.Error(
"Failed to generate uuid",
log.FieldsFromImcomingContext(ctx).AddFields(
zap.Error(err),
)...,
)
dt, err := statusInternal.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalize(locale.InternalServerError),
})
if err != nil {
return nil, statusInternal.Err()
}
return nil, dt.Err()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the UUID logic to the domain.NewCodeReference as we do for the other entities.

)
if err != nil {
s.logger.Error(
"Failed to update code reference",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Failed to update code reference",
"Failed to update code reference domain object",

// See the License for the specific language governing permissions and
// limitations under the License.

package v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is new, we don't need the v2.

Suggested change
package v2
package storage

return codeRefs, nextOffset, total, nil
}

func (s *codeReferenceStorage) DeleteCodeReference(ctx context.Context, id, environmentID string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are using UUID, we don't need the environment ID in the storage layer.

Suggested change
func (s *codeReferenceStorage) DeleteCodeReference(ctx context.Context, id, environmentID string) error {
func (s *codeReferenceStorage) DeleteCodeReference(ctx context.Context, id string) error {

Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work 🎉

@cre8ivejp cre8ivejp merged commit 6b2ae5f into main Jan 22, 2025
17 checks passed
@cre8ivejp cre8ivejp deleted the feat-code-ref-table branch January 22, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants