Skip to content

Initial Client and Config class for tfe#5

Merged
taru-garg-2000 merged 7 commits into
mainfrom
taru-garg-hashicorp/client
Aug 27, 2025
Merged

Initial Client and Config class for tfe#5
taru-garg-2000 merged 7 commits into
mainfrom
taru-garg-hashicorp/client

Conversation

@taru-garg-2000

Copy link
Copy Markdown
Contributor

Description

Initial Client and Config class for tfe

Testing plan

Unit tests added

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

Rollback Plan

Changes to Security Controls

@taru-garg-2000 taru-garg-2000 requested a review from a team as a code owner August 26, 2025 13:10
Comment thread tfe/config.py
self.address = f"https://{host}"
else:
self.address = DEFAULT_ADDRESS

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey why don't we check here if the string is actually a valid URL? Add a validator here.

@taru-garg-2000 taru-garg-2000 requested a review from Copilot August 26, 2025 17:41

This comment was marked as outdated.

@taru-garg-2000 taru-garg-2000 marked this pull request as draft August 26, 2025 17:54
@taru-garg-2000 taru-garg-2000 requested a review from Copilot August 27, 2025 06:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the foundational Client and Config classes for the python-tfe library, replacing a placeholder implementation with a production-ready API client structure.

  • Implements a comprehensive Config class with environment variable support and validation
  • Creates a Client class that fetches API metadata and provides cloud/enterprise detection
  • Restructures the project from src/python_tfe to tfe package layout

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tfe/config.py New Config class with environment variable handling, token management, and validation
tfe/client.py New Client class with API metadata fetching and instance type detection
tfe/init.py Updates exports to use new Client and Config classes
tests/units/test_config.py Comprehensive unit tests for Config class functionality
tests/units/test_client.py Unit tests for Client class with mocked HTTP responses
tests/test_client.py Removes old placeholder test file
src/python_tfe/client.py Removes old placeholder client implementation
pyproject.toml Updates package structure and adds new dev dependencies
Makefile Updates source directory reference and test verbosity

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread tfe/config.py
Comment thread pyproject.toml
Comment thread pyproject.toml
@taru-garg-2000 taru-garg-2000 marked this pull request as ready for review August 27, 2025 06:56

@mukulmohan177 mukulmohan177 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good

@@ -1,17 +1 @@
"""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I noticed that the tests for the client were removed in this PR, but no new tests were added for the new Client class. Can you explain the reasoning behind removing these tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I had just moved the tests around, so earlier the tests were in /tests however later i moved them to /tests/units

Comment thread tests/units/test_config.py Outdated
assert cfg.base_path == config.DEFAULT_BASE_PATH
assert cfg.registry_base_path == config.DEFAULT_REGISTRY_PATH
assert cfg.token is None
assert cfg.token == ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One thing to keep in mind is our code must consistently treat "" as “missing.”

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it will be better to say not cfg.token for anything we add like this so it is consistent

@taru-garg-2000 taru-garg-2000 merged commit 901eee8 into main Aug 27, 2025
11 checks passed
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.

3 participants