Skip to content

Commit

Permalink
Refactor handling of identifiers and service creation
Browse files Browse the repository at this point in the history
  • Loading branch information
htahir1 committed Oct 27, 2024
1 parent 6f9d900 commit c0001f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
7 changes: 3 additions & 4 deletions internal/provider/data_source_stack_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ func dataSourceStackComponentRead(d *schema.ResourceData, m interface{}) error {
client := m.(*Client)

// Check that only one identifier method is used
hasID := d.GetOk("id")
hasName := d.GetOk("name")
id, hasID := d.GetOk("id")
name, hasName := d.GetOk("name")
if hasID && hasName {
return fmt.Errorf("only one of id or name should be specified")
}

// Try to find by ID first
if id, ok := d.GetOk("id"); ok {
if hasID {
component, err := client.GetComponent(id.(string))
if err != nil {
return fmt.Errorf("error reading stack component: %v", err)
Expand All @@ -26,7 +26,6 @@ func dataSourceStackComponentRead(d *schema.ResourceData, m interface{}) error {
}

// Try to find by name and workspace
name, hasName := d.GetOk("name")
workspace, hasWorkspace := d.GetOk("workspace")

if !hasName {
Expand Down
3 changes: 0 additions & 3 deletions internal/provider/resource_service_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ func resourceServiceConnectorCreate(d *schema.ResourceData, m interface{}) error
client := m.(*Client)

connector := ServiceConnectorBody{
Name: d.Get("name").(string),
Type: d.Get("type").(string),
AuthMethod: d.Get("auth_method").(string),
User: d.Get("user").(string),
Workspace: d.Get("workspace").(string),
}
Expand Down
Binary file modified terraform-provider-zenml
Binary file not shown.

0 comments on commit c0001f4

Please sign in to comment.