Skip to content

Commit 1c21089

Browse files
committed
main merge
1 parent f19fa16 commit 1c21089

32 files changed

+1258
-234
lines changed
Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
name: Build and Test CI
1+
name: Coverage and E2E
22

33
on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- "*"
7+
pull_request_target:
108
workflow_dispatch:
119

1210
permissions:
@@ -15,7 +13,7 @@ permissions:
1513
actions: read
1614

1715
concurrency:
18-
group: build-test-ci-${{ github.ref }}
16+
group: build-test-ci-${{ github.event.pull_request.number || github.ref_name }}
1917
cancel-in-progress: true
2018

2119
jobs:
@@ -26,6 +24,8 @@ jobs:
2624
paths: ${{ steps.filter.outputs.changes }}
2725
steps:
2826
- uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
2929
- name: Harden Runner
3030
uses: step-security/harden-runner@v2
3131
with:
@@ -39,16 +39,8 @@ jobs:
3939
with:
4040
filters: .github/filters.yml
4141

42-
yamllint:
43-
runs-on: ubuntu-latest
44-
needs: changes
45-
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
46-
steps:
47-
- uses: actions/checkout@v4
48-
- name: Validate YAML file
49-
run: yamllint templates
50-
5142
go-build-test:
43+
environment: ${{ github.event.pull_request.head.repo.fork == true && 'prod-external' || 'prod' }}
5244
runs-on: ubuntu-latest
5345
needs: changes
5446
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
@@ -72,19 +64,15 @@ jobs:
7264
raw.githubusercontent.com:443
7365
7466
- uses: actions/checkout@v4
67+
with:
68+
ref: ${{ github.event.pull_request.head.sha }}
7569

7670
- name: Set up Go
7771
uses: actions/setup-go@v5
7872
with:
7973
go-version-file: 'go.mod'
8074
check-latest: true
8175

82-
- name: Build
83-
run: make build
84-
85-
- name: Check for generated diff
86-
run: make check-gen-diff
87-
8876
- name: Test
8977
run: make test
9078

@@ -106,45 +94,10 @@ jobs:
10694
exclude:
10795
- flavor: src
10896
include:
109-
- flavor: ${{ github.ref == 'refs/heads/main' && 'all' || 'quick' }}
97+
- flavor: ${{ github.event.pull_request.number && 'quick' || 'all' }}
11098
uses: ./.github/workflows/e2e-test.yaml
11199
secrets: inherit
112100
with:
101+
environment: ${{ github.event.pull_request.head.repo.fork == true && 'prod-external' || 'prod' }}
113102
e2e-selector: ${{ matrix.flavor }}
114103
e2e-flags: ${{ matrix.flavor == 'quick' && '' || '--assert-timeout 20m0s'}}
115-
116-
117-
docker-build:
118-
runs-on: ubuntu-latest
119-
needs: changes
120-
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
121-
steps:
122-
- name: Harden Runner
123-
uses: step-security/harden-runner@v2
124-
with:
125-
disable-sudo: true
126-
egress-policy: block
127-
allowed-endpoints: >
128-
api.github.com:443
129-
github.com:443
130-
proxy.golang.org:443
131-
sum.golang.org:443
132-
go.dev:443
133-
dl.google.com:443
134-
golang.org:443
135-
objects.githubusercontent.com:443
136-
registry-1.docker.io:443
137-
auth.docker.io:443
138-
production.cloudflare.docker.com:443
139-
gcr.io:443
140-
storage.googleapis.com:443
141-
142-
- uses: actions/checkout@v4
143-
144-
- name: Docker cache
145-
uses: ScribeMD/docker-cache@0.5.0
146-
with:
147-
key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }}
148-
149-
- name: Build the Docker image
150-
run: make docker-build

.github/workflows/e2e-test.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
e2e-flags:
1212
type: string
1313
description: "Flags to pass to chainsaw when running e2e tests"
14+
environment:
15+
required: false
16+
type: string
17+
default: ''
1418
workflow_dispatch:
1519
inputs:
1620
e2e-selector:
@@ -42,7 +46,7 @@ permissions:
4246
actions: read
4347

4448
concurrency:
45-
group: e2e-${{ github.ref }}-${{ inputs.e2e-selector }}
49+
group: e2e-${{ inputs.e2e-selector }}-${{ github.event.pull_request.number || github.ref }}
4650
cancel-in-progress: true
4751

4852
jobs:
@@ -70,6 +74,7 @@ jobs:
7074
name: ${{ format('{0}-e2e-tests', inputs.e2e-selector) }}
7175
if: ${{contains(fromJSON(needs.changes.outputs.paths), 'src')}}
7276
runs-on: ubuntu-latest
77+
environment: ${{ inputs.environment }}
7378
env:
7479
GITHUB_TOKEN: ${{ secrets.github_token }}
7580
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build and Test PR
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
actions: read
11+
12+
concurrency:
13+
group: pull-request-ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
# Expose matched filters as job 'src' output variable
21+
paths: ${{ steps.filter.outputs.changes }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@v2
26+
with:
27+
disable-sudo: true
28+
egress-policy: block
29+
allowed-endpoints: >
30+
api.github.com:443
31+
github.com:443
32+
- uses: dorny/paths-filter@v3
33+
id: filter
34+
with:
35+
filters: .github/filters.yml
36+
37+
yamllint:
38+
runs-on: ubuntu-latest
39+
needs: changes
40+
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Validate YAML file
44+
run: yamllint templates
45+
46+
go-build-test:
47+
runs-on: ubuntu-latest
48+
needs: changes
49+
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
50+
steps:
51+
- name: Harden Runner
52+
uses: step-security/harden-runner@v2
53+
with:
54+
disable-sudo: true
55+
egress-policy: block
56+
allowed-endpoints: >
57+
api.github.com:443
58+
github.com:443
59+
golang.org:443
60+
proxy.golang.org:443
61+
sum.golang.org:443
62+
objects.githubusercontent.com:443
63+
storage.googleapis.com:443
64+
cli.codecov.io:443
65+
api.codecov.io:443
66+
ingest.codecov.io:443
67+
raw.githubusercontent.com:443
68+
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up Go
72+
uses: actions/setup-go@v5
73+
with:
74+
go-version-file: 'go.mod'
75+
check-latest: true
76+
77+
- name: Build
78+
run: make build
79+
80+
- name: Check for generated diff
81+
run: make check-gen-diff
82+
83+
- name: Test
84+
run: make test
85+
86+
docker-build:
87+
runs-on: ubuntu-latest
88+
needs: changes
89+
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
90+
steps:
91+
- name: Harden Runner
92+
uses: step-security/harden-runner@v2
93+
with:
94+
disable-sudo: true
95+
egress-policy: block
96+
allowed-endpoints: >
97+
api.github.com:443
98+
github.com:443
99+
proxy.golang.org:443
100+
sum.golang.org:443
101+
go.dev:443
102+
dl.google.com:443
103+
golang.org:443
104+
objects.githubusercontent.com:443
105+
registry-1.docker.io:443
106+
auth.docker.io:443
107+
production.cloudflare.docker.com:443
108+
gcr.io:443
109+
storage.googleapis.com:443
110+
111+
- uses: actions/checkout@v4
112+
113+
- name: Docker cache
114+
uses: ScribeMD/docker-cache@0.5.0
115+
with:
116+
key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }}
117+
118+
- name: Build the Docker image
119+
run: make docker-build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ release/*
1010
templates/cluster-template*.yaml
1111
infrastructure-*-linode/*
1212
.envrc
13+
vendor/

api/v1alpha2/linodemachine_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ type LinodeMachineSpec struct {
6565
BackupsEnabled bool `json:"backupsEnabled,omitempty"`
6666
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
6767
PrivateIP *bool `json:"privateIP,omitempty"`
68-
// Deprecated: spec.tags is deprecated, use metadata.annotations.linode-vm-tags instead.
69-
// +kubebuilder:deprecatedversion:warning="spec.tags is deprecated, use metadata.annotations.linode-vm-tags instead"
70-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
68+
// Tags is a list of tags to apply to the Linode instance.
7169
Tags []string `json:"tags,omitempty"`
7270
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
7371
FirewallID int `json:"firewallID,omitempty"`
@@ -225,6 +223,10 @@ type LinodeMachineStatus struct {
225223
// Conditions defines current service state of the LinodeMachine.
226224
// +optional
227225
Conditions []metav1.Condition `json:"conditions,omitempty"`
226+
227+
// tags are the tags applied to the Linode Machine.
228+
// +optional
229+
Tags []string `json:"tags,omitempty"`
228230
}
229231

230232
// +kubebuilder:object:root=true

api/v1alpha2/linodemachinetemplate_types.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ type LinodeMachineTemplateSpec struct {
2525
Template LinodeMachineTemplateResource `json:"template"`
2626
}
2727

28+
// LinodeMachineTemplateStatus defines the observed state of LinodeMachineTemplate
29+
// It is used to store the status of the LinodeMachineTemplate, such as tags.
30+
type LinodeMachineTemplateStatus struct {
31+
32+
// tags that are currently applied to the LinodeMachineTemplate.
33+
// +optional
34+
Tags []string `json:"tags,omitempty"`
35+
36+
// Conditions represent the latest available observations of a LinodeMachineTemplate's current state.
37+
// +optional
38+
Conditions []metav1.Condition `json:"conditions,omitempty"`
39+
}
40+
2841
// LinodeMachineTemplateResource describes the data needed to create a LinodeMachine from a template.
2942
type LinodeMachineTemplateResource struct {
3043
Spec LinodeMachineSpec `json:"spec"`
@@ -33,6 +46,7 @@ type LinodeMachineTemplateResource struct {
3346
// +kubebuilder:object:root=true
3447
// +kubebuilder:storageversion
3548
// +kubebuilder:resource:path=linodemachinetemplates,scope=Namespaced,categories=cluster-api,shortName=lmt
49+
// +kubebuilder:subresource:status
3650
// +kubebuilder:metadata:labels="clusterctl.cluster.x-k8s.io/move-hierarchy=true"
3751

3852
// LinodeMachineTemplate is the Schema for the linodemachinetemplates API
@@ -41,6 +55,29 @@ type LinodeMachineTemplate struct {
4155
metav1.ObjectMeta `json:"metadata,omitempty"`
4256

4357
Spec LinodeMachineTemplateSpec `json:"spec,omitempty"`
58+
59+
Status LinodeMachineTemplateStatus `json:"status,omitempty"`
60+
}
61+
62+
func (lmt *LinodeMachineTemplate) GetConditions() []metav1.Condition {
63+
for i := range lmt.Status.Conditions {
64+
if lmt.Status.Conditions[i].Reason == "" {
65+
lmt.Status.Conditions[i].Reason = DefaultConditionReason
66+
}
67+
}
68+
return lmt.Status.Conditions
69+
}
70+
71+
func (lmt *LinodeMachineTemplate) SetConditions(conditions []metav1.Condition) {
72+
lmt.Status.Conditions = conditions
73+
}
74+
75+
func (lmt *LinodeMachineTemplate) GetV1Beta2Conditions() []metav1.Condition {
76+
return lmt.GetConditions()
77+
}
78+
79+
func (lmt *LinodeMachineTemplate) SetV1Beta2Conditions(conditions []metav1.Condition) {
80+
lmt.SetConditions(conditions)
4481
}
4582

4683
// +kubebuilder:object:root=true

0 commit comments

Comments
 (0)