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

add agent data source #456

Merged
merged 23 commits into from Aug 11, 2022
Merged

add agent data source #456

merged 23 commits into from Aug 11, 2022

Conversation

laurenolivia
Copy link
Contributor

@laurenolivia laurenolivia commented Jul 6, 2022

Description

This PR adds a new datasource to the Client. The purpose is to allow users to Read, List agents. Please see the Agent Pool and Agents documentation, linked below, for more information.

Please be aware that this PR downloads the tfc-agent binary, which only supports Linux AMD64 architecture.

Testing plan

  1. Checkout this branch
  2. Ensure you have an existing agent pool (Org -> Settings -> Agent Pool)
  3. Ensure you have an agent pool token
  4. Create an agent
  5. Make an API call to read, list an agent

-- or --

  1. With the required architecture
  2. Run the test command noted, below
  3. The test suite should pass ✅

External links

Output from tests

PASS
ok github.com/hashicorp/go-tfe

See example of how to run integration tests, below. Refer to TESTS.md for further details.

envchain tfe.local go test ./... -v -tags=integration -run TestAgents

...

agent.go Outdated Show resolved Hide resolved
@laurenolivia laurenolivia requested a review from a team as a code owner July 18, 2022 23:18
@laurenolivia laurenolivia marked this pull request as draft July 22, 2022 16:02
@laurenolivia laurenolivia force-pushed the laurenolivia/add-agent-data-source branch from 113e384 to 2c1cb2b Compare July 25, 2022 19:51
@laurenolivia laurenolivia marked this pull request as ready for review July 25, 2022 21:53
@laurenolivia laurenolivia force-pushed the laurenolivia/add-agent-data-source branch from 35977f5 to 84413bc Compare July 27, 2022 12:32
@laurenolivia laurenolivia force-pushed the laurenolivia/add-agent-data-source branch from 84413bc to cd5c837 Compare July 27, 2022 13:10
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

Some items for discussion down below ⬇️ . Great work so far 👍

agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
}

u := fmt.Sprintf("agents/%s", url.QueryEscape(agentID))
req, err := s.client.NewRequest("GET", u, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should pass options here instead of nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly another sign that this method isn't needed! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sebasslash 👍
@nfagerlund Can you elaborate on why it's a sign that the method, possibly, isn't needed❔

agent_integration_test.go Outdated Show resolved Hide resolved
agent_integration_test.go Outdated Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@nfagerlund nfagerlund left a comment

Choose a reason for hiding this comment

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

Impressive work! I think I spotted some stuff that isn't right, plus a few things that might not be intended.

agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
}

u := fmt.Sprintf("agents/%s", url.QueryEscape(agentID))
req, err := s.client.NewRequest("GET", u, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly another sign that this method isn't needed! 😄

agent.go Outdated Show resolved Hide resolved
agent_integration_test.go Outdated Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
helper_test.go Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
helper_test.go Show resolved Hide resolved
helper_test.go Show resolved Hide resolved
Copy link
Collaborator

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

Be sure to add this file to the mocks script and then generate mocks

agent.go Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
agent_integration_test.go Outdated Show resolved Hide resolved
agent_integration_test.go Outdated Show resolved Hide resolved
agent_integration_test.go Outdated Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
@brandonc brandonc dismissed stale reviews from nfagerlund and sebasslash August 10, 2022 18:19

outdated

@brandonc
Copy link
Collaborator

Tests passing 🎉

agent_integration_test.go Outdated Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

I made the change that I recommended and smoke tested it and it worked well. So close!

agent.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

giphy-2

@laurenolivia laurenolivia merged commit 3835095 into main Aug 11, 2022
@laurenolivia laurenolivia deleted the laurenolivia/add-agent-data-source branch August 11, 2022 17:13
@github-actions
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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.

None yet

5 participants