Merge BYOW GA branch to main (#2398)
* feat(workers): Add ability to read and reinitialize cert authority (#2312) * feat(workers): Return Release Version on worker list and read (#2377) * feat(cli): Read and reinitialize worker certificate authority (#2387)
This commit is contained in:
1 parent
cee5ff7599
commit
18dff62b7b
50 files changed
+2401
-462
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// Code generated by "make api"; DO NOT EDIT.
|
||||
package workers
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Certificate struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
PublicKeySha256 string `json:"public_key_sha256,omitempty"`
|
||||
NotBeforeTime time.Time `json:"not_before_time,omitempty"`
|
||||
NotAfterTime time.Time `json:"not_after_time,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code generated by "make api"; DO NOT EDIT.
|
||||
package workers
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/boundary/api"
|
||||
)
|
||||
|
||||
type CertificateAuthority struct {
|
||||
Certs []*Certificate `json:"certs,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
type CertificateAuthorityReadResult struct {
|
||||
Item *CertificateAuthority
|
||||
response *api.Response
|
||||
}
|
||||
|
||||
func (n CertificateAuthorityReadResult) GetItem() *CertificateAuthority {
|
||||
return n.Item
|
||||
}
|
||||
|
||||
func (n CertificateAuthorityReadResult) GetResponse() *api.Response {
|
||||
return n.response
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package workers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type CertificateAuthorityReinitializeResult = CertificateAuthorityReadResult
|
||||
|
||||
func (c *Client) ReinitializeCA(ctx context.Context, scopeId string, opt ...Option) (*CertificateAuthorityReinitializeResult, error) {
|
||||
if scopeId == "" {
|
||||
return nil, fmt.Errorf("empty scopeId value passed into ReinitializeCA request")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
|
||||
if c.client == nil {
|
||||
return nil, fmt.Errorf("nil client")
|
||||
}
|
||||
opts.queryMap["scope_id"] = scopeId
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "POST", "workers:reinitialize-certificate-authority", nil, apiOpts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating ReinitializeCA request: %w", err)
|
||||
}
|
||||
|
||||
if len(opts.queryMap) > 0 {
|
||||
q := url.Values{}
|
||||
for k, v := range opts.queryMap {
|
||||
q.Add(k, v)
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
}
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error performing client request during ReinitializeCA call: %w", err)
|
||||
}
|
||||
|
||||
target := new(CertificateAuthorityReinitializeResult)
|
||||
target.Item = new(CertificateAuthority)
|
||||
apiErr, err := resp.Decode(target.Item)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding ReinitializeCA response: %w", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
return target, nil
|
||||
}
|
||||
|
||||
func (c *Client) ReadCA(ctx context.Context, scopeId string, opt ...Option) (*CertificateAuthorityReadResult, error) {
|
||||
if scopeId == "" {
|
||||
return nil, fmt.Errorf("empty scopeId value passed into ReadCA request")
|
||||
}
|
||||
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
opts.queryMap["scope_id"] = scopeId
|
||||
|
||||
if c.client == nil {
|
||||
return nil, fmt.Errorf("nil client")
|
||||
}
|
||||
|
||||
req, err := c.client.NewRequest(ctx, "GET", "workers:read-certificate-authority", nil, apiOpts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating ReadCA request: %w", err)
|
||||
}
|
||||
|
||||
if len(opts.queryMap) > 0 {
|
||||
q := url.Values{}
|
||||
for k, v := range opts.queryMap {
|
||||
q.Add(k, v)
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
}
|
||||
|
||||
resp, err := c.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error performing client request during ReadCA call: %w", err)
|
||||
}
|
||||
|
||||
target := new(CertificateAuthorityReadResult)
|
||||
target.Item = new(CertificateAuthority)
|
||||
apiErr, err := resp.Decode(target.Item)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding ReadCA response: %w", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return nil, apiErr
|
||||
}
|
||||
target.response = resp
|
||||
return target, nil
|
||||
}
|
||||
@@ -30,6 +30,7 @@ type Worker struct {
|
||||
ActiveConnectionCount uint32 `json:"active_connection_count,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
ApiTags map[string][]string `json:"api_tags,omitempty"`
|
||||
ReleaseVersion string `json:"release_version,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
|
||||
Reference in new issue
Block a user