chore: migrate agent repo references from GitHub to Codeberg

Updates all docs, UI copy, release checker, proto go_package,
container image refs, and tests to point at
codeberg.org/towerops-agent/towerops-agent. Also deletes stray
empty package.json/package-lock.json (Phoenix uses esbuild — no
npm) and an unused test_encode_decode.exs scratch file.
This commit is contained in:
Graham McIntire 2026-05-07 07:44:48 -05:00
parent 4a8d8cb208
commit 38375dcebb
12 changed files with 31 additions and 57 deletions

View file

@ -354,7 +354,7 @@ defmodule Towerops.Agents do
Broadcasts an update command to all connected agents.
1. Invalidates the release cache
2. Fetches the latest release from GitHub
2. Fetches the latest release from Codeberg
3. Finds all updatable agents
4. Sends update command to each agent matching their architecture

View file

@ -1,13 +1,14 @@
defmodule Towerops.Agents.ReleaseChecker do
@moduledoc """
Fetches latest release info from GitHub Releases API for the towerops-agent repo.
Fetches latest release info from the Codeberg (Forgejo) Releases API for the
towerops-agent repo.
Caches results for 5 minutes to avoid excessive API calls.
"""
require Logger
@github_repo "towerops-app/towerops-agent"
@codeberg_repo "towerops-agent/towerops-agent"
@cache_ttl_ms to_timeout(minute: 5)
@arch_map %{
@ -17,7 +18,7 @@ defmodule Towerops.Agents.ReleaseChecker do
@doc """
Clears the cached release info so the next call to `get_latest_release/0`
fetches fresh data from GitHub.
fetches fresh data from Codeberg.
"""
@spec invalidate_cache() :: :ok
def invalidate_cache do
@ -28,7 +29,7 @@ defmodule Towerops.Agents.ReleaseChecker do
end
@doc """
Returns the latest release info from GitHub.
Returns the latest release info from Codeberg.
Returns `{:ok, %{version: String.t(), assets: [asset]}}` where each asset
has `name`, `url`, and `checksum` fields.
@ -76,20 +77,20 @@ defmodule Towerops.Agents.ReleaseChecker do
end
defp fetch_and_cache do
url = "https://api.github.com/repos/#{@github_repo}/releases/latest"
url = "https://codeberg.org/api/v1/repos/#{@codeberg_repo}/releases/latest"
case req_get(url, headers: [{"accept", "application/vnd.github+json"}], retry: false) do
case req_get(url, headers: [{"accept", "application/json"}], retry: false) do
{:ok, %Req.Response{status: 200, body: body}} ->
release = parse_release(body)
:persistent_term.put({__MODULE__, :release}, {release, System.monotonic_time(:millisecond)})
{:ok, release}
{:ok, %Req.Response{status: status}} ->
Logger.warning("GitHub API returned status #{status} for latest release")
{:error, {:github_api, status}}
Logger.warning("Codeberg API returned status #{status} for latest release")
{:error, {:codeberg_api, status}}
{:error, reason} ->
Logger.warning("Failed to fetch latest release from GitHub: #{inspect(reason)}")
Logger.warning("Failed to fetch latest release from Codeberg: #{inspect(reason)}")
{:error, reason}
end
end

View file

@ -199,7 +199,7 @@
and starts collecting metrics. No firewall changes, no VPN, no open ports.
</p>
<div class="mt-6 rounded-lg bg-slate-900 dark:bg-black/50 dark:ring-1 dark:ring-white/10 p-4 font-mono text-sm text-green-400">
$ docker run -d towerops/agent
$ docker run -d codeberg.org/towerops-agent/towerops-agent
</div>
</div>
<!-- Step 2 -->

View file

@ -51,7 +51,12 @@ defmodule ToweropsWeb.AgentLive.Index do
offline_agents = Stats.get_offline_agents(organization.id)
# Get agent image URL from config or use default
agent_image = Application.get_env(:towerops, :agent_docker_image, "towerops/agent:latest")
agent_image =
Application.get_env(
:towerops,
:agent_docker_image,
"codeberg.org/towerops-agent/towerops-agent:latest"
)
{:ok,
socket

View file

@ -392,7 +392,7 @@ defmodule ToweropsWeb.HelpLive.Index do
<li>No data collection or sharing.</li>
<li>
Our remote agent is
<a href="https://github.com/towerops-app/towerops-agent/">
<a href="https://codeberg.org/towerops-agent/towerops-agent">
fully open source
</a>
and ONLY collects monitoring jobs from the server and WILL NEVER allow us to access any part of your internal network.
@ -977,7 +977,7 @@ defmodule ToweropsWeb.HelpLive.Index do
<div class="mt-3 p-4 bg-black rounded-lg not-prose overflow-x-auto">
<pre class="text-xs text-green-400 font-mono"><code><%= raw(~S[services:
towerops-agent:
image: ghcr.io/towerops-app/towerops-agent:latest
image: codeberg.org/towerops-agent/towerops-agent:latest
container_name: towerops-agent
restart: unless-stopped
environment:

View file

@ -345,7 +345,7 @@
-e TOWEROPS_TOKEN=<%= if @agent_token_value, do: @agent_token_value, else: "<your-token>" %> \
-e TOWEROPS_SERVER=<%= ToweropsWeb.Endpoint.url() %> \
--network host \
ghcr.io/towerops/agent:latest</code></pre>
codeberg.org/towerops-agent/towerops-agent:latest</code></pre>
</div>
<div>

6
package-lock.json generated
View file

@ -1,6 +0,0 @@
{
"name": "towerops-web",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

View file

@ -1 +0,0 @@
{}

View file

@ -2,7 +2,7 @@ syntax = "proto3";
package towerops.agent;
option go_package = "github.com/towerops-app/towerops-agent/pb";
option go_package = "codeberg.org/towerops-agent/towerops-agent/pb";
// Configuration received from the API
message AgentConfig {

View file

@ -14,7 +14,7 @@ defmodule Towerops.Agents.ReleaseCheckerTest do
describe "get_latest_release/0" do
test "returns release info from the configured test stub" do
Req.Test.stub(ReleaseChecker, fn conn ->
if conn.request_path == "/repos/towerops-app/towerops-agent/releases/latest" do
if conn.request_path == "/api/v1/repos/towerops-agent/towerops-agent/releases/latest" do
conn
|> Plug.Conn.put_resp_content_type("application/json")
|> Plug.Conn.send_resp(
@ -55,7 +55,7 @@ defmodule Towerops.Agents.ReleaseCheckerTest do
Plug.Conn.send_resp(conn, 503, "")
end)
assert {:error, {:github_api, 503}} = ReleaseChecker.get_latest_release()
assert {:error, {:codeberg_api, 503}} = ReleaseChecker.get_latest_release()
end
test "uses cached release info until invalidated" do
@ -80,8 +80,8 @@ defmodule Towerops.Agents.ReleaseCheckerTest do
assert release.version == "9.9.9"
assert cached_release == release
assert_receive {:release_request, "/repos/towerops-app/towerops-agent/releases/latest"}
refute_receive {:release_request, "/repos/towerops-app/towerops-agent/releases/latest"}
assert_receive {:release_request, "/api/v1/repos/towerops-agent/towerops-agent/releases/latest"}
refute_receive {:release_request, "/api/v1/repos/towerops-agent/towerops-agent/releases/latest"}
end
end

View file

@ -1981,7 +1981,9 @@ defmodule Towerops.AgentsTest do
{:ok, agent_token, _token} = Agents.create_agent_token(org.id, "Test Agent")
Phoenix.PubSub.subscribe(Towerops.PubSub, "agent:#{agent_token.id}:lifecycle")
url = "https://github.com/towerops-app/towerops-agent/releases/download/v0.2.0/towerops-agent-linux-amd64"
url =
"https://codeberg.org/towerops-agent/towerops-agent/releases/download/v0.2.0/towerops-agent-linux-amd64"
checksum = "abc123def456"
assert :ok = Agents.update_agent(agent_token.id, url, checksum)
@ -1991,8 +1993,8 @@ defmodule Towerops.AgentsTest do
end
describe "broadcast_mass_update/0" do
test "returns error when GitHub API is unavailable" do
# In test environment, GitHub returns 404 for the private repo
test "returns error when Codeberg API is unavailable" do
# In test environment, Codeberg returns 404 for the private repo
assert {:error, _reason} = Agents.broadcast_mass_update()
end
end

View file

@ -1,27 +0,0 @@
alias Towerops.Agent.SnmpResult
result = %SnmpResult{
device_id: "550e8400-e29b-41d4-a716-446655440000",
job_type: :POLL,
job_id: "test",
timestamp: 1_234_567_890,
oid_values: %{"1.2.3" => "test"}
}
IO.puts("Original: #{inspect(result)}")
binary = SnmpResult.encode(result)
IO.puts("Encoded to #{byte_size(binary)} bytes")
case SnmpResult.decode(binary) do
{:ok, decoded} ->
IO.puts("Decoded successfully!")
IO.puts(" device_id: #{decoded.device_id}")
IO.puts(" job_type: #{inspect(decoded.job_type)}")
IO.puts(" job_id: #{decoded.job_id}")
IO.puts(" timestamp: #{decoded.timestamp}")
IO.puts(" oid_values: #{inspect(decoded.oid_values)}")
{:error, reason} ->
IO.puts("Decode failed: #{inspect(reason)}")
end