-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cname and UUID to tunnel #1176
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,15 @@ func resourceCloudflareArgoTunnel() *schema.Resource { | |
Required: true, | ||
Sensitive: true, | ||
}, | ||
"cname": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "The generated CNAME for the named tunnel", | ||
}, | ||
"uuid": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -55,10 +64,30 @@ func resourceCloudflareArgoTunnelCreate(d *schema.ResourceData, meta interface{} | |
} | ||
|
||
func resourceCloudflareArgoTunnelRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*cloudflare.API) | ||
|
||
attributes := strings.Split(d.Id(), "/") | ||
|
||
if len(attributes) != 2 { | ||
return fmt.Errorf("invalid id (\"%s\") specified, should be in format \"accountID/argoTunnelUUID\"", d.Id()) | ||
} | ||
|
||
accID, tunnelID := attributes[0], attributes[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is |
||
|
||
tunnel, err := client.ArgoTunnel(context.Background(), accID, tunnelID) | ||
if err != nil { | ||
return fmt.Errorf("failed to fetch Argo Tunnel %s: %w", tunnelID, err) | ||
} | ||
|
||
d.Set("name", tunnel.Name) | ||
d.Set("cname", fmt.Sprintf("%s.argotunnel.com", tunnelID)) | ||
d.Set("uuid", tunnelID) | ||
d.SetId(tunnel.ID) | ||
|
||
return nil | ||
} | ||
|
||
func resourceCloudflareArgoTunnelUpdate(d *schema.ResourceData, meta interface{}) error { | ||
func resourceCloudflareArgoTunnelUpdate(_ *schema.ResourceData, _ interface{}) error { | ||
return nil | ||
} | ||
|
||
|
@@ -82,24 +111,8 @@ func resourceCloudflareArgoTunnelDelete(d *schema.ResourceData, meta interface{} | |
} | ||
|
||
func resourceCloudflareArgoTunnelImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { | ||
client := meta.(*cloudflare.API) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mentioned at https://github.com/cloudflare/terraform-provider-cloudflare/pull/1176/files#r700663326, some of this functionality needs to stay as is as it's |
||
attributes := strings.Split(d.Id(), "/") | ||
|
||
if len(attributes) != 2 { | ||
return nil, fmt.Errorf("invalid id (\"%s\") specified, should be in format \"accountID/argoTunnelUUID\"", d.Id()) | ||
} | ||
|
||
accID, tunnelID := attributes[0], attributes[1] | ||
|
||
tunnel, err := client.ArgoTunnel(context.Background(), accID, tunnelID) | ||
if err != nil { | ||
return nil, errors.Wrap(err, fmt.Sprintf("failed to fetch Argo Tunnel %s", tunnelID)) | ||
} | ||
|
||
d.Set("name", tunnel.Name) | ||
d.SetId(tunnel.ID) | ||
|
||
resourceCloudflareArgoTunnelRead(d, meta) | ||
err := resourceCloudflareArgoTunnelRead(d, meta) | ||
|
||
return []*schema.ResourceData{d}, nil | ||
return []*schema.ResourceData{d}, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't really need this; the resource ID is already this value.