From d2968c0cd0487b1143c532adf9b33f495c08b529 Mon Sep 17 00:00:00 2001 From: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:25:33 +0200 Subject: [PATCH 1/4] Support dynamic AAP API endpoints (#30) * Support dynamic AAP API endpoints * Code review updates * Fix lint issue * Update AAP endpoint discovery * Update internal/provider/client_test.go * format code * use httptest for client code testing (cherry picked from commit 48f2caff9a2b201248a0725c5e406d6f60d06329) --- .../fragments/20240619-aap-versioning.yaml | 3 + go.mod | 2 +- go.sum | 16 ---- internal/provider/client.go | 75 +++++++++++++++++-- internal/provider/client_test.go | 54 ++++++++++++- internal/provider/group_resource.go | 4 +- internal/provider/host_resource.go | 4 +- internal/provider/inventory_data_source.go | 4 +- internal/provider/inventory_resource.go | 4 +- internal/provider/job_resource.go | 3 +- internal/provider/provider.go | 12 +-- internal/provider/provider_test.go | 11 ++- 12 files changed, 144 insertions(+), 48 deletions(-) create mode 100644 changelogs/fragments/20240619-aap-versioning.yaml diff --git a/changelogs/fragments/20240619-aap-versioning.yaml b/changelogs/fragments/20240619-aap-versioning.yaml new file mode 100644 index 0000000..1c5c689 --- /dev/null +++ b/changelogs/fragments/20240619-aap-versioning.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Support dynamic value for AAP endpoints since the value depends on the AAP version (https://github.com/ansible/terraform-provider-aap/pull/30). \ No newline at end of file diff --git a/go.mod b/go.mod index 9460380..a315d83 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/hashicorp/terraform-plugin-framework-jsontypes v0.1.0 github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 github.com/hashicorp/terraform-plugin-go v0.19.1 + github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.6.0 github.com/stretchr/testify v1.8.4 ) @@ -45,7 +46,6 @@ require ( github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect github.com/hashicorp/terraform-json v0.22.1 // indirect - github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect diff --git a/go.sum b/go.sum index ff67e3e..dddac71 100644 --- a/go.sum +++ b/go.sum @@ -86,28 +86,18 @@ github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly8 github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0= -github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA= github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= -github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= -github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U= -github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-docs v0.19.2 h1:YjdKa1vuqt9EnPYkkrv9HnGZz175HhSJ7Vsn8yZeWus= -github.com/hashicorp/terraform-plugin-docs v0.19.2/go.mod h1:gad2aP6uObFKhgNE8DR9nsEuEQnibp7il0jZYYOunWY= github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= github.com/hashicorp/terraform-plugin-framework v1.4.2 h1:P7a7VP1GZbjc4rv921Xy5OckzhoiO3ig6SGxwelD2sI= @@ -228,8 +218,6 @@ golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOM golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -238,8 +226,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -270,8 +256,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/internal/provider/client.go b/internal/provider/client.go index ffdccba..c45790f 100644 --- a/internal/provider/client.go +++ b/internal/provider/client.go @@ -3,6 +3,8 @@ package provider import ( "context" "crypto/tls" + "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -18,18 +20,64 @@ type ProviderHTTPClient interface { Get(path string) ([]byte, diag.Diagnostics) Update(path string, data io.Reader) ([]byte, diag.Diagnostics) Delete(path string) ([]byte, diag.Diagnostics) + setApiEndpoint() diag.Diagnostics + getApiEndpoint() string +} + +type AAPApiEndpointResponse struct { + Apis struct { + Controller string `json:"controller"` + } `json:"apis"` + CurrentVersion string `json:"current_version"` +} + +func readApiEndpoint(client ProviderHTTPClient) (string, diag.Diagnostics) { + body, diags := client.Get("/api/") + if diags.HasError() { + return "", diags + } + var response AAPApiEndpointResponse + err := json.Unmarshal(body, &response) + if err != nil { + diags.AddError( + fmt.Sprintf("Unable to parse AAP API endpoint response: %s", string(body)), + fmt.Sprintf("Unexpected error: %s", err.Error()), + ) + return "", diags + } + if len(response.Apis.Controller) > 0 { + body, diags = client.Get(response.Apis.Controller) + if diags.HasError() { + return "", diags + } + // Parse response + err = json.Unmarshal(body, &response) + if err != nil { + diags.AddError( + fmt.Sprintf("Unable to parse AAP API endpoint response: %s", string(body)), + fmt.Sprintf("Unexpected error: %s", err.Error()), + ) + return "", diags + } + } + if len(response.CurrentVersion) == 0 { + diags.AddError("Unable to determine API Endpoint", "The controller endpoint is missing from response") + return "", diags + } + return response.CurrentVersion, diags } // Client - type AAPClient struct { - HostURL string - Username *string - Password *string - httpClient *http.Client + HostURL string + Username *string + Password *string + httpClient *http.Client + ApiEndpoint string } // NewClient - create new AAPClient instance -func NewClient(host string, username *string, password *string, insecureSkipVerify bool, timeout int64) (*AAPClient, error) { +func NewClient(host string, username *string, password *string, insecureSkipVerify bool, timeout int64) (*AAPClient, diag.Diagnostics) { hostURL, _ := url.JoinPath(host, "/") client := AAPClient{ HostURL: hostURL, @@ -42,7 +90,22 @@ func NewClient(host string, username *string, password *string, insecureSkipVeri } client.httpClient = &http.Client{Transport: tr, Timeout: time.Duration(timeout) * time.Second} - return &client, nil + // Set AAP API endpoint + diags := client.setApiEndpoint() + return &client, diags +} + +func (c *AAPClient) setApiEndpoint() diag.Diagnostics { + endpoint, diags := readApiEndpoint(c) + if diags.HasError() { + return diags + } + c.ApiEndpoint = endpoint + return diags +} + +func (c *AAPClient) getApiEndpoint() string { + return c.ApiEndpoint } func (c *AAPClient) computeURLPath(path string) string { diff --git a/internal/provider/client_test.go b/internal/provider/client_test.go index bfb972b..c3b17eb 100644 --- a/internal/provider/client_test.go +++ b/internal/provider/client_test.go @@ -1,6 +1,8 @@ package provider import ( + "net/http" + "net/http/httptest" "testing" "fmt" @@ -22,12 +24,56 @@ func TestComputeURLPath(t *testing.T) { var expected = "https://localhost:8043/api/v2/state/" for _, tc := range testTable { t.Run(tc.name, func(t *testing.T) { - client, err := NewClient(tc.url, nil, nil, true, 0) - if err != nil { - t.Fatalf(`Failed to create provider client %v`, err) + client := AAPClient{ + HostURL: tc.url, + Username: nil, + Password: nil, + httpClient: nil, + ApiEndpoint: "", } result := client.computeURLPath(tc.path) - assert.Equal(t, result, expected, fmt.Sprintf("expected (%s), got (%s)", expected, result)) + assert.Equal(t, expected, result, fmt.Sprintf("expected (%s), got (%s)", expected, result)) + }) + } +} + +func TestReadApiEndpoint(t *testing.T) { + server_24 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/api/" { + t.Errorf("Expected to request '/api/', got: %s", r.URL.Path) + } + w.WriteHeader(http.StatusOK) + w.Write([]byte(`{"current_version": "/api/v2/"}`)) //nolint:errcheck + })) + defer server_24.Close() + + server_25 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/api/": + w.WriteHeader(http.StatusOK) + w.Write([]byte(`{"apis":{"gateway": "/api/gateway/", "controller": "/api/controller/"}}`)) //nolint:errcheck + case "/api/controller/": + w.WriteHeader(http.StatusOK) + w.Write([]byte(`{"current_version": "/api/controller/v2/"}`)) //nolint:errcheck + default: + t.Errorf("Expected to request one of '/api/', '/api/controller/', got: %s", r.URL.Path) + } + })) + defer server_25.Close() + + testTable := []struct { + Name string + URL string + expected string + }{ + {Name: "AAP 2.4", URL: server_24.URL, expected: "/api/v2/"}, + {Name: "AAP 2.5+", URL: server_25.URL, expected: "/api/controller/v2/"}, + } + for _, tc := range testTable { + t.Run(tc.Name, func(t *testing.T) { + client, diags := NewClient(tc.URL, nil, nil, true, 0) // readApiEndpoint() is called when creating client + assert.Equal(t, false, diags.HasError(), fmt.Sprintf("readApiEndpoint() returns errors (%v)", diags)) + assert.Equal(t, tc.expected, client.getApiEndpoint()) }) } } diff --git a/internal/provider/group_resource.go b/internal/provider/group_resource.go index fa1fe1c..e8cd721 100644 --- a/internal/provider/group_resource.go +++ b/internal/provider/group_resource.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "path" "github.com/ansible/terraform-provider-aap/internal/provider/customtypes" "github.com/hashicorp/terraform-plugin-framework/diag" @@ -137,7 +138,8 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, requestData := bytes.NewReader(createRequestBody) // Create new group in AAP - createResponseBody, diags := r.client.Create("/api/v2/groups/", requestData) + groupsURL := path.Join(r.client.getApiEndpoint(), "groups") + createResponseBody, diags := r.client.Create(groupsURL, requestData) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/provider/host_resource.go b/internal/provider/host_resource.go index 16b9481..f69017c 100644 --- a/internal/provider/host_resource.go +++ b/internal/provider/host_resource.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "path" "slices" "sync" @@ -162,7 +163,8 @@ func (r *HostResource) Create(ctx context.Context, req resource.CreateRequest, r requestData := bytes.NewReader(createRequestBody) // Create new host in AAP - createResponseBody, diags := r.client.Create("/api/v2/hosts/", requestData) + hostsURL := path.Join(r.client.getApiEndpoint(), "hosts") + createResponseBody, diags := r.client.Create(hostsURL, requestData) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/provider/inventory_data_source.go b/internal/provider/inventory_data_source.go index b3eecb3..b55e80c 100644 --- a/internal/provider/inventory_data_source.go +++ b/internal/provider/inventory_data_source.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "path" "github.com/ansible/terraform-provider-aap/internal/provider/customtypes" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -78,7 +79,8 @@ func (d *InventoryDataSource) Read(ctx context.Context, req datasource.ReadReque return } - readResponseBody, diags := d.client.Get("api/v2/inventories/" + state.Id.String()) + resourceURL := path.Join(d.client.getApiEndpoint(), "inventories", state.Id.String()) + readResponseBody, diags := d.client.Get(resourceURL) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/provider/inventory_resource.go b/internal/provider/inventory_resource.go index a4c08c5..4a12284 100644 --- a/internal/provider/inventory_resource.go +++ b/internal/provider/inventory_resource.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "path" "github.com/ansible/terraform-provider-aap/internal/provider/customtypes" "github.com/hashicorp/terraform-plugin-framework/diag" @@ -122,7 +123,8 @@ func (r *InventoryResource) Create(ctx context.Context, req resource.CreateReque requestData := bytes.NewReader(createRequestBody) // Create new inventory in AAP - createResponseBody, diags := r.client.Create("/api/v2/inventories/", requestData) + inventoriesURL := path.Join(r.client.getApiEndpoint(), "inventories") + createResponseBody, diags := r.client.Create(inventoriesURL, requestData) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/provider/job_resource.go b/internal/provider/job_resource.go index 43923bc..fabe04e 100644 --- a/internal/provider/job_resource.go +++ b/internal/provider/job_resource.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "path" "github.com/ansible/terraform-provider-aap/internal/provider/customtypes" "github.com/hashicorp/terraform-plugin-framework/attr" @@ -302,7 +303,7 @@ func (r *JobResource) LaunchJob(data *JobResourceModel) diag.Diagnostics { } requestData := bytes.NewReader(requestBody) - var postURL = "/api/v2/job_templates/" + data.GetTemplateID() + "/launch/" + var postURL = path.Join(r.client.getApiEndpoint(), "job_templates", data.GetTemplateID(), "launch") resp, body, err := r.client.doRequest(http.MethodPost, postURL, requestData) diags.Append(ValidateResponse(resp, body, err, []int{http.StatusCreated})...) if diags.HasError() { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 4f9c28b..88dbfb6 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -132,16 +132,8 @@ func (p *aapProvider) Configure(ctx context.Context, req provider.ConfigureReque } // Create a new http client using the configuration values - client, err := NewClient(host, &username, &password, insecureSkipVerify, timeout) - if err != nil { - resp.Diagnostics.AddError( - "Unable to Create AAP API Client", - "An unexpected error occurred when creating the AAP API client. "+ - "If the error is not clear, please contact the provider developers.\n\n"+ - "http Client Error: "+err.Error(), - ) - return - } + client, diags := NewClient(host, &username, &password, insecureSkipVerify, timeout) + resp.Diagnostics.Append(diags...) // Make the http client available during DataSource and Resource // type Configure methods. diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 9d4bc2c..0302a6b 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -46,18 +46,17 @@ func testGetResource(urlPath string) ([]byte, error) { username := os.Getenv("AAP_USERNAME") password := os.Getenv("AAP_PASSWORD") - client, err := NewClient(host, &username, &password, true, 0) - if err != nil { - return nil, err + client, diags := NewClient(host, &username, &password, true, 0) + if diags.HasError() { + return nil, fmt.Errorf("%v", diags.Errors()) } body, diags := client.Get(urlPath) if diags.HasError() { - err = fmt.Errorf("%v", diags.Errors()) - return nil, err + return nil, fmt.Errorf("%v", diags.Errors()) } - return body, err + return body, nil } func TestReadValues(t *testing.T) { From fb2218f4ecb17eaeabbe0b9c799007bb5e19efd5 Mon Sep 17 00:00:00 2001 From: Mandar Kulkarni Date: Thu, 9 Jan 2025 13:07:04 -0800 Subject: [PATCH 2/4] run go get github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server@v0.20.0 --- go.mod | 12 ++++++------ go.sum | 13 +++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a315d83..dbfc455 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/hashicorp/terraform-plugin-framework v1.4.2 github.com/hashicorp/terraform-plugin-framework-jsontypes v0.1.0 github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 - github.com/hashicorp/terraform-plugin-go v0.19.1 + github.com/hashicorp/terraform-plugin-go v0.20.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.6.0 github.com/stretchr/testify v1.8.4 @@ -38,7 +38,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.5.2 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/hc-install v0.7.0 // indirect @@ -49,7 +49,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 // indirect github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect - github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.15 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -79,9 +79,9 @@ require ( golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.15.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/grpc v1.59.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.60.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index dddac71..82b35d1 100644 --- a/go.sum +++ b/go.sum @@ -55,6 +55,7 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -83,6 +84,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -108,6 +111,8 @@ github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEz github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= github.com/hashicorp/terraform-plugin-go v0.19.1 h1:lf/jTGTeELcz5IIbn/94mJdmnTjRYm6S6ct/JqCSr50= github.com/hashicorp/terraform-plugin-go v0.19.1/go.mod h1:5NMIS+DXkfacX6o5HCpswda5yjkSYfKzn1Nfl9l+qRs= +github.com/hashicorp/terraform-plugin-go v0.20.0 h1:oqvoUlL+2EUbKNsJbIt3zqqZ7wi6lzn4ufkn/UA51xQ= +github.com/hashicorp/terraform-plugin-go v0.20.0/go.mod h1:Rr8LBdMlY53a3Z/HpP+ZU3/xCDqtKNCkeI9qOyT10QE= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 h1:X7vB6vn5tON2b49ILa4W7mFAsndeqJ7bZFOGbVO+0Cc= @@ -120,6 +125,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -255,6 +262,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= @@ -268,10 +276,15 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= +google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 1daf556db1a9b83539f2a71da1c841032ee5ec6e Mon Sep 17 00:00:00 2001 From: Mandar Kulkarni Date: Thu, 9 Jan 2025 13:08:55 -0800 Subject: [PATCH 3/4] run go get github.com/hashicorp/go-hclog --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dbfc455..b484eeb 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect diff --git a/go.sum b/go.sum index 82b35d1..7263042 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,8 @@ github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUK github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= From 54972519b9359859bb542cf6a33c6b799925337f Mon Sep 17 00:00:00 2001 From: aubin bikouo Date: Fri, 10 Jan 2025 10:22:37 +0100 Subject: [PATCH 4/4] install terraform --- .github/workflows/generate_docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml index 59b9dd0..702ad16 100644 --- a/.github/workflows/generate_docs.yml +++ b/.github/workflows/generate_docs.yml @@ -25,6 +25,10 @@ jobs: - name: Build run: go build -v ./... + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "1.1.7" + - name: Generate documentation run: make generatedocs