Skip to content

Commit 417d470

Browse files
authored
Merge branch 'master' into feat/cockpit-alert-waiters
2 parents c0887c1 + a8fa9f9 commit 417d470

File tree

63 files changed

+3768
-2163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3768
-2163
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3
45+
uses: github/codeql-action/init@v4
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v3
56+
uses: github/codeql-action/autobuild@v4
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v3
70+
uses: github/codeql-action/analyze@v4

api/applesilicon/v1alpha1/apple_silicon_utils.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,6 @@ const (
1313
defaultTimeout = 60 * time.Minute
1414
)
1515

16-
// WaitForInstanceRequest is used by WaitForServer method.
17-
type WaitForServerRequest struct {
18-
ServerID string
19-
Zone scw.Zone
20-
Timeout *time.Duration
21-
RetryInterval *time.Duration
22-
}
23-
24-
// WaitForServer waits for the instance to be in a "terminal state" before returning.
25-
// This function can be used to wait for an instance to be ready for example.
26-
func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) {
27-
timeout := defaultTimeout
28-
if req.Timeout != nil {
29-
timeout = *req.Timeout
30-
}
31-
retryInterval := defaultRetryInterval
32-
if req.RetryInterval != nil {
33-
retryInterval = *req.RetryInterval
34-
}
35-
36-
terminalStatus := map[ServerStatus]struct{}{
37-
ServerStatusReady: {},
38-
ServerStatusError: {},
39-
}
40-
41-
server, err := async.WaitSync(&async.WaitSyncConfig{
42-
Get: func() (any, bool, error) {
43-
res, err := s.GetServer(&GetServerRequest{
44-
ServerID: req.ServerID,
45-
Zone: req.Zone,
46-
}, opts...)
47-
if err != nil {
48-
return nil, false, err
49-
}
50-
_, isTerminal := terminalStatus[res.Status]
51-
52-
return res, isTerminal, nil
53-
},
54-
Timeout: timeout,
55-
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
56-
})
57-
if err != nil {
58-
return nil, errors.Wrap(err, "waiting for server failed")
59-
}
60-
return server.(*Server), nil
61-
}
62-
6316
func (s *PrivateNetworkAPI) WaitForServerPrivateNetworks(req *WaitForServerRequest, opts ...scw.RequestOption) ([]*ServerPrivateNetwork, error) {
6417
timeout := defaultTimeout
6518
if req.Timeout != nil {

api/applesilicon/v1alpha1/applesilicon_sdk.go

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import (
1515
"time"
1616

1717
"github.com/scaleway/scaleway-sdk-go/errors"
18+
"github.com/scaleway/scaleway-sdk-go/internal/async"
1819
"github.com/scaleway/scaleway-sdk-go/marshaler"
1920
"github.com/scaleway/scaleway-sdk-go/namegenerator"
2021
"github.com/scaleway/scaleway-sdk-go/parameter"
2122
"github.com/scaleway/scaleway-sdk-go/scw"
2223
)
2324

25+
const (
26+
defaultApplesiliconRetryInterval = 15 * time.Second
27+
defaultApplesiliconTimeout = 1 * time.Hour
28+
)
29+
2430
// always import dependencies
2531
var (
2632
_ fmt.Stringer
@@ -499,7 +505,7 @@ type OS struct {
499505
// Deprecated: CompatibleServerTypes: list of compatible server types. Deprecated.
500506
CompatibleServerTypes *[]string `json:"compatible_server_types,omitempty"`
501507

502-
// ReleaseNotesURL: url of the release notes for the OS image or softwares pre-installed.
508+
// ReleaseNotesURL: url of the release notes for the OS image or software pre-installed.
503509
ReleaseNotesURL string `json:"release_notes_url"`
504510

505511
// Description: a summary of the OS image content and configuration.
@@ -1430,6 +1436,59 @@ func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Serv
14301436
return &resp, nil
14311437
}
14321438

1439+
// WaitForServerRequest is used by WaitForServer method.
1440+
type WaitForServerRequest struct {
1441+
Zone scw.Zone
1442+
ServerID string
1443+
Timeout *time.Duration
1444+
RetryInterval *time.Duration
1445+
}
1446+
1447+
// WaitForServer waits for the Server to reach a terminal state.
1448+
func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) {
1449+
timeout := defaultApplesiliconTimeout
1450+
if req.Timeout != nil {
1451+
timeout = *req.Timeout
1452+
}
1453+
1454+
retryInterval := defaultApplesiliconRetryInterval
1455+
if req.RetryInterval != nil {
1456+
retryInterval = *req.RetryInterval
1457+
}
1458+
transientStatuses := map[ServerStatus]struct{}{
1459+
ServerStatusStarting: {},
1460+
ServerStatusRebooting: {},
1461+
ServerStatusUpdating: {},
1462+
ServerStatusLocking: {},
1463+
ServerStatusUnlocking: {},
1464+
ServerStatusReinstalling: {},
1465+
ServerStatusBusy: {},
1466+
}
1467+
1468+
res, err := async.WaitSync(&async.WaitSyncConfig{
1469+
Get: func() (any, bool, error) {
1470+
res, err := s.GetServer(&GetServerRequest{
1471+
Zone: req.Zone,
1472+
ServerID: req.ServerID,
1473+
}, opts...)
1474+
if err != nil {
1475+
return nil, false, err
1476+
}
1477+
1478+
_, isTransient := transientStatuses[res.Status]
1479+
1480+
return res, !isTransient, nil
1481+
},
1482+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
1483+
Timeout: timeout,
1484+
})
1485+
if err != nil {
1486+
return nil, errors.Wrap(err, "waiting for Server failed")
1487+
}
1488+
1489+
return res.(*Server), nil
1490+
}
1491+
14331492
// UpdateServer: Update the parameters of an existing Apple silicon server, specified by its server ID.
14341493
func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*Server, error) {
14351494
var err error
@@ -1531,7 +1590,7 @@ func (s *API) RebootServer(req *RebootServerRequest, opts ...scw.RequestOption)
15311590
return &resp, nil
15321591
}
15331592

1534-
// ReinstallServer: Reinstall an existing Apple silicon server (specified by its server ID) from a new image (OS). All the data on the disk is deleted and all configuration is reset to the defailt configuration values of the image (OS).
1593+
// ReinstallServer: Reinstall an existing Apple silicon server (specified by its server ID) from a new image (OS). All the data on the disk is deleted and all configuration is reset to the default configuration values of the image (OS).
15351594
func (s *API) ReinstallServer(req *ReinstallServerRequest, opts ...scw.RequestOption) (*Server, error) {
15361595
var err error
15371596

@@ -1681,6 +1740,56 @@ func (s *PrivateNetworkAPI) GetServerPrivateNetwork(req *PrivateNetworkAPIGetSer
16811740
return &resp, nil
16821741
}
16831742

1743+
// WaitForServerPrivateNetworkRequest is used by WaitForServerPrivateNetwork method.
1744+
type WaitForServerPrivateNetworkRequest struct {
1745+
Zone scw.Zone
1746+
ServerID string
1747+
PrivateNetworkID string
1748+
Timeout *time.Duration
1749+
RetryInterval *time.Duration
1750+
}
1751+
1752+
// WaitForServerPrivateNetwork waits for the ServerPrivateNetwork to reach a terminal state.
1753+
func (s *PrivateNetworkAPI) WaitForServerPrivateNetwork(req *WaitForServerPrivateNetworkRequest, opts ...scw.RequestOption) (*ServerPrivateNetwork, error) {
1754+
timeout := defaultApplesiliconTimeout
1755+
if req.Timeout != nil {
1756+
timeout = *req.Timeout
1757+
}
1758+
1759+
retryInterval := defaultApplesiliconRetryInterval
1760+
if req.RetryInterval != nil {
1761+
retryInterval = *req.RetryInterval
1762+
}
1763+
transientStatuses := map[ServerPrivateNetworkServerStatus]struct{}{
1764+
ServerPrivateNetworkServerStatusAttaching: {},
1765+
ServerPrivateNetworkServerStatusDetaching: {},
1766+
}
1767+
1768+
res, err := async.WaitSync(&async.WaitSyncConfig{
1769+
Get: func() (any, bool, error) {
1770+
res, err := s.GetServerPrivateNetwork(&PrivateNetworkAPIGetServerPrivateNetworkRequest{
1771+
Zone: req.Zone,
1772+
ServerID: req.ServerID,
1773+
PrivateNetworkID: req.PrivateNetworkID,
1774+
}, opts...)
1775+
if err != nil {
1776+
return nil, false, err
1777+
}
1778+
1779+
_, isTransient := transientStatuses[res.Status]
1780+
1781+
return res, !isTransient, nil
1782+
},
1783+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
1784+
Timeout: timeout,
1785+
})
1786+
if err != nil {
1787+
return nil, errors.Wrap(err, "waiting for ServerPrivateNetwork failed")
1788+
}
1789+
1790+
return res.(*ServerPrivateNetwork), nil
1791+
}
1792+
16841793
// AddServerPrivateNetwork: Add an Apple silicon server to a Private Network.
16851794
func (s *PrivateNetworkAPI) AddServerPrivateNetwork(req *PrivateNetworkAPIAddServerPrivateNetworkRequest, opts ...scw.RequestOption) (*ServerPrivateNetwork, error) {
16861795
var err error

api/audit_trail/v1alpha1/audit_trail_sdk.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ const (
448448
ResourceTypeIamRule = ResourceType("iam_rule")
449449
ResourceTypeIamSaml = ResourceType("iam_saml")
450450
ResourceTypeIamSamlCertificate = ResourceType("iam_saml_certificate")
451+
ResourceTypeIamScim = ResourceType("iam_scim")
452+
ResourceTypeIamScimToken = ResourceType("iam_scim_token")
451453
ResourceTypeSecretManagerSecret = ResourceType("secret_manager_secret")
452454
ResourceTypeSecretManagerVersion = ResourceType("secret_manager_version")
453455
ResourceTypeKeyManagerKey = ResourceType("key_manager_key")
@@ -513,6 +515,8 @@ func (enum ResourceType) Values() []ResourceType {
513515
"iam_rule",
514516
"iam_saml",
515517
"iam_saml_certificate",
518+
"iam_scim",
519+
"iam_scim_token",
516520
"secret_manager_secret",
517521
"secret_manager_version",
518522
"key_manager_key",

api/baremetal/v1/baremetal_sdk.go

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ import (
1515
"time"
1616

1717
"github.com/scaleway/scaleway-sdk-go/errors"
18+
"github.com/scaleway/scaleway-sdk-go/internal/async"
1819
"github.com/scaleway/scaleway-sdk-go/marshaler"
1920
"github.com/scaleway/scaleway-sdk-go/namegenerator"
2021
"github.com/scaleway/scaleway-sdk-go/parameter"
2122
"github.com/scaleway/scaleway-sdk-go/scw"
2223
)
2324

25+
const (
26+
defaultBaremetalRetryInterval = 15 * time.Second
27+
defaultBaremetalTimeout = 2 * time.Hour
28+
)
29+
2430
// always import dependencies
2531
var (
2632
_ fmt.Stringer
@@ -1531,10 +1537,10 @@ type BMCAccess struct {
15311537
// URL: URL to access to the server console.
15321538
URL string `json:"url"`
15331539

1534-
// Login: the login to use for the BMC (Baseboard Management Controller) access authentification.
1540+
// Login: the login to use for the BMC (Baseboard Management Controller) access authentication.
15351541
Login string `json:"login"`
15361542

1537-
// Password: the password to use for the BMC (Baseboard Management Controller) access authentification.
1543+
// Password: the password to use for the BMC (Baseboard Management Controller) access authentication.
15381544
Password string `json:"password"`
15391545

15401546
// ExpiresAt: the date after which the BMC (Baseboard Management Controller) access will be closed.
@@ -2285,6 +2291,59 @@ func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Serv
22852291
return &resp, nil
22862292
}
22872293

2294+
// WaitForServerRequest is used by WaitForServer method.
2295+
type WaitForServerRequest struct {
2296+
Zone scw.Zone
2297+
ServerID string
2298+
Timeout *time.Duration
2299+
RetryInterval *time.Duration
2300+
}
2301+
2302+
// WaitForServer waits for the Server to reach a terminal state.
2303+
func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) {
2304+
timeout := defaultBaremetalTimeout
2305+
if req.Timeout != nil {
2306+
timeout = *req.Timeout
2307+
}
2308+
2309+
retryInterval := defaultBaremetalRetryInterval
2310+
if req.RetryInterval != nil {
2311+
retryInterval = *req.RetryInterval
2312+
}
2313+
transientStatuses := map[ServerStatus]struct{}{
2314+
ServerStatusDelivering: {},
2315+
ServerStatusStopping: {},
2316+
ServerStatusStarting: {},
2317+
ServerStatusDeleting: {},
2318+
ServerStatusOrdered: {},
2319+
ServerStatusResetting: {},
2320+
ServerStatusMigrating: {},
2321+
}
2322+
2323+
res, err := async.WaitSync(&async.WaitSyncConfig{
2324+
Get: func() (any, bool, error) {
2325+
res, err := s.GetServer(&GetServerRequest{
2326+
Zone: req.Zone,
2327+
ServerID: req.ServerID,
2328+
}, opts...)
2329+
if err != nil {
2330+
return nil, false, err
2331+
}
2332+
2333+
_, isTransient := transientStatuses[res.Status]
2334+
2335+
return res, !isTransient, nil
2336+
},
2337+
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
2338+
Timeout: timeout,
2339+
})
2340+
if err != nil {
2341+
return nil, errors.Wrap(err, "waiting for Server failed")
2342+
}
2343+
2344+
return res.(*Server), nil
2345+
}
2346+
22882347
// CreateServer: Create a new Elastic Metal server. Once the server is created, proceed with the [installation of an OS](#post-3e949e).
22892348
func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*Server, error) {
22902349
var err error

api/baremetal/v1/server_utils.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,6 @@ const (
1313
defaultTimeout = 2 * time.Hour
1414
)
1515

16-
// WaitForServerRequest is used by WaitForServer method.
17-
type WaitForServerRequest struct {
18-
ServerID string
19-
Zone scw.Zone
20-
Timeout *time.Duration
21-
RetryInterval *time.Duration
22-
}
23-
24-
// WaitForServer wait for the server to be in a "terminal state" before returning.
25-
// This function can be used to wait for a server to be created.
26-
func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) {
27-
timeout := defaultTimeout
28-
if req.Timeout != nil {
29-
timeout = *req.Timeout
30-
}
31-
retryInterval := defaultRetryInterval
32-
if req.RetryInterval != nil {
33-
retryInterval = *req.RetryInterval
34-
}
35-
36-
terminalStatus := map[ServerStatus]struct{}{
37-
ServerStatusReady: {},
38-
ServerStatusStopped: {},
39-
ServerStatusError: {},
40-
ServerStatusLocked: {},
41-
ServerStatusUnknown: {},
42-
}
43-
44-
server, err := async.WaitSync(&async.WaitSyncConfig{
45-
Get: func() (any, bool, error) {
46-
res, err := s.GetServer(&GetServerRequest{
47-
ServerID: req.ServerID,
48-
Zone: req.Zone,
49-
}, opts...)
50-
if err != nil {
51-
return nil, false, err
52-
}
53-
54-
_, isTerminal := terminalStatus[res.Status]
55-
return res, isTerminal, err
56-
},
57-
Timeout: timeout,
58-
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
59-
})
60-
if err != nil {
61-
return nil, errors.Wrap(err, "waiting for server failed")
62-
}
63-
64-
return server.(*Server), nil
65-
}
66-
6716
// WaitForServerInstallRequest is used by WaitForServerInstall method.
6817
type WaitForServerInstallRequest struct {
6918
ServerID string

0 commit comments

Comments
 (0)