Skip to content

Commit

Permalink
first authentication implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
RaynorChavez committed Feb 12, 2024
1 parent 65343b5 commit c4da8e0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
5 changes: 4 additions & 1 deletion examples/provider-install-verification/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ terraform {
}
}

provider "marqo" {}
provider "marqo" {
host = "http://localhost:8080"
api_key = "your"
}

data "marqo_indices" "example" {}
25 changes: 25 additions & 0 deletions internal/provider/indices_datasource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package provider

import (
"context"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

func NewIndicesDataSource() datasource.DataSource {
return &indicesDataSource{}
}

type indicesDataSource struct{}

func (d *indicesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_indices"
}

func (d *indicesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{}
}

func (d *indicesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
}
6 changes: 4 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ func (p *marqoProvider) Configure(ctx context.Context, req provider.ConfigureReq
return
}

// Make the HashiCups client available during DataSource and Resource
// Make the Marqo client available during DataSource and Resource
// type Configure methods.
resp.DataSourceData = client
resp.ResourceData = client
}

// DataSources defines the data sources implemented in the provider.
func (p *marqoProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return nil
return []func() datasource.DataSource{
NewIndicesDataSource,
}
}

// Resources defines the resources implemented in the provider.
Expand Down
11 changes: 11 additions & 0 deletions marqo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ func NewClient(baseURL, apiKey *string) (*Client, error) {
return nil, errors.New("apiKey is required but was not provided")
}

//
// TO IMPLEMENT:
// - Translate is_marqo_cloud = False
// if url is not None:
// if url.lower().startswith(os.environ.get("MARQO_CLOUD_URL", "https://api.marqo.ai")):
// instance_mappings = MarqoCloudInstanceMappings(control_base_url=url, api_key=api_key)
// is_marqo_cloud = True
// else:
// instance_mappings = DefaultInstanceMappings(url, main_user, main_password)
//

// Create the client instance
client := &Client{
BaseURL: *baseURL,
Expand Down

0 comments on commit c4da8e0

Please sign in to comment.