Skip to content

Commit

Permalink
Merge branch 'main' into feat/bearer_token_full
Browse files Browse the repository at this point in the history
  • Loading branch information
paketeserrano authored Jan 31, 2025
2 parents 125be91 + ebdb329 commit 92f62c0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)

### Added
- Added support for token-based authentication in the client, including functions for token management.
- managed load balancer: support for redirect rule HTTP status

## [8.14.0]

Expand Down
1 change: 1 addition & 0 deletions upcloud/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ type LoadBalancerActionHTTPReturn struct {
type LoadBalancerActionHTTPRedirect struct {
Location string `json:"location,omitempty"`
Scheme LoadBalancerActionHTTPRedirectScheme `json:"scheme,omitempty"`
Status int `json:"status,omitempty"`
}

// LoadBalancerActionSetForwardedHeaders represents 'set_forwarded_headers' action
Expand Down
20 changes: 20 additions & 0 deletions upcloud/request/load_balancer_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ func NewLoadBalancerHTTPRedirectAction(location string) upcloud.LoadBalancerActi
}
}

func NewLoadBalancerHTTPRedirectActionWithStatus(location string, status int) upcloud.LoadBalancerAction {
return upcloud.LoadBalancerAction{
Type: upcloud.LoadBalancerActionTypeHTTPRedirect,
HTTPRedirect: &upcloud.LoadBalancerActionHTTPRedirect{
Location: location,
Status: status,
},
}
}

func NewLoadBalancerHTTPRedirectSchemeAction(scheme upcloud.LoadBalancerActionHTTPRedirectScheme) upcloud.LoadBalancerAction {
return upcloud.LoadBalancerAction{
Type: upcloud.LoadBalancerActionTypeHTTPRedirect,
Expand All @@ -40,6 +50,16 @@ func NewLoadBalancerHTTPRedirectSchemeAction(scheme upcloud.LoadBalancerActionHT
}
}

func NewLoadBalancerHTTPRedirectSchemeActionWithStatus(scheme upcloud.LoadBalancerActionHTTPRedirectScheme, status int) upcloud.LoadBalancerAction {
return upcloud.LoadBalancerAction{
Type: upcloud.LoadBalancerActionTypeHTTPRedirect,
HTTPRedirect: &upcloud.LoadBalancerActionHTTPRedirect{
Scheme: scheme,
Status: status,
},
}
}

func NewLoadBalancerUseBackendAction(name string) upcloud.LoadBalancerAction {
return upcloud.LoadBalancerAction{
Type: upcloud.LoadBalancerActionTypeUseBackend,
Expand Down
18 changes: 17 additions & 1 deletion upcloud/request/load_balancer_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,21 @@ func TestMatcheresAndActionsHelper(t *testing.T) {
"action_http_redirect": {
"scheme": "https"
}
}
},
{
"type": "http_redirect",
"action_http_redirect": {
"location": "https://internal.example.com",
"status": 301
}
},
{
"type": "http_redirect",
"action_http_redirect": {
"scheme": "https",
"status": 302
}
}
]
}
`
Expand Down Expand Up @@ -185,6 +199,8 @@ func TestMatcheresAndActionsHelper(t *testing.T) {
NewLoadBalancerHTTPReturnAction(200, "text/html", "PGgxPmFwcGxlYmVlPC9oMT4K"),
NewLoadBalancerHTTPRedirectAction("https://internal.example.com"),
NewLoadBalancerHTTPRedirectSchemeAction(upcloud.LoadBalancerActionHTTPRedirectSchemeHTTPS),
NewLoadBalancerHTTPRedirectActionWithStatus("https://internal.example.com", 301),
NewLoadBalancerHTTPRedirectSchemeActionWithStatus(upcloud.LoadBalancerActionHTTPRedirectSchemeHTTPS, 302),
},
}
actual, err := json.Marshal(&r)
Expand Down

0 comments on commit 92f62c0

Please sign in to comment.