From 3fa9531be36b593ddd0489ef7b2e8795842417f5 Mon Sep 17 00:00:00 2001 From: Amanda Hager Lopes de Andrade Katz Date: Wed, 11 Dec 2024 10:07:30 -0300 Subject: [PATCH] fix: add godocs --- internal/juju/offers.go | 11 +++++++---- internal/provider/resource_access_offer.go | 7 +++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/juju/offers.go b/internal/juju/offers.go index 274b94ea..a09d53b1 100644 --- a/internal/juju/offers.go +++ b/internal/juju/offers.go @@ -87,6 +87,7 @@ func newOffersClient(sc SharedClient) *offersClient { } } +// CreateOffer creates offer managed by the offer resource. func (c offersClient) CreateOffer(input *CreateOfferInput) (*CreateOfferResponse, []error) { var errs []error @@ -159,6 +160,7 @@ func (c offersClient) CreateOffer(input *CreateOfferInput) (*CreateOfferResponse return &resp, nil } +// ReadOffer reads offer managed by the offer resource. func (c offersClient) ReadOffer(input *ReadOfferInput) (*ReadOfferResponse, error) { conn, err := c.GetConnection(nil) if err != nil { @@ -190,6 +192,7 @@ func (c offersClient) ReadOffer(input *ReadOfferInput) (*ReadOfferResponse, erro return &response, nil } +// DestroyOffer destroys offer managed by the offer resource. func (c offersClient) DestroyOffer(input *DestroyOfferInput) error { conn, err := c.GetConnection(nil) if err != nil { @@ -257,7 +260,7 @@ func parseModelFromURL(url string) (result string, success bool) { return result, true } -// This function allows the integration resource to consume the offers managed by the offer resource +// ConsumeRemoteOffer allows the integration resource to consume the offers managed by the offer resource. func (c offersClient) ConsumeRemoteOffer(input *ConsumeRemoteOfferInput) (*ConsumeRemoteOfferResponse, error) { modelConn, err := c.GetConnection(&input.ModelName) if err != nil { @@ -338,7 +341,7 @@ func (c offersClient) ConsumeRemoteOffer(input *ConsumeRemoteOfferInput) (*Consu return &response, nil } -// This function allows the integration resource to destroy the offers managed by the offer resource +// RemoveRemoteOffer allows the integration resource to destroy the offers managed by the offer resource. func (c offersClient) RemoveRemoteOffer(input *RemoveRemoteOfferInput) []error { var errors []error conn, err := c.GetConnection(&input.ModelName) @@ -399,7 +402,7 @@ func (c offersClient) RemoveRemoteOffer(input *RemoveRemoteOfferInput) []error { return nil } -// This function adds access to an offer +// GrantOffer adds access to an offer managed by the access offer resource. func (c offersClient) GrantOffer(input *GrantRevokeOfferInput) error { conn, err := c.GetConnection(nil) if err != nil { @@ -421,7 +424,7 @@ func (c offersClient) GrantOffer(input *GrantRevokeOfferInput) error { return nil } -// This function revokes access to an offer. +// RevokeOffer revokes access to an offer managed by the access offer resource. func (c offersClient) RevokeOffer(input *GrantRevokeOfferInput) error { conn, err := c.GetConnection(nil) if err != nil { diff --git a/internal/provider/resource_access_offer.go b/internal/provider/resource_access_offer.go index 7a691c44..c594e65b 100644 --- a/internal/provider/resource_access_offer.go +++ b/internal/provider/resource_access_offer.go @@ -33,6 +33,7 @@ var _ resource.ResourceWithConfigure = &accessOfferResource{} var _ resource.ResourceWithImportState = &accessOfferResource{} var _ resource.ResourceWithConfigValidators = &accessOfferResource{} +// NewAccessOfferResource returns a new instance of the Access Offer resource. func NewAccessOfferResource() resource.Resource { return &accessOfferResource{} } @@ -105,6 +106,7 @@ func (a *accessOfferResource) Schema(_ context.Context, req resource.SchemaReque } } +// Create attempts to grant access to the offer. func (a *accessOfferResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // Check first if the client is configured if a.client == nil { @@ -156,6 +158,7 @@ func (a *accessOfferResource) Create(ctx context.Context, req resource.CreateReq resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } +// Read reads users and permissions granted to the offer func (a *accessOfferResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // Check first if the client is configured if a.client == nil { @@ -214,6 +217,7 @@ func (a *accessOfferResource) Read(ctx context.Context, req resource.ReadRequest resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } +// Update attempts to update the access to the offer. func (a *accessOfferResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // Check first if the client is configured if a.client == nil { @@ -320,6 +324,7 @@ func (a *accessOfferResource) Update(ctx context.Context, req resource.UpdateReq resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } +// Delete remove access to the offer according to the resource. func (a *accessOfferResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // Check first if the client is configured if a.client == nil { @@ -356,6 +361,7 @@ func (a *accessOfferResource) Delete(ctx context.Context, req resource.DeleteReq } } +// Configure sets the access offer resource with provider data. func (a *accessOfferResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { @@ -383,6 +389,7 @@ func (r *accessOfferResource) ConfigValidators(ctx context.Context) []resource.C } } +// ImportState import existing resource to the state. func (a *accessOfferResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { IDstr := req.ID if len(strings.Split(IDstr, ":")) != 3 {