From de23eb8e6c6fbb27d41872a10b7fe2dd75760dff Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Wed, 9 Oct 2024 14:38:33 -0500 Subject: [PATCH 1/2] owner check for receiver --- plugins/receivers/github/github.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/receivers/github/github.go b/plugins/receivers/github/github.go index 2e1dc69..c33dbb5 100644 --- a/plugins/receivers/github/github.go +++ b/plugins/receivers/github/github.go @@ -137,10 +137,13 @@ func Run( }, ) + configFileName := config.GetConfigFileNameFromContext(pluginCtx) if ctxPlugin.Token == "" && ctxPlugin.PrivateKey == "" { - configFileName := config.GetConfigFileNameFromContext(pluginCtx) logging.Panic(workerCtx, pluginCtx, "token or private_key are not set at global level or in "+configFileName+":plugins:"+ctxPlugin.Name+"") } + if ctxPlugin.Owner == "" { + logging.Panic(workerCtx, pluginCtx, "owner is not set in "+configFileName+":plugins:"+ctxPlugin.Name+"") + } databaseContainer, err := database.GetDatabaseFromContext(pluginCtx) if err != nil { From 8596bb4701f6ef5646af784e2168a366a8df7d26 Mon Sep 17 00:00:00 2001 From: Nathan Pierce Date: Thu, 10 Oct 2024 15:49:49 -0500 Subject: [PATCH 2/2] removed unique-id and run-id --- .github/workflows/t1-failure-no-tag.yml | 2 -- .github/workflows/t1-failure-no-template.yml | 2 -- .github/workflows/t1-failure-tag-1-in-vm.yml | 2 -- .github/workflows/t1-with-tag-1.yml | 2 -- .github/workflows/t1-with-tag-2.yml | 2 -- .github/workflows/t1-without-tag.yml | 4 +--- .github/workflows/t2-dual-without-tag.yml | 4 ---- VERSION | 2 +- plugins/handlers/github/README.md | 6 ++--- plugins/handlers/github/github.go | 24 ++++++++++---------- 10 files changed, 16 insertions(+), 34 deletions(-) diff --git a/.github/workflows/t1-failure-no-tag.yml b/.github/workflows/t1-failure-no-tag.yml index a7d9b52..9469480 100644 --- a/.github/workflows/t1-failure-no-tag.yml +++ b/.github/workflows/t1-failure-no-tag.yml @@ -9,8 +9,6 @@ jobs: "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", "anka-template-tag:not-a-tag", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t1-failure-no-template.yml b/.github/workflows/t1-failure-no-template.yml index 0a3ce0f..2be5bc8 100644 --- a/.github/workflows/t1-failure-no-template.yml +++ b/.github/workflows/t1-failure-no-template.yml @@ -9,8 +9,6 @@ jobs: "anka", "anka-template:c092c6f6-198c-470f-9526-9c998efe7ab5", "anka-template-tag:vanilla+port-forward-22+brew-git", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t1-failure-tag-1-in-vm.yml b/.github/workflows/t1-failure-tag-1-in-vm.yml index bae920f..b3c5c5e 100644 --- a/.github/workflows/t1-failure-tag-1-in-vm.yml +++ b/.github/workflows/t1-failure-tag-1-in-vm.yml @@ -9,8 +9,6 @@ jobs: "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", "anka-template-tag:vanilla+port-forward-22+brew-git", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t1-with-tag-1.yml b/.github/workflows/t1-with-tag-1.yml index 43ff9e4..de2cb10 100644 --- a/.github/workflows/t1-with-tag-1.yml +++ b/.github/workflows/t1-with-tag-1.yml @@ -9,8 +9,6 @@ jobs: "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", "anka-template-tag:vanilla+port-forward-22+brew-git", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t1-with-tag-2.yml b/.github/workflows/t1-with-tag-2.yml index 41213d3..621912b 100644 --- a/.github/workflows/t1-with-tag-2.yml +++ b/.github/workflows/t1-with-tag-2.yml @@ -9,8 +9,6 @@ jobs: "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", "anka-template-tag:vanilla+port-forward-22", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t1-without-tag.yml b/.github/workflows/t1-without-tag.yml index 52040aa..fca87d5 100644 --- a/.github/workflows/t1-without-tag.yml +++ b/.github/workflows/t1-without-tag.yml @@ -7,9 +7,7 @@ jobs: runs-on: [ "self-hosted", "anka", - "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", - "run-id:${{ github.run_id }}", - "unique-id:1" + "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/t2-dual-without-tag.yml b/.github/workflows/t2-dual-without-tag.yml index 692b1ea..f362b92 100644 --- a/.github/workflows/t2-dual-without-tag.yml +++ b/.github/workflows/t2-dual-without-tag.yml @@ -8,8 +8,6 @@ jobs: "self-hosted", "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 @@ -23,8 +21,6 @@ jobs: "self-hosted", "anka", "anka-template:6abae54f-025d-4a27-b5eb-b985d5eddac9", - "run-id:${{ github.run_id }}", - "unique-id:2" ] steps: - uses: actions/checkout@v3 diff --git a/VERSION b/VERSION index 79a2734..09a3acf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 \ No newline at end of file +0.6.0 \ No newline at end of file diff --git a/plugins/handlers/github/README.md b/plugins/handlers/github/README.md index 20be701..23bb060 100644 --- a/plugins/handlers/github/README.md +++ b/plugins/handlers/github/README.md @@ -43,8 +43,8 @@ Next, in your workflow yml you need to add several labels to `runs-on`. Here is 1. `anka` (required) 1. `anka-template:{UUID OF TEMPLATE HERE}` (required) 1. `anka-template-tag:{TAG NAME OF TEMPLATE HERE}` (optional; uses latest if not populated) -1. `run-id:${{ github.run_id }}` (do not change this) - label that is used to ensure that jobs in the same workspace don't compete for the same runner. -1. `unique-id:{UNIQUE ID OF JOB HERE}` - a label that is used to ensure multiple jobs in the same run don't compete for the same runner. + + (from [t1-with-tag-1.yml](.github/workflows/t1-with-tag-1.yml)) @@ -60,8 +60,6 @@ jobs: "anka", "anka-template:d792c6f6-198c-470f-9526-9c998efe7ab4", "anka-template-tag:vanilla+port-forward-22+brew-git", - "run-id:${{ github.run_id }}", - "unique-id:1" ] steps: - uses: actions/checkout@v3 diff --git a/plugins/handlers/github/github.go b/plugins/handlers/github/github.go index 7535cc1..90e5b46 100644 --- a/plugins/handlers/github/github.go +++ b/plugins/handlers/github/github.go @@ -29,9 +29,9 @@ type WorkflowRunJobDetail struct { AnkaTemplate string AnkaTemplateTag string RunID int64 - UniqueID string - Labels []string - Repo string + // UniqueID string + Labels []string + Repo string } // func exists_in_array_exact(array_to_search_in []string, desired []string) bool { @@ -638,12 +638,12 @@ func Run( // get the unique unique-id for this job // this ensures that multiple jobs in the same workflow run don't compete for the same runner - uniqueID := extractLabelValue(queuedJob.WorkflowJob.Labels, "unique-id:") - if uniqueID == "" { - logger.WarnContext(pluginCtx, "unique-id label not found or empty; something wrong with your workflow yaml") - return - } - pluginCtx = logging.AppendCtx(pluginCtx, slog.String("uniqueID", uniqueID)) + // uniqueID := extractLabelValue(queuedJob.WorkflowJob.Labels, "unique-id:") + // if uniqueID == "" { + // logger.WarnContext(pluginCtx, "unique-id label not found or empty; something wrong with your workflow yaml") + // return + // } + // pluginCtx = logging.AppendCtx(pluginCtx, slog.String("uniqueID", uniqueID)) ankaTemplate := extractLabelValue(queuedJob.WorkflowJob.Labels, "anka-template:") if ankaTemplate == "" { logger.WarnContext(pluginCtx, "warning: unable to find Anka Template specified in labels - skipping") @@ -664,9 +664,9 @@ func Run( AnkaTemplate: ankaTemplate, AnkaTemplateTag: ankaTemplateTag, RunID: *queuedJob.WorkflowJob.RunID, - UniqueID: uniqueID, - Labels: queuedJob.WorkflowJob.Labels, - Repo: *queuedJob.Repo.Name, + // UniqueID: uniqueID, + Labels: queuedJob.WorkflowJob.Labels, + Repo: *queuedJob.Repo.Name, } // get anka CLI