Skip to content

Commit bd2e810

Browse files
scaleway-botjremy42yfodil
authored
feat(apple_silicon): add CI-CD runner installation APIs (scaleway#2440)
Co-authored-by: Jonathan Remy <[email protected]> Co-authored-by: Yacine Fodil <[email protected]>
1 parent 0c1af30 commit bd2e810

File tree

3 files changed

+118
-3
lines changed

3 files changed

+118
-3
lines changed

packages_generated/applesilicon/src/v1alpha1/index.gen.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ export type {
3333
ListServerTypesRequest,
3434
ListServerTypesResponse,
3535
OS,
36+
OSSupportedServerType,
3637
PrivateNetworkApiAddServerPrivateNetworkRequest,
3738
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
3839
PrivateNetworkApiGetServerPrivateNetworkRequest,
3940
PrivateNetworkApiListServerPrivateNetworksRequest,
4041
PrivateNetworkApiSetServerPrivateNetworksRequest,
4142
RebootServerRequest,
4243
ReinstallServerRequest,
44+
RunnerConfiguration,
45+
RunnerConfigurationProvider,
4346
Server,
4447
ServerPrivateNetwork,
4548
ServerPrivateNetworkServerStatus,

packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ import type {
2121
ListServersResponse,
2222
ListServerTypesResponse,
2323
OS,
24+
OSSupportedServerType,
2425
PrivateNetworkApiAddServerPrivateNetworkRequest,
2526
PrivateNetworkApiSetServerPrivateNetworksRequest,
2627
ReinstallServerRequest,
28+
RunnerConfiguration,
2729
Server,
2830
ServerPrivateNetwork,
2931
ServerType,
@@ -39,6 +41,21 @@ import type {
3941
UpdateServerRequest,
4042
} from './types.gen'
4143

44+
const unmarshalOSSupportedServerType = (
45+
data: unknown,
46+
): OSSupportedServerType => {
47+
if (!isJSONObject(data)) {
48+
throw new TypeError(
49+
`Unmarshalling the type 'OSSupportedServerType' failed as data isn't a dictionary.`,
50+
)
51+
}
52+
53+
return {
54+
fastDeliveryAvailable: data.fast_delivery_available,
55+
serverType: data.server_type,
56+
} as OSSupportedServerType
57+
}
58+
4259
export const unmarshalOS = (data: unknown): OS => {
4360
if (!isJSONObject(data)) {
4461
throw new TypeError(
@@ -47,13 +64,22 @@ export const unmarshalOS = (data: unknown): OS => {
4764
}
4865

4966
return {
50-
compatibleServerTypes: data.compatible_server_types,
67+
compatibleServerTypes: data.compatible_server_types
68+
? data.compatible_server_types
69+
: undefined,
70+
description: data.description,
5171
family: data.family,
5272
id: data.id,
5373
imageUrl: data.image_url,
5474
isBeta: data.is_beta,
5575
label: data.label,
5676
name: data.name,
77+
releaseNotesUrl: data.release_notes_url,
78+
supportedServerTypes: unmarshalArrayOfObject(
79+
data.supported_server_types,
80+
unmarshalOSSupportedServerType,
81+
),
82+
tags: data.tags,
5783
version: data.version,
5884
xcodeVersion: data.xcode_version,
5985
} as OS
@@ -72,6 +98,21 @@ const unmarshalCommitment = (data: unknown): Commitment => {
7298
} as Commitment
7399
}
74100

101+
const unmarshalRunnerConfiguration = (data: unknown): RunnerConfiguration => {
102+
if (!isJSONObject(data)) {
103+
throw new TypeError(
104+
`Unmarshalling the type 'RunnerConfiguration' failed as data isn't a dictionary.`,
105+
)
106+
}
107+
108+
return {
109+
name: data.name,
110+
provider: data.provider,
111+
token: data.token,
112+
url: data.url,
113+
} as RunnerConfiguration
114+
}
115+
75116
export const unmarshalServer = (data: unknown): Server => {
76117
if (!isJSONObject(data)) {
77118
throw new TypeError(
@@ -94,9 +135,13 @@ export const unmarshalServer = (data: unknown): Server => {
94135
os: data.os ? unmarshalOS(data.os) : undefined,
95136
projectId: data.project_id,
96137
publicBandwidthBps: data.public_bandwidth_bps,
138+
runnerConfiguration: data.runner_configuration
139+
? unmarshalRunnerConfiguration(data.runner_configuration)
140+
: undefined,
97141
sshUsername: data.ssh_username,
98142
status: data.status,
99143
sudoPassword: data.sudo_password,
144+
tags: data.tags,
100145
type: data.type,
101146
updatedAt: unmarshalDate(data.updated_at),
102147
vncPort: data.vnc_port,
@@ -404,6 +449,16 @@ export const marshalBatchCreateServersRequest = (
404449
type: request.type,
405450
})
406451

452+
const marshalRunnerConfiguration = (
453+
request: RunnerConfiguration,
454+
defaults: DefaultValues,
455+
): Record<string, unknown> => ({
456+
name: request.name,
457+
provider: request.provider,
458+
token: request.token,
459+
url: request.url,
460+
})
461+
407462
export const marshalCreateServerRequest = (
408463
request: CreateServerRequest,
409464
defaults: DefaultValues,
@@ -414,6 +469,10 @@ export const marshalCreateServerRequest = (
414469
os_id: request.osId,
415470
project_id: request.projectId ?? defaults.defaultProjectId,
416471
public_bandwidth_bps: request.publicBandwidthBps,
472+
runner_configuration:
473+
request.runnerConfiguration !== undefined
474+
? marshalRunnerConfiguration(request.runnerConfiguration, defaults)
475+
: undefined,
417476
type: request.type,
418477
})
419478

@@ -437,6 +496,10 @@ export const marshalReinstallServerRequest = (
437496
defaults: DefaultValues,
438497
): Record<string, unknown> => ({
439498
os_id: request.osId,
499+
runner_configuration:
500+
request.runnerConfiguration !== undefined
501+
? marshalRunnerConfiguration(request.runnerConfiguration, defaults)
502+
: undefined,
440503
})
441504

442505
export const marshalStartConnectivityDiagnosticRequest = (

packages_generated/applesilicon/src/v1alpha1/types.gen.ts

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export type ListServerPrivateNetworksRequestOrderBy =
2222

2323
export type ListServersRequestOrderBy = 'created_at_asc' | 'created_at_desc'
2424

25+
export type RunnerConfigurationProvider =
26+
| 'unknown_provider'
27+
| 'github'
28+
| 'gitlab'
29+
2530
export type ServerPrivateNetworkServerStatus =
2631
| 'unknown_status'
2732
| 'attaching'
@@ -55,6 +60,11 @@ export type ServerTypeStock =
5560
| 'low_stock'
5661
| 'high_stock'
5762

63+
export interface OSSupportedServerType {
64+
serverType: string
65+
fastDeliveryAvailable: boolean
66+
}
67+
5868
export interface Commitment {
5969
type: CommitmentType
6070
cancelled: boolean
@@ -94,9 +104,32 @@ export interface OS {
94104
*/
95105
xcodeVersion: string
96106
/**
97-
* List of compatible server types.
107+
* @deprecated List of compatible server types. Deprecated.
108+
*/
109+
compatibleServerTypes?: string[]
110+
/**
111+
* Url of the release notes for the OS image or softwares pre-installed.
112+
*/
113+
releaseNotesUrl: string
114+
/**
115+
* A summary of the OS image content and configuration.
116+
*/
117+
description: string
118+
/**
119+
* List of tags for the OS configuration.
120+
*/
121+
tags: string[]
122+
/**
123+
* List of server types which supports the OS configuration. Also gives information about immediate stock availability.
98124
*/
99-
compatibleServerTypes: string[]
125+
supportedServerTypes: OSSupportedServerType[]
126+
}
127+
128+
export interface RunnerConfiguration {
129+
name: string
130+
url: string
131+
token: string
132+
provider: RunnerConfigurationProvider
100133
}
101134

102135
export interface ServerTypeCPU {
@@ -220,6 +253,14 @@ export interface Server {
220253
* Public bandwidth configured for this server. Expressed in bits per second.
221254
*/
222255
publicBandwidthBps: number
256+
/**
257+
* Current runner configuration, empty if none is installed.
258+
*/
259+
runnerConfiguration?: RunnerConfiguration
260+
/**
261+
* A list of tags attached to the server.
262+
*/
263+
tags: string[]
223264
}
224265

225266
export interface ConnectivityDiagnosticServerHealth {
@@ -401,6 +442,10 @@ export type CreateServerRequest = {
401442
* Public bandwidth to configure for this server. This defaults to the minimum bandwidth for this server type. For compatible server types, the bandwidth can be increased which incurs additional costs.
402443
*/
403444
publicBandwidthBps: number
445+
/**
446+
* Specify the configuration to install an optional CICD runner on the server during installation.
447+
*/
448+
runnerConfiguration?: RunnerConfiguration
404449
}
405450

406451
export type DeleteServerRequest = {
@@ -667,6 +712,10 @@ export type ReinstallServerRequest = {
667712
* Reinstall the server with the target OS, when no os_id provided the default OS for the server type is used.
668713
*/
669714
osId?: string
715+
/**
716+
* Specify the configuration to install an optional CICD runner on the server during installation.
717+
*/
718+
runnerConfiguration?: RunnerConfiguration
670719
}
671720

672721
export interface SetServerPrivateNetworksResponse {

0 commit comments

Comments
 (0)