Skip to content
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

Allow to enable LKE APL #665

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lke_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package linodego
import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/linode/linodego/internal/parseabletime"
Expand Down Expand Up @@ -31,6 +32,9 @@ type LKECluster struct {

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier"`

// NOTE: APLEnabled is currently in beta and may only function with API version v4beta.
APLEnabled bool `json:"apl_enabled"`
}

// LKEClusterCreateOptions fields are those accepted by CreateLKECluster
Expand All @@ -44,6 +48,9 @@ type LKEClusterCreateOptions struct {

// NOTE: Tier may not currently be available to all users and can only be used with v4beta.
Tier string `json:"tier,omitempty"`

// NOTE: APLEnabled is currently in beta and may only function with API version v4beta.
APLEnabled bool `json:"apl_enabled,omitempty"`
}

// LKEClusterUpdateOptions fields are those accepted by UpdateLKECluster
Expand Down Expand Up @@ -246,3 +253,31 @@ func (c *Client) DeleteLKEClusterServiceToken(ctx context.Context, clusterID int
e := formatAPIPath("lke/clusters/%d/servicetoken", clusterID)
return doDELETERequest(ctx, c, e)
}

// GetLKEClusterAPLConsoleURL gets the URL of this cluster's APL installation if this cluster is APL-enabled.
func (c *Client) GetLKEClusterAPLConsoleURL(ctx context.Context, clusterID int) (string, error) {
cluster, err := c.GetLKECluster(ctx, clusterID)
if err != nil {
return "", err
}

if cluster.APLEnabled {
return fmt.Sprintf("https://console.lke%d.akamai-apl.net", cluster.ID), nil
}

return "", nil
}

// GetLKEClusterAPLHealthCheckURL gets the URL of this cluster's APL health check endpoint if this cluster is APL-enabled.
func (c *Client) GetLKEClusterAPLHealthCheckURL(ctx context.Context, clusterID int) (string, error) {
cluster, err := c.GetLKECluster(ctx, clusterID)
if err != nil {
return "", err
}

if cluster.APLEnabled {
return fmt.Sprintf("https://auth.lke%d.akamai-apl.net/ready", cluster.ID), nil
}

return "", nil
}
Loading