Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bd26101

Browse files
committedJul 26, 2024·
remove unused Post and PostDataReadings in Venafi Connection mode
1 parent a941e17 commit bd26101

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed
 

‎pkg/client/client_venconn.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,19 @@ func (c *VenConnClient) PostDataReadingsWithOptions(readings []*api.DataReading,
175175
return nil
176176
}
177177

178-
// Post performs an HTTP POST request.
179-
func (c *VenConnClient) Post(path string, body io.Reader) (*http.Response, error) {
180-
_, token, err := c.connHandler.Get(context.Background(), c.installNS, auth.Scope{}, types.NamespacedName{Name: c.venConnName, Namespace: c.venConnNS})
181-
if err != nil {
182-
return nil, fmt.Errorf("while loading the VenafiConnection %s/%s: %w", c.venConnNS, c.venConnName, err)
183-
}
184-
185-
req, err := http.NewRequest(http.MethodPost, fullURL(c.baseURL, path), body)
186-
if err != nil {
187-
return nil, err
188-
}
189-
190-
req.Header.Set("Content-Type", "application/json")
191-
192-
if len(token.BearerToken) > 0 {
193-
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token.BearerToken))
194-
}
178+
// PostDataReadings isn't implemented for Venafi Cloud. This is because Venafi
179+
// Cloud needs a `clusterName` and `clusterDescription`, but this function can
180+
// only pass `orgID` and `clusterID` which are both useless in Venafi Cloud. Use
181+
// PostDataReadingsWithOptions instead.
182+
func (c *VenConnClient) PostDataReadings(_orgID, _clusterID string, readings []*api.DataReading) error {
183+
return fmt.Errorf("programmer mistake: PostDataReadings is not implemented for Venafi Cloud")
184+
}
195185

196-
return c.client.Do(req)
186+
// Post isn't implemented for Venafi Cloud because /v1/tlspk/upload/clusterdata
187+
// requires using the query parameters `name` and `description` which can't be
188+
// set using Post. Use PostDataReadingsWithOptions instead.
189+
func (c *VenConnClient) Post(path string, body io.Reader) (*http.Response, error) {
190+
return nil, fmt.Errorf("programmer mistake: Post is not implemented for Venafi Cloud")
197191
}
198192

199193
func loadRESTConfig(path string) (*rest.Config, error) {

0 commit comments

Comments
 (0)
Please sign in to comment.