Skip to content
Open
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
2 changes: 2 additions & 0 deletions github/actions_hosted_runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type HostedRunner struct {
MaximumRunners *int64 `json:"maximum_runners,omitempty"`
PublicIPEnabled *bool `json:"public_ip_enabled,omitempty"`
PublicIPs []*HostedRunnerPublicIP `json:"public_ips,omitempty"`
ImageGen *bool `json:"image_gen,omitempty"`
LastActiveOn *Timestamp `json:"last_active_on,omitempty"`
}

Expand Down Expand Up @@ -112,6 +113,7 @@ type UpdateHostedRunnerRequest struct {
Size *string `json:"size,omitempty"`
ImageID *string `json:"image_id,omitempty"`
ImageVersion *string `json:"image_version,omitempty"`
ImageGen *bool `json:"image_gen,omitempty"`
}

// validateCreateHostedRunnerRequest validates the provided CreateHostedRunnerRequest to ensure
Expand Down
72 changes: 72 additions & 0 deletions github/actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,3 +1159,75 @@ func TestActionsService_DeleteHostedRunnerCustomImageVersion(t *testing.T) {
return client.Actions.DeleteHostedRunnerCustomImageVersion(ctx, "o", 1, "1.0.0")
})
}

func TestHostedRunner_Marshal(t *testing.T) {
t.Parallel()
testJSONMarshal(t, &HostedRunner{}, "{}")

u := &HostedRunner{
ID: new(int64(5)),
Name: new("My hosted ubuntu runner"),
RunnerGroupID: new(int64(2)),
Platform: new("linux-x64"),
ImageDetails: &HostedRunnerImageDetail{
ID: new("ubuntu-20.04"),
SizeGB: new(int64(86)),
DisplayName: new("20.04"),
Source: new("github"),
Version: new("latest"),
},
MachineSizeDetails: &HostedRunnerMachineSpec{ID: "4-core", CPUCores: 4, MemoryGB: 16, StorageGB: 150},
Status: new("Ready"),
MaximumRunners: new(int64(10)),
PublicIPEnabled: new(true),
PublicIPs: []*HostedRunnerPublicIP{{Enabled: true, Prefix: "20.80.208.150", Length: 31}},
ImageGen: new(true),
LastActiveOn: &Timestamp{referenceTime},
}

want := `{
"id": 5,
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"platform": "linux-x64",
"image_details": {"id": "ubuntu-20.04", "size_gb": 86, "display_name": "20.04", "source": "github", "version": "latest"},
"machine_size_details": {"id": "4-core", "cpu_cores": 4, "memory_gb": 16, "storage_gb": 150},
"status": "Ready",
"maximum_runners": 10,
"public_ip_enabled": true,
"public_ips": [{"enabled": true, "prefix": "20.80.208.150", "length": 31}],
"image_gen": true,
"last_active_on": ` + referenceTimeStr + `
}`

testJSONMarshal(t, u, want)
}

func TestUpdateHostedRunnerRequest_Marshal(t *testing.T) {
t.Parallel()
testJSONMarshal(t, &UpdateHostedRunnerRequest{}, "{}")

u := &UpdateHostedRunnerRequest{
Name: new("My hosted ubuntu runner"),
RunnerGroupID: new(int64(2)),
MaximumRunners: new(int64(10)),
EnableStaticIP: new(true),
Size: new("4-core"),
ImageID: new("ubuntu-20.04"),
ImageVersion: new("latest"),
ImageGen: new(true),
}

want := `{
"name": "My hosted ubuntu runner",
"runner_group_id": 2,
"maximum_runners": 10,
"enable_static_ip": true,
"size": "4-core",
"image_id": "ubuntu-20.04",
"image_version": "latest",
"image_gen": true
}`

testJSONMarshal(t, u, want)
}
16 changes: 16 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading