Commit graph

16 commits

Author SHA1 Message Date
Jenna Goldstrich
8dcd9fe1a5 Ensure org ID is set and move UploadSbom to api package 2025-01-21 16:57:50 -05:00
Jenna Goldstrich
cf6a82fae8 Make error less brittle to fix upcoming error with HCP SDK Go changing how we return 404 error 2025-01-21 11:33:32 -08:00
Jenna Goldstrich
078ad45860
HCP Packer Buckets: Change UpsertBucket to call GetBucket (#13059)
* Update UpsertBucket to first call GetBucket, this will allow bucket level role based authentication, as CreateBucket uses project level auth

* Fix one incorrect test failure message
2024-06-21 08:28:09 -07:00
Devashish
8e92027546 HPR-1537: Packer Core sends metadata to HCP Packer in UpdateBuild API (#12891) 2024-04-11 12:55:04 -04:00
Devashish
3fa637c608
Migrate HCP Packer to API V2 and new nomenclature changes (#12794)
* add hcp packer new nomenclature updates

* Update docs with nomenclature changes

* Update navigation bar links

* Bump github.com/hashicorp/hcp-sdk-go from 0.81.0 to 0.82.0

* fix acceptance test template

---------

Co-authored-by: sylviamoss <moss@hashicorp.com>
Co-authored-by: Wilken Rivera <dev@wilkenrivera.com>
2024-01-24 13:17:35 -05:00
Wilken Rivera
c245b1fb7c deps: Bump github.com/hashicorp/hcp-sdk-go to v0.73.0
* Updates cloud-resource-management API to use sable
* Removes duplicate imports of the same SDK packages
2023-11-15 10:27:51 -05:00
hashicorp-copywrite[bot]
19055df3ec
[COMPLIANCE] License changes (#12568)
* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at https://hashi.co/license-faq, and details of the license at www.hashicorp.com/bsl.

* Update copyright file headers to BUSL-1.1

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-10 15:53:29 -07:00
Wilken Rivera
60c66fdf9f Add additional validation for manually set project ids
When setting a project id via the HCP_PROJECT_ID env the client will try to validate the project
by checking that it has an associated registry. If the project is invalid or not a valid UUID an error
will be displayed to the user

* Add comment to clarify usage of SDK loaded env. variables
2023-07-25 11:31:39 -04:00
Wilken Rivera
38101a64c9 hcp: Add support for project level service principals
HCP supports two types of service principals: Organization-level and project-level.
When a user tries to publish to an active HCP Packer registry using a plsp the client
fails when configuring the client due to a API permission error; namely plsp do not have
the permissions to query an org for a list of projects. Setting the HCP_PROJECT_ID does
not resolve the issue because the call to ListProjects is still executed.

This changes updates the client configuration params to obtain both the HCP Organization and
Project IDs that will be used for connecting to the HCP Packer registry. With this change
if a user provides a project Id via the HCP_PROJECT_ID environment variable no call to ListProjects will
be made. Instead the value will be take as is and used to create the connection. A user connecting with
a project level service principals must provide a valid HCP_PROJECT_ID in order to connect.
2023-07-25 11:31:39 -04:00
hashicorp-copywrite[bot]
d563a3c623 [COMPLIANCE] Add Copyright and License Headers 2023-06-05 13:39:28 -04:00
Lucas Bajolet
925cb5e541 hcp: support HCP_PROJECT_ID environment variable
With HCP supporting multi-projects now, Packer needs to take it into
account when picking a project from an organisation.

This commit adds two cases:

1. multiple projects are defined, none is supplied through
   HCP_PROJECT_ID: in this case we will default to the oldest project
   defined for the organisation.

2. we supply HCP_PROJECT_ID: in this case, we pick the project with the
   corresponding ID, and use it for publishing metadata.
2023-06-01 14:39:09 -04:00
Wilken Rivera
eca75a6847 Run make fmt to fix checks 2023-04-27 15:17:31 -04:00
hashicorp-copywrite[bot]
b7df3ca36f
[COMPLIANCE] Add Copyright and License Headers (#12254)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-03-02 15:37:05 -05:00
Lucas Bajolet
6d0045607c hcp: record template type when creating iterations
In order to ensure users keep the same templates between two packer
invocations for a single iteration, we start tracking the type of
template used when building images.
2022-12-07 16:18:52 -05:00
Lucas Bajolet
08f1e85fb1 hcp: fix payloads for new SDK version
The grpc_gateway v2 changes had some repercussions in the payloads of
the API calls, making the current code non-functional against the latest
SDK.
2022-12-07 16:18:52 -05:00
Wilken Rivera
606e6c48f1 internal: reorganise registry/HCP code
This commit reorganises the code for both the registry/API and the
Orchestrator/Registry.

The main difference with the previous version is how stuff is exposed.
Now we only expose a Registry interface to the outside (previously named
Orchestrator), which has several implementations: null is the default,
and is returned if HCP is not enabled.

The other implementations being HCL/JSON, both private to the hcp
sub-package.

The api (previously `registry') is the set of functionality that
abstracts and calls the HCP API.
It was meant to be merged with the `hcp' package, but because of a
dependency loop with the datasources, both are separated for now.
2022-11-14 13:31:35 -05:00