Skip to content

Commit

Permalink
added code snippet for delete registration token
Browse files Browse the repository at this point in the history
  • Loading branch information
MGamya committed Aug 26, 2024
1 parent 68556f4 commit e591eab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
21 changes: 17 additions & 4 deletions client/cluster_edge_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,28 @@ func (h *V1Client) GetRegistrationToken(tokenName string) (string, error) {
}

// CreateRegistrationToken creates a new registration token.
func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, error) {
func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, string, error) {
// ACL scoped to tenant only
params := clientv1.NewV1EdgeTokensCreateParams().
WithBody(body)
_, err := h.Client.V1EdgeTokensCreate(params)
res, err := h.Client.V1EdgeTokensCreate(params)
if err != nil {
return "", err
return "", "", err
}
token, err := h.GetRegistrationToken(tokenName)

return *res.Payload.UID, token, err
}

// DeleteRegistrationToken deletes a registration token by name.
func (h *V1Client) DeleteRegistrationToken(tokenUid string) error {

Check failure on line 50 in client/cluster_edge_native.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

var-naming: method parameter tokenUid should be tokenUID (revive)
// ACL scoped to tenant only
params := clientv1.NewV1EdgeTokensUIDDeleteParams().WithUID(tokenUid)
_, err := h.Client.V1EdgeTokensUIDDelete(params)
if err != nil {
return fmt.Errorf("failed to delete registration token: %w", err)
}
return h.GetRegistrationToken(tokenName)
return nil
}

// GetEdgeHost retrieves an existing edge host by UID.
Expand Down

0 comments on commit e591eab

Please sign in to comment.