Add Forge metadata (#20)

Adds support for loading Forge metadata from env variables

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/20
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-committed-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
Lauris BH
2023-12-10 20:27:57 +00:00
committed by Lauris BH
parent 30c031631d
commit 93da4f40e1
5 changed files with 80 additions and 2 deletions
+9 -2
View File
@@ -48,7 +48,7 @@ func testMetadata() map[string]string {
"CI_COMMIT_URL": "https://codeberg.org/woodpecker-plugins/go-plugin/commit/a1b2c3d4",
// Build
"CI_PIPELINE_NUMBER": "1",
"CI_PIPELINE_EVENT": "push",
"CI_PIPELINE_EVENT": EventTypePush,
"CI_PIPELINE_URL": "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1",
"CI_PIPELINE_STATUS": "running",
"CI_PIPELINE_CREATED": "1611234567",
@@ -63,6 +63,9 @@ func testMetadata() map[string]string {
"CI_SYSTEM_URL": "https://ci.woodpecker-ci.org",
"CI_SYSTEM_VERSION": "1.0.0",
"CI_SYSTEM_HOST": "woodpecker-ci.org",
// Forge
"CI_FORGE_TYPE": ForgeTypeGitea,
"CI_FORGE_URL": "https://codeberg.org",
}
}
@@ -99,7 +102,7 @@ func TestMetadata(t *testing.T) {
// Pipeline
assert.Equal(t, int64(1), plugin.Metadata.Pipeline.Number)
assert.Equal(t, "push", plugin.Metadata.Pipeline.Event)
assert.Equal(t, EventTypePush, plugin.Metadata.Pipeline.Event)
assert.Equal(t, "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1", plugin.Metadata.Pipeline.Link)
assert.Equal(t, "running", plugin.Metadata.Pipeline.Status)
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Created)
@@ -114,4 +117,8 @@ func TestMetadata(t *testing.T) {
assert.Equal(t, "https://ci.woodpecker-ci.org", plugin.Metadata.System.Link)
assert.Equal(t, "1.0.0", plugin.Metadata.System.Version)
assert.Equal(t, "woodpecker-ci.org", plugin.Metadata.System.Host)
// Forge
assert.Equal(t, ForgeTypeGitea, plugin.Metadata.Forge.Type)
assert.Equal(t, "https://codeberg.org", plugin.Metadata.Forge.Link)
}