-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement validate #40
Conversation
WalkthroughThe changes introduce a new method Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant JiraAPI
participant Connector
Client->>JiraAPI: GET /myself
JiraAPI-->>Client: User Info
Connector->>Client: Validate
Client->>Connector: Call Myself
Connector-->>Client: Validation Result
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
pkg/connector/connector.go (1)
49-49
: Approve the changes with minor suggestions.The modification to the
Validate
method is a good improvement. It now actually tests the Jira client's ability to make an API call, which aligns with the PR objective of ensuring the connector is properly configured and has a valid personal access token.Consider the following minor improvements:
- Add some logging before and after the API call for better observability.
- Consider returning a non-nil
Annotations
object with additional information about the validation process.Example implementation:
func (d *Connector) Validate(ctx context.Context) (annotations.Annotations, error) { log.Println("Validating Jira connector...") _, err := d.jiraClient.Myself(ctx) if err != nil { log.Printf("Validation failed: %v", err) return nil, fmt.Errorf("failed to validate Jira connector: %w", err) } log.Println("Jira connector validated successfully") return annotations.Annotations{ "status": "validated", "method": "Myself", }, nil }This implementation provides more context and improves error handling and observability.
pkg/client/client.go (1)
674-685
: Implement aValidate
method usingMyself
The new
Myself
method (or the suggestedGetCurrentUser
method) can be used to implement theValidate
method mentioned in the PR objectives. This method can check if the client is properly configured and has a valid personal access token.Here's a suggested implementation for a
Validate
method:func (client *Client) Validate(ctx context.Context) error { _, err := client.GetCurrentUser(ctx) if err != nil { return fmt.Errorf("failed to validate client: %w", err) } return nil }This method attempts to get the current user information. If successful, it confirms that the client is properly configured and authenticated. If you'd like me to implement this method or open a GitHub issue for tracking this task, please let me know.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- pkg/client/client.go (2 hunks)
- pkg/connector/connector.go (1 hunks)
🔇 Additional comments (1)
pkg/client/client.go (1)
80-80
: LGTM: Constant addition formyself
endpointThe new constant
myself
is correctly defined and follows the existing naming convention for API endpoints in this file. It represents the Jira API endpoint for retrieving information about the authenticated user.
Pull Request
To help us get this pull request reviewed and merged quickly, please be sure to include the following items:
PR Type
What kind of change does this PR introduce?
Backward Compatibility
Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the Connector in any way?
Useful links:
Issue Linking
What's new?
Validate
method to ensure that the connector is properly configured and has a valid personal access tokenSummary by CodeRabbit
New Features
Bug Fixes