add filters

This commit is contained in:
2026-01-11 17:31:28 +08:00
parent b638d72402
commit 089e19c6eb
5 changed files with 107 additions and 47 deletions

View File

@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
imagePullSecrets:
- name: ghcr-secret

View File

@@ -1,2 +1,11 @@
resources: resources:
- manager.yaml - manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/bapung/gitea-runner-operator
newTag: sha-b638d72
patchesStrategicMerge:
- image_pull_secret_patch.yaml

View File

@@ -12,4 +12,4 @@ roleRef:
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: controller-manager name: controller-manager
namespace: system namespace: gitea-runner-operator-system

View File

@@ -1,3 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: gitea-credentials
labels:
app.kubernetes.io/name: gitea-runner-operator
app.kubernetes.io/managed-by: kustomize
stringData:
# The Gitea API Token (for the Operator to poll for jobs)
auth-token: "3430680995113a33a17715bb552882d504f5cf98"
# The Runner Registration Token (for the Runner to register itself)
registration-token: "5r4lpLA9rKCZZEHyUyKHeA187DoaElcTBySITRRi"
---
apiVersion: gitea.bpg.pw/v1alpha1 apiVersion: gitea.bpg.pw/v1alpha1
kind: RunnerGroup kind: RunnerGroup
metadata: metadata:
@@ -6,4 +19,28 @@ metadata:
app.kubernetes.io/managed-by: kustomize app.kubernetes.io/managed-by: kustomize
name: runnergroup-sample name: runnergroup-sample
spec: spec:
# TODO(user): Add fields here # The base URL of your Gitea instance
giteaURL: "https://gitea.bpg.pw"
# Scope of the runners (global, org, or repo)
scope: "repo"
org: "bapung" # Required if scope is 'org' or 'repo'
repo: "dummy-service-workflow" # Required if scope is 'repo'
# Labels to identify this runner group
labels:
- "linux"
- "amd64"
# Maximum number of runners to spawn concurrently
maxActiveRunners: 5
# Reference to the Secret containing the API token
authToken:
name: gitea-credentials
key: auth-token
# Reference to the Secret containing the Registration token
registrationToken:
name: gitea-credentials
key: registration-token

View File

@@ -153,6 +153,9 @@ func (c *HTTPClient) getQueuedRunsGlobal(ctx context.Context, giteaURL, authToke
// fetchWorkflowJobs fetches workflow jobs from a given endpoint with label filtering and pagination // fetchWorkflowJobs fetches workflow jobs from a given endpoint with label filtering and pagination
func (c *HTTPClient) fetchWorkflowJobs(ctx context.Context, endpoint, authToken string, labels []string) (int, error) { func (c *HTTPClient) fetchWorkflowJobs(ctx context.Context, endpoint, authToken string, labels []string) (int, error) {
totalCount := 0 totalCount := 0
statuses := []string{"queued", "waiting", "pending"}
for _, status := range statuses {
page := 1 page := 1
limit := 50 // Default page size limit := 50 // Default page size
@@ -162,7 +165,7 @@ func (c *HTTPClient) fetchWorkflowJobs(ctx context.Context, endpoint, authToken
return 0, err return 0, err
} }
q := u.Query() q := u.Query()
q.Set("status", "queued") q.Set("status", status)
q.Set("page", fmt.Sprintf("%d", page)) q.Set("page", fmt.Sprintf("%d", page))
q.Set("limit", fmt.Sprintf("%d", limit)) q.Set("limit", fmt.Sprintf("%d", limit))
u.RawQuery = q.Encode() u.RawQuery = q.Encode()
@@ -204,6 +207,7 @@ func (c *HTTPClient) fetchWorkflowJobs(ctx context.Context, endpoint, authToken
page++ page++
} }
}
return totalCount, nil return totalCount, nil
} }