Compare commits

..

No commits in common. "master" and "wip-gitea" have entirely different histories.

36 changed files with 274 additions and 289 deletions

View File

@ -3,5 +3,5 @@ export db=""
export STRIPE_SECRET_KEY="" export STRIPE_SECRET_KEY=""
export STRIPE_PUBLIC_KEY="" export STRIPE_PUBLIC_KEY=""
export HOSTEA_INFRA_HOSTEA_REPO_REMOTE="ssh://git@localhost:22/hostea/fleet.git" export HOSTEA_INFRA_HOSTEA_REPO_REMOTE="ssh://git@localhost:22/hostea/fleet.git"
export HOSTEA_META_FORGEJO_INSTANCE="http://localhost:3000" export HOSTEA_META_GITEA_INSTANCE="http://localhost:3000"
export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)" export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)"

View File

@ -4,8 +4,8 @@ pipeline:
environment: environment:
- DATABSE_URL=postgres://postgres:password@database:5432/postgres - DATABSE_URL=postgres://postgres:password@database:5432/postgres
- EMAIL_URL=smtp://admin:password@smtp:10025 - EMAIL_URL=smtp://admin:password@smtp:10025
- HOSTEA_INFRA_HOSTEA_REPO_REMOTE=ssh://git@forgejo:22/hostea/ - HOSTEA_INFRA_HOSTEA_REPO_REMOTE=ssh://git@gitea:22/hostea/
- HOSTEA_META_FORGEJO_INSTANCE=http://forgejo:3000 - HOSTEA_META_GITEA_INSTANCE=http://gitea:3000
commands: commands:
- export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)" - export HOSTEA_INFRA_HOSTEA_REPO_SSH_KEY="$(realpath ./tests/fleet-deploy-key)"
- pip install virtualenv - pip install virtualenv
@ -21,9 +21,9 @@ services:
environment: environment:
- POSTGRES_PASSWORD=password - POSTGRES_PASSWORD=password
forgejo: gitea:
image: codeberg.org/forgejo/forgejo:1.18.0-1 image: gitea/gitea:1.16.5
container_name: hostea-dash-forgejo container_name: hostea-dash-gitea
smtp: smtp:
image: maildev/maildev:latest image: maildev/maildev:latest

View File

@ -1,6 +1,6 @@
FROM python FROM python
LABEL org.opencontainers.image.source https://forgejo.hostea.org/Hostea/dashboard LABEL org.opencontainers.image.source https://gitea.hostea.org/Hostea/dashboard
RUN useradd -ms /bin/bash -u 1001 hostea RUN useradd -ms /bin/bash -u 1001 hostea
RUN apt-get update && apt-get install -y ca-certificates git RUN apt-get update && apt-get install -y ca-certificates git

View File

@ -6,13 +6,13 @@
<main class="auth__main"> <main class="auth__main">
<section class="main"> <section class="main">
<div class="title"> <div class="title">
<h1><a href="https://forgejo.org">Forgejo</a> hosting and <a href="/forgejo-clinic/">service</a></h1> <h1><a href="https://gitea.io">Gitea</a> hosting and <a href="/gitea-clinic/">service</a></h1>
<p class="welcome"> <p class="welcome">
A free forge ecosystem for free developers. A free forge ecosystem for free developers.
</p> </p>
<ul class="index-banner__features-list"> <ul class="index-banner__features-list">
<li class="index-banner__features">Dedicated <a href="https://hosteadashboard.gna.org/register/">Forgejo hosting</a> and <a href="https://woodpecker-ci.org/">Woodpecker CI</a> from 10€/month</li> <li class="index-banner__features">Dedicated <a href="https://hosteadashboard.gna.org/register/">Gitea hosting</a> and <a href="https://woodpecker-ci.org/">Woodpecker CI</a> from 10€/month</li>
<li class="index-banner__features">Clinic to <a href="https://gna.org/forgejo-clinic/">heal sick Forgejo</a> instances</li> <li class="index-banner__features">Clinic to <a href="https://gna.org/gitea-clinic/">heal sick Gitea</a> instances</li>
<li class="index-banner__features">100% <a href="https://www.gnu.org/philosophy/free-sw.html">Free Software</a></li> <li class="index-banner__features">100% <a href="https://www.gnu.org/philosophy/free-sw.html">Free Software</a></li>
<li class="index-banner__features">Radically <a href="https://forum.gna.org/t/about-governance-and-decisions-in-hostea/55">Transparent</a></li> <li class="index-banner__features">Radically <a href="https://forum.gna.org/t/about-governance-and-decisions-in-hostea/55">Transparent</a></li>
<li class="index-banner__features">Run by a <a href="https://forum.gna.org/t/about-governance-and-decisions-in-hostea/55">horizontal collective</a></li> <li class="index-banner__features">Run by a <a href="https://forum.gna.org/t/about-governance-and-decisions-in-hostea/55">horizontal collective</a></li>

View File

@ -59,7 +59,7 @@ class Command(BaseCommand):
sender = settings.DEFAULT_FROM_EMAIL sender = settings.DEFAULT_FROM_EMAIL
send_mail( send_mail(
subject="[Gna!] Payment receipt for your Gna! VM", subject="[Gna!] Payment receipt your Gna! VM",
message=body, message=body,
from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py
recipient_list=[email], recipient_list=[email],

View File

@ -95,7 +95,7 @@ class BillingTest(TestCase):
# sent when the invoice is generated and one after payment is made # sent when the invoice is generated and one after payment is made
# #
# So we are first checking for the last email that was sent(receipt) # So we are first checking for the last email that was sent(receipt)
# and then the Forgejo instance credentials notification followed by the # and then the Gitea instance credentials notification followed by the
# invoice generation email. # invoice generation email.
receipt_mail = mail.outbox.pop() receipt_mail = mail.outbox.pop()
print(receipt_mail.body) print(receipt_mail.body)

View File

@ -128,7 +128,7 @@ def payment_success(request, payment_public_id):
sender = settings.DEFAULT_FROM_EMAIL sender = settings.DEFAULT_FROM_EMAIL
send_mail( send_mail(
subject="[Gna!] Payment receipt for your Gna! VM", subject="[Gna!] Payment receipt your Gna! VM",
message=body, message=body,
from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py
recipient_list=[email], recipient_list=[email],

View File

@ -12,7 +12,7 @@
</ul> </ul>
<p>Created On: {{ instance.created_at }}</p> <p>Created On: {{ instance.created_at }}</p>
<p><a href="{{forgejo_uri}}">Forgejo Instance</a>|<a href="{{woodpecker}}">Woodpecker CI</a></p> <p><a href="{{gitea_uri}}">Gitea Instance</a>|<a href="{{woodpecker}}">Woodpecker CI</a></p>
<form <form
action="{% url 'dash.instances.delete' name=instance.name %}" action="{% url 'dash.instances.delete' name=instance.name %}"

View File

@ -30,7 +30,7 @@ from payments import get_payment_model, RedirectNeeded, PaymentStatus
from accounts.tests import login_util, register_util from accounts.tests import login_util, register_util
from .models import InstanceConfiguration, Instance from .models import InstanceConfiguration, Instance
from .utils import create_instance, sanitize_vm_name, VmErrors, VmException from .utils import create_instance, VmErrors, VmException
def create_configurations(t: TestCase): def create_configurations(t: TestCase):
@ -171,7 +171,7 @@ class InstancesConfig(TestCase):
""" """
Expects InstancesConfig titled "s1-2", "s1-4" and "s1-8" Expects InstancesConfig titled "s1-2", "s1-4" and "s1-8"
ref: https://forgejo.gna.org/Hostea/july-mvp/issues/10#issuecomment-639 ref: https://gitea.gna.org/Hostea/july-mvp/issues/10#issuecomment-639
""" """
self.assertEqual( self.assertEqual(
InstanceConfiguration.objects.filter( InstanceConfiguration.objects.filter(
@ -198,21 +198,11 @@ class CreateInstance(TestCase):
register_util(t=self, username="createinstance_user") register_util(t=self, username="createinstance_user")
create_configurations(t=self) create_configurations(t=self)
def test_sanitize_vm_name(self):
self.assertEqual(sanitize_vm_name(vm_name="LOWERname"), "lowername")
with self.assertRaises(VmException):
sanitize_vm_name(vm_name="12345452131324234234234234")
with self.assertRaises(VmException):
sanitize_vm_name(vm_name="122342$#34234")
@override_settings( @override_settings(
HOSTEA=infra_custom_config(test_name="test_create_instance_util") HOSTEA=infra_custom_config(test_name="test_create_instance_util")
) )
def test_create_instance_util(self): def test_create_instance_util(self):
vm_name = "test_create_instance_renders"
configuration = self.instance_config[0].name configuration = self.instance_config[0].name
with self.assertRaises(VmException): with self.assertRaises(VmException):
@ -222,6 +212,13 @@ class CreateInstance(TestCase):
user=self.user, user=self.user,
) )
with self.assertRaises(VmException):
create_instance(
vm_name="122342$#34234",
configuration_name=configuration,
user=self.user,
)
@override_settings( @override_settings(
HOSTEA=infra_custom_config(test_name="test_create_instance_renders") HOSTEA=infra_custom_config(test_name="test_create_instance_renders")
) )

View File

@ -43,13 +43,11 @@ class VmException(Exception):
return self.error return self.error
def sanitize_vm_name(vm_name: str) -> str: def create_instance(vm_name: str, configuration_name: str, user: User) -> Instance:
""" """
Sanity checks and normalization of the vm name Create instance view
""" """
vm_name = vm_name.lower()
if len(vm_name) > 20: if len(vm_name) > 20:
raise VmException(code=VmErrors.NAME_TOO_LONG) raise VmException(code=VmErrors.NAME_TOO_LONG)
if not str.isalnum(vm_name): if not str.isalnum(vm_name):
@ -58,16 +56,6 @@ def sanitize_vm_name(vm_name: str) -> str:
if Instance.objects.filter(name=vm_name).exists(): if Instance.objects.filter(name=vm_name).exists():
raise VmException(code=VmErrors.NAME_EXISTS) raise VmException(code=VmErrors.NAME_EXISTS)
return vm_name
def create_instance(vm_name: str, configuration_name: str, user: User) -> Instance:
"""
Create instance view
"""
vm_name = sanitize_vm_name(vm_name)
if not InstanceConfiguration.objects.filter(name=configuration_name).exists(): if not InstanceConfiguration.objects.filter(name=configuration_name).exists():
raise VmException(code=VmErrors.NO_CONFIG) raise VmException(code=VmErrors.NO_CONFIG)
@ -89,7 +77,7 @@ def footer_ctx():
"link": settings.HOSTEA["SOURCE_CODE"], "link": settings.HOSTEA["SOURCE_CODE"],
} }
else: else:
link = "https://forgejo.gna.org/Hostea/dashboard" link = "https://gitea.gna.org/Hostea/dashboard"
source_code = {"text": "Source Code", "link": link} source_code = {"text": "Source Code", "link": link}
try: try:
r = Repo(".") r = Repo(".")

View File

@ -117,12 +117,12 @@ def view_instance(request, name: str):
instance = get_object_or_404(Instance, owned_by=user, name=name) instance = get_object_or_404(Instance, owned_by=user, name=name)
ctx = default_ctx(title=PAGE_TITLE, username=user.username) ctx = default_ctx(title=PAGE_TITLE, username=user.username)
instance.configuration = instance.configuration_id instance.configuration = instance.configuration_id
forgejo_uri = Infra.get_forgejo_uri(instance=instance) gitea_uri = Infra.get_gitea_uri(instance=instance)
woodpecker = Infra.get_woodpecker_uri(instance=instance) woodpecker = Infra.get_woodpecker_uri(instance=instance)
ctx["instance"] = instance ctx["instance"] = instance
ctx["woodpecker"] = woodpecker ctx["woodpecker"] = woodpecker
ctx["forgejo_uri"] = forgejo_uri ctx["gitea_uri"] = gitea_uri
return render(request, "dash/instances/view/index.html", context=ctx) return render(request, "dash/instances/view/index.html", context=ctx)

View File

@ -44,8 +44,8 @@ PAYMENT_VARIANTS = {
"stripe": ( "stripe": (
"payments.stripe.StripeProvider", # please don't change this "payments.stripe.StripeProvider", # please don't change this
{ {
"secret_key": env.get_value("STRIPE_SECRET_KEY", default="UNSET"), "secret_key": env.get_value("STRIPE_SECRET_KEY"),
"public_key": env.get_value("STRIPE_PUBLIC_KEY", default="UNSET"), "public_key": env.get_value("STRIPE_PUBLIC_KEY"),
}, },
) )
} }
@ -54,19 +54,19 @@ PAYMENT_VARIANTS = {
### Dashbaord specific configuration options ### Dashbaord specific configuration options
HOSTEA = { HOSTEA = {
"SOURCE_CODE": "https://forgejo.gna.org/Hostea/dashboard", "SOURCE_CODE": "https://gitea.gna.org/Hostea/dashboard",
"INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org", "INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org",
"ACCOUNTS": { "ACCOUNTS": {
"MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds "MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds
"SUDO_TTL": 60 * 5, "SUDO_TTL": 60 * 5,
}, },
"META": { "META": {
"FORGEJO_INSTANCE": env.get_value( "GITEA_INSTANCE": env.get_value(
"HOSTEA_META_FORGEJO_INSTANCE" "HOSTEA_META_GITEA_INSTANCE"
), # meta Forgejo insatnce ), # meta Gitea insatnce
"FORGEJO_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance "GITEA_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance
# Repository dedicated for handling support # Repository dedicated for handling support
# ref: https://forgejo.gna.org/Hostea/july-mvp/issues/17 # ref: https://gitea.gna.org/Hostea/july-mvp/issues/17
"SUPPORT_REPOSITORY": "support", "SUPPORT_REPOSITORY": "support",
}, },
"INFRA": { "INFRA": {

View File

@ -53,17 +53,17 @@ PAYMENT_VARIANTS = {
### Dashbaord specific configuration options ### Dashbaord specific configuration options
HOSTEA = { HOSTEA = {
"SOURCE_CODE": "https://forgejo.gna.org/Hostea/dashboard", "SOURCE_CODE": "https://gitea.gna.org/Hostea/dashboard",
"INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org", "INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org",
"ACCOUNTS": { "ACCOUNTS": {
"MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds "MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds
"SUDO_TTL": 60 * 5, "SUDO_TTL": 60 * 5,
}, },
"META": { "META": {
"FORGEJO_INSTANCE": "https://forgejo.gna.org", # meta Forgejo insatnce "GITEA_INSTANCE": "https://gitea.gna.org", # meta Gitea insatnce
"FORGEJO_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance "GITEA_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance
# Repository dedicated for handling support # Repository dedicated for handling support
# ref: https://forgejo.gna.org/Hostea/july-mvp/issues/17 # ref: https://gitea.gna.org/Hostea/july-mvp/issues/17
"SUPPORT_REPOSITORY": "support", "SUPPORT_REPOSITORY": "support",
}, },
"INFRA": { "INFRA": {

View File

@ -171,7 +171,7 @@ PAYMENT_VARIANTS = {
### Dashbaord specific configuration options ### Dashbaord specific configuration options
HOSTEA = { HOSTEA = {
"SOURCE_CODE": "https://forgejo.gna.org/Hostea/dashboard", "SOURCE_CODE": "https://gitea.gna.org/Hostea/dashboard",
"RESTRICT_NEW_INTEGRATION_INSTALLATION": True, "RESTRICT_NEW_INTEGRATION_INSTALLATION": True,
"INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org", "INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org",
"ACCOUNTS": { "ACCOUNTS": {
@ -179,10 +179,10 @@ HOSTEA = {
"SUDO_TTL": 60 * 5, "SUDO_TTL": 60 * 5,
}, },
"META": { "META": {
"FORGEJO_INSTANCE": "http://localhost:3000", # meta Forgejo insatnce "GITEA_INSTANCE": "http://localhost:3000", # meta Gitea insatnce
"FORGEJO_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance "GITEA_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance
# Repository dedicated for handling support # Repository dedicated for handling support
# ref: https://forgejo.gna.org/Hostea/july-mvp/issues/17 # ref: https://gitea.gna.org/Hostea/july-mvp/issues/17
"SUPPORT_REPOSITORY": "support", "SUPPORT_REPOSITORY": "support",
}, },
"INFRA": { "INFRA": {

View File

@ -1,23 +1,23 @@
version: "3" version: "3"
#networks: #networks:
# hostea-dash-forgejo: # hostea-dash-gitea:
# external: false # external: false
# hostea-dash-smtp: # hostea-dash-smtp:
# external: false # external: false
services: services:
forgejo: gitea:
image: codeberg.org/forgejo/forgejo:1.18.0-1 image: gitea/gitea:1.16.5
container_name: hostea-dash-forgejo container_name: hostea-dash-gitea
network_mode: host network_mode: host
environment: environment:
- USER_UID=1000 - USER_UID=1000
- USER_GID=1000 - USER_GID=1000
restart: always restart: always
#networks: #networks:
# - hostea-dash-forgejo # - hostea-dash-gitea
volumes: volumes:
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro

View File

@ -15,7 +15,7 @@
1. Clone the project 1. Clone the project
```bash ```bash
git clone https://forgejo.gna.org/Hostea/dashboard.git && cd dashboard git clone https://gitea.gna.org/Hostea/dashboard.git && cd dashboard
``` ```
2. Create `virtualenv` and activate environment 2. Create `virtualenv` and activate environment

View File

@ -44,8 +44,8 @@ hence the current redundancy in configuration and cronjob duration.
## Support Platform Integration ## Support Platform Integration
Hostea Dashbaord delegates support to Hostea's meta Forgejo instance, as Hostea Dashbaord delegates support to Hostea's meta Gitea instance, as
discussed [here](https://forgejo.gna.org/Hostea/july-mvp/issues/17). discussed [here](https://gitea.gna.org/Hostea/july-mvp/issues/17).
To configure support platform integration , please set the following To configure support platform integration , please set the following
attributes in `settings.py`: attributes in `settings.py`:
@ -55,10 +55,10 @@ HOSTEA = {
# <--snip---> # <--snip--->
"META": { "META": {
# <--snip---> # <--snip--->
"FORGEJO_INSTANCE": "https://forgejo.gna.org", # meta Forgejo insatnce "GITEA_INSTANCE": "https://gitea.gna.org", # meta Gitea insatnce
"FORGEJO_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance "GITEA_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance
# Repository dedicated for handling support # Repository dedicated for handling support
# ref: https://forgejo.gna.org/Hostea/july-mvp/issues/17 # ref: https://gitea.gna.org/Hostea/july-mvp/issues/17
"SUPPORT_REPOSITORY": "support", "SUPPORT_REPOSITORY": "support",
}, },
} }

View File

@ -93,9 +93,9 @@ class Command(BaseCommand):
instance = create_instance( instance = create_instance(
vm_name=vm_name, configuration_name=size, user=user vm_name=vm_name, configuration_name=size, user=user
) )
(forgejo_password, _commit) = create_vm_if_not_exists(instance) (gitea_password, _commit) = create_vm_if_not_exists(instance)
print("Instance created") print("Instance created")
print(f"Forgejo admin password: {forgejo_password}") print(f"Gitea admin password: {gitea_password}")
except VmException as e: except VmException as e:
if e.code == VmErrors.NAME_EXISTS: if e.code == VmErrors.NAME_EXISTS:
instance = Instance.objects.get(name=vm_name) instance = Instance.objects.get(name=vm_name)
@ -104,9 +104,9 @@ class Command(BaseCommand):
name=size name=size
) )
instance.save() instance.save()
(forgejo_password, _commit) = create_vm_if_not_exists(instance) (gitea_password, _commit) = create_vm_if_not_exists(instance)
print("Instance created") print("Instance created")
print(f"Forgejo admin password: {forgejo_password}") print(f"Gitea admin password: {gitea_password}")
else: else:
self.stderr.write(self.style.ERROR(f"error: {str(e)}")) self.stderr.write(self.style.ERROR(f"error: {str(e)}"))

View File

@ -6,13 +6,13 @@ Your Gna! instance is being prepared, you will receive an email
notification when it is ready. notification when it is ready.
You can use the following credentials to log into an admin account on You can use the following credentials to log into an admin account on
your new Gna! Forgejo instance. Great powers come with great your new Gna! Gitea instance. Great powers come with great
responsibilities, so use the admin credentials wisely. When in doubt, responsibilities, so use the admin credentials wisely. When in doubt,
consult the Forgejo docs or contact support! consult the Gitea docs or contact support!
- username : root - username : root
- password: {{ forgejo_password }} - password: {{ gitea_password }}
- Forgejo {{ forgejo_uri }} - Gitea {{ gitea_uri }}
Cheers, Cheers,
Gna! team Gna! team

View File

@ -4,7 +4,7 @@ The deployment job has run to completion and your Gna! instance is now online!
Credentials to admin account was sent in an earlier email, please contact Credentials to admin account was sent in an earlier email, please contact
support if didn't receive it. support if didn't receive it.
Forgejo: {{ forgejo_uri }} Gitea: {{ gitea_uri }}
Woodpecker CI: {{ woodpecker_uri }} Woodpecker CI: {{ woodpecker_uri }}
Cheers, Cheers,

View File

@ -3,7 +3,7 @@ Hello {{ username }}!,
A customer has purchased a new instance. Please find the details below: A customer has purchased a new instance. Please find the details below:
Forgejo: {{ forgejo_uri }} Gitea: {{ gitea_uri }}
Woodpecker CI: {{ woodpecker_uri }} Woodpecker CI: {{ woodpecker_uri }}
Cheers, Cheers,

View File

@ -1,11 +1,11 @@
{% extends 'dash/common/base.html' %} {% block dash %} {% extends 'dash/common/base.html' %} {% block dash %}
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<h2>Forgejo Admin Credentials</h2> <h2>Gitea Admin Credentials</h2>
<ul> <ul>
<li><b>Username:</b> root</li> <li><b>Username:</b> root</li>
<li><b>Password:</b> {{ forgejo_password }}</li> <li><b>Password:</b> {{ gitea_password }}</li>
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -1,2 +1,2 @@
enough --domain $domain host create {{subdomain}}-host enough --domain $domain host create {{subdomain}}-host
enough --domain $domain service create --host {{subdomain}}-host forgejo enough --domain $domain service create --host {{subdomain}}-host gitea

View File

@ -2,49 +2,49 @@
# #
####################################### #######################################
# #
# Public hostname of the Forgejo instance # Public hostname of the Gitea instance
# #
# #
forgejo_host: "{{ subdomain }}.{{ '{' }}{{ '{' }} domain {{ '}' }}{{ '}' }}" gitea_host: "{{ subdomain }}.{{ '{' }}{{ '{' }} domain {{ '}' }}{{ '}' }}"
# #
####################################### #######################################
# #
# Mailer from # Mailer from
# #
# #
forgejo_mailer_from: "noreply@{{ '{' }}{{ '{' }} domain {{ '}' }}{{ '}' }}" gitea_mailer_from: "noreply@{{ '{' }}{{ '{' }} domain {{ '}' }}{{ '}' }}"
# #
####################################### #######################################
# #
# SSH port of the Forgejo instance # SSH port of the Gitea instance
# #
# #
forgejo_ssh_port: "22" gitea_ssh_port: "22"
# #
####################################### #######################################
# #
# Forgejo version # Gitea version
# #
# #
#forgejo_version: "1.18.0-1" #gitea_version: "1.16.8"
# #
####################################### #######################################
# #
# Admin user name # Admin user name
# #
forgejo_user: root gitea_user: root
# #
####################################### #######################################
# #
# Admin user password # Admin user password
# #
forgejo_password: "{{ forgejo_password }}" gitea_password: "{{ gitea_password }}"
# #
####################################### #######################################
# #
# Admin user email # Admin user email
# #
forgejo_email: "{{ forgejo_email }}" gitea_email: "{{ gitea_email }}"
# #
####################################### #######################################
# #
@ -60,9 +60,9 @@ woodpecker_host: "{{ '{' }}{{ '{' }} woodpecker_hostname {{ '}' }}{{ '}' }}.{{ '
# #
####################################### #######################################
# #
# Forgejo users with admin rights on woodpecker # Gitea users with admin rights on woodpecker
# #
woodpecker_admins: "{{ '{' }}{{ '{' }} forgejo_user {{ '}' }}{{ '}' }}" woodpecker_admins: "{{ '{' }}{{ '{' }} gitea_user {{ '}' }}{{ '}' }}"
# #
####################################### #######################################
# #

View File

@ -1,4 +1,4 @@
forgejo-service-group: gitea-service-group:
hosts: hosts:
{{ subdomain }}-host: {{ subdomain }}-host:
ansible_port: 2222 ansible_port: 2222

View File

@ -54,8 +54,8 @@ class InfraUtilTest(TestCase):
# ) # )
# #
# self.assertEqual( # self.assertEqual(
# base.joinpath(f"inventory/host_vars/{subdomain}-host/forgejo.yml"), # base.joinpath(f"inventory/host_vars/{subdomain}-host/gitea.yml"),
# infra._forgejo_path(subdomain=subdomain), # infra._gitea_path(subdomain=subdomain),
# ) # )
# #
# self.assertEqual( # self.assertEqual(
@ -156,7 +156,7 @@ class InfraUtilTest(TestCase):
# call_command("vm", "delete", subdomain) # call_command("vm", "delete", subdomain)
# #
# def test_worker(self): # def test_worker(self):
# subdomain = "forgejo" # yes, forgejo.hostea.org exists. will use it till I # subdomain = "gitea" # yes, gitea.hostea.org exists. will use it till I
# # figure out how to use requests_mock within django # # figure out how to use requests_mock within django
# c = Client() # c = Client()
# login_util(self, c, "accounts.home") # login_util(self, c, "accounts.home")
@ -166,8 +166,8 @@ class InfraUtilTest(TestCase):
# #
# instance = Instance.objects.get(name=subdomain) # instance = Instance.objects.get(name=subdomain)
# job = Job.objects.create(instance=instance, job_type=JobType.PING) # job = Job.objects.create(instance=instance, job_type=JobType.PING)
# forgejo_uri = Infra.get_forgejo_uri(instance=instance) # gitea_uri = Infra.get_gitea_uri(instance=instance)
# print(f"mocking {forgejo_uri}") # print(f"mocking {gitea_uri}")
# #
# w = Worker(job=job) # w = Worker(job=job)
# w.start() # w.start()
@ -184,7 +184,7 @@ class InfraUtilTest(TestCase):
Test if the dashboard generates invoices for a VM crated with a name Test if the dashboard generates invoices for a VM crated with a name
matching a VM name that was deleted that existed. matching a VM name that was deleted that existed.
ref: https://forgejo.hostea.org/Hostea/dashboard/issues/38#issuecomment-1162 ref: https://gitea.hostea.org/Hostea/dashboard/issues/38#issuecomment-1162
""" """
c = Client() c = Client()
login_util(self, c, "accounts.home") login_util(self, c, "accounts.home")

View File

@ -43,12 +43,12 @@ class Worker(Thread):
super().__init__() super().__init__()
def run(self): def run(self):
forgejo_uri = Infra.get_forgejo_uri(instance=self.job.instance) gitea_uri = Infra.get_gitea_uri(instance=self.job.instance)
woodpecker = Infra.get_woodpecker_uri(instance=self.job.instance) woodpecker = Infra.get_woodpecker_uri(instance=self.job.instance)
while True: while True:
try: try:
print(f"[ping] Trying to reach {forgejo_uri}") print(f"[ping] Trying to reach {gitea_uri}")
resp = requests.get(forgejo_uri) resp = requests.get(gitea_uri)
if resp.status_code == 200: if resp.status_code == 200:
break break
except Exception: except Exception:
@ -60,7 +60,7 @@ class Worker(Thread):
email = job.instance.owned_by.email email = job.instance.owned_by.email
ctx = { ctx = {
"forgejo_uri": forgejo_uri, "gitea_uri": gitea_uri,
"woodpecker_uri": woodpecker, "woodpecker_uri": woodpecker,
"username": job.instance.owned_by.username, "username": job.instance.owned_by.username,
} }
@ -82,18 +82,18 @@ class Worker(Thread):
def create_vm_if_not_exists(instance: Instance) -> (str, str): def create_vm_if_not_exists(instance: Instance) -> (str, str):
""" """
Create VM utility. Forgejo password is returned Create VM utility. Gitea password is returned
""" """
def notify_staff(instance: Instance): def notify_staff(instance: Instance):
infra = Infra() infra = Infra()
User = get_user_model() User = get_user_model()
forgejo_uri = Infra.get_forgejo_uri(instance=instance) gitea_uri = Infra.get_gitea_uri(instance=instance)
woodpecker = Infra.get_woodpecker_uri(instance=instance) woodpecker = Infra.get_woodpecker_uri(instance=instance)
for staff in User.objects.filter(is_staff=True): for staff in User.objects.filter(is_staff=True):
ctx = { ctx = {
"forgejo_uri": forgejo_uri, "gitea_uri": gitea_uri,
"woodpecker_uri": woodpecker, "woodpecker_uri": woodpecker,
"username": staff.username, "username": staff.username,
} }
@ -113,12 +113,12 @@ def create_vm_if_not_exists(instance: Instance) -> (str, str):
infra = Infra() infra = Infra()
if not InstanceCreated.objects.filter(instance=instance).exists(): if not InstanceCreated.objects.filter(instance=instance).exists():
(forgejo_password, commit) = infra.add_vm(instance=instance) (gitea_password, commit) = infra.add_vm(instance=instance)
InstanceCreated.objects.create(instance=instance, created=True) InstanceCreated.objects.create(instance=instance, created=True)
notify_staff(instance=instance) notify_staff(instance=instance)
job = Job.objects.create(instance=instance, job_type=str(JobType.PING)) job = Job.objects.create(instance=instance, job_type=str(JobType.PING))
Worker(job=job).start() Worker(job=job).start()
return (forgejo_password, commit) return (gitea_password, commit)
else: else:
if str.strip(infra.get_flavor(instance=instance)) != str.strip( if str.strip(infra.get_flavor(instance=instance)) != str.strip(
infra.translate_size(instance=instance) infra.translate_size(instance=instance)
@ -177,9 +177,9 @@ class Infra:
return self._host_vars_dir(subdomain=subdomain).joinpath("provision.yml") return self._host_vars_dir(subdomain=subdomain).joinpath("provision.yml")
@classmethod @classmethod
def get_forgejo_uri(cls, instance: Instance) -> str: def get_gitea_uri(cls, instance: Instance) -> str:
""" """
Get an instance's Forgejo URI Get an instance's Gitea URI
""" """
base = settings.HOSTEA["INFRA"]["HOSTEA_DOMAIN"] base = settings.HOSTEA["INFRA"]["HOSTEA_DOMAIN"]
return f"https://{instance.name}.{base}" return f"https://{instance.name}.{base}"
@ -194,7 +194,7 @@ class Infra:
@classmethod @classmethod
def get_woodpecker_uri(cls, instance: Instance) -> str: def get_woodpecker_uri(cls, instance: Instance) -> str:
""" """
Get an instance's Forgejo URI Get an instance's Gitea URI
""" """
base = settings.HOSTEA["INFRA"]["HOSTEA_DOMAIN"] base = settings.HOSTEA["INFRA"]["HOSTEA_DOMAIN"]
return f"https://{cls._gen_woodpecker_hostname(instance=instance)}.{base}" return f"https://{cls._gen_woodpecker_hostname(instance=instance)}.{base}"
@ -211,12 +211,12 @@ class Infra:
return config["openstack_flavor"].split("{{ ")[1].split(" }}")[0] return config["openstack_flavor"].split("{{ ")[1].split(" }}")[0]
return None return None
def _forgejo_path(self, subdomain: str) -> Path: def _gitea_path(self, subdomain: str) -> Path:
""" """
utility method: get forgejo file for a subdomain utility method: get gitea file for a subdomain
""" """
return self._host_vars_dir(subdomain=subdomain).joinpath("forgejo.yml") return self._host_vars_dir(subdomain=subdomain).joinpath("gitea.yml")
def _backup_path(self, subdomain: str) -> Path: def _backup_path(self, subdomain: str) -> Path:
""" """
@ -284,7 +284,7 @@ class Infra:
""" """
Add new VM to infrastructure repository Add new VM to infrastructure repository
The forgejo user password is returned The gitea user password is returned
""" """
subdomain = instance.name subdomain = instance.name
@ -298,22 +298,22 @@ class Infra:
os.makedirs(hostscript_path) os.makedirs(hostscript_path)
woodpecker_agent_secret = get_random_string(64) woodpecker_agent_secret = get_random_string(64)
forgejo_password = get_random_string(20) gitea_password = get_random_string(20)
ctx = { ctx = {
"woodpecker_agent_secret": woodpecker_agent_secret, "woodpecker_agent_secret": woodpecker_agent_secret,
"woodpecker_hostname": self._gen_woodpecker_hostname(instance=instance), "woodpecker_hostname": self._gen_woodpecker_hostname(instance=instance),
"woodpecker_admins": f"{instance.owned_by.username}", "woodpecker_admins": f"{instance.owned_by.username}",
"forgejo_email": instance.owned_by.email, "gitea_email": instance.owned_by.email,
"forgejo_password": forgejo_password, "gitea_password": gitea_password,
"subdomain": subdomain, "subdomain": subdomain,
} }
forgejo = self._forgejo_path(subdomain) gitea = self._gitea_path(subdomain)
with open(forgejo, "w+", encoding="utf-8") as f: with open(gitea, "w+", encoding="utf-8") as f:
f.write( f.write(
render_to_string( render_to_string(
"infrastructure/yml/forgejo.yml", "infrastructure/yml/gitea.yml",
context=ctx, context=ctx,
) )
) )
@ -357,7 +357,7 @@ class Infra:
) )
commit = self._push(f"add vm {subdomain}") commit = self._push(f"add vm {subdomain}")
return (forgejo_password, commit) return (gitea_password, commit)
def remove_vm(self, instance: Instance): def remove_vm(self, instance: Instance):
""" """

View File

@ -53,23 +53,23 @@ def create_instance(request, instance_name: str):
res = create_vm_if_not_exists(instance=instance) res = create_vm_if_not_exists(instance=instance)
if res is not None: if res is not None:
(forgejo_password, commit) = res (gitea_password, commit) = res
ctx = { ctx = {
"username": request.user.username, "username": request.user.username,
"forgejo_password": forgejo_password, "gitea_password": gitea_password,
"forgejo_uri": Infra.get_forgejo_uri(instance=instance), "gitea_uri": Infra.get_gitea_uri(instance=instance),
} }
body = render_to_string( body = render_to_string(
"infrastructure/emails/forgejo-creds.txt", "infrastructure/emails/gitea-creds.txt",
context=ctx, context=ctx,
) )
sender = settings.DEFAULT_FROM_EMAIL sender = settings.DEFAULT_FROM_EMAIL
send_mail( send_mail(
subject="[Gna!] Forgejo admin credentials", subject="[Gna!] Gitea admin credentials",
message=body, message=body,
from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py from_email=f"No reply Gna!<{sender}>", # TODO read from settings.py
recipient_list=[request.user.email], recipient_list=[request.user.email],

View File

@ -16,7 +16,7 @@ init() {
sleep 5 sleep 5
# wait_for_env # wait_for_env
fi fi
forgejo_root gitea_root
support_repo_init support_repo_init
fleet_repo_init fleet_repo_init
} }

View File

@ -3,10 +3,10 @@ import argparse
from requests import Session from requests import Session
def forgejo_from_args(args, c: Session): def gitea_from_args(args, c: Session):
from .forgejo import Forgejo from .gitea import Gitea
return Forgejo( return Gitea(
host=args.host, host=args.host,
username=args.username, username=args.username,
password=args.password, password=args.password,
@ -15,7 +15,7 @@ def forgejo_from_args(args, c: Session):
) )
class Forgejo: class Gitea:
def __init__(self, parser, c: Session): def __init__(self, parser, c: Session):
self.c = c self.c = c
self.parser = parser self.parser = parser
@ -29,56 +29,56 @@ class Forgejo:
def __add_credentials_parser(self, parser): def __add_credentials_parser(self, parser):
group = parser.add_argument_group("credentials", "User credentials") group = parser.add_argument_group("credentials", "User credentials")
group.add_argument("username", type=str, help="Forgejo user's username") group.add_argument("username", type=str, help="Gitea user's username")
group.add_argument("password", type=str, help="Forgejo user's password") group.add_argument("password", type=str, help="Gitea user's password")
group.add_argument("email", type=str, help="Forgejo user's email") group.add_argument("email", type=str, help="Gitea user's email")
group.add_argument("host", type=str, help="URI at which Forgejo is running") group.add_argument("host", type=str, help="URI at which Gitea is running")
def install(self): def install(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.install() gitea.install()
self.install_parser = self.subparser.add_parser( self.install_parser = self.subparser.add_parser(
name="install", description="Install Forgejo", help="Install Forgejo" name="install", description="Install Gitea", help="Install Gitea"
) )
self.__add_credentials_parser(self.install_parser) self.__add_credentials_parser(self.install_parser)
self.install_parser.set_defaults(func=run) self.install_parser.set_defaults(func=run)
def register(self): def register(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.register() gitea.register()
self.register_parser = self.subparser.add_parser( self.register_parser = self.subparser.add_parser(
name="register", name="register",
description="Forgejo user registration", description="Gitea user registration",
help="Register a user on Forgejo", help="Register a user on Gitea",
) )
self.__add_credentials_parser(self.register_parser) self.__add_credentials_parser(self.register_parser)
self.register_parser.set_defaults(func=run) self.register_parser.set_defaults(func=run)
def login(self): def login(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.login() gitea.login()
self.login_parser = self.subparser.add_parser( self.login_parser = self.subparser.add_parser(
name="login", description="Forgejo user login", help="Login on Forgejo" name="login", description="Gitea user login", help="Login on Gitea"
) )
self.__add_credentials_parser(self.login_parser) self.__add_credentials_parser(self.login_parser)
self.login_parser.set_defaults(func=run) self.login_parser.set_defaults(func=run)
def create_repository(self): def create_repository(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.login() gitea.login()
forgejo.create_repository(name=args.repo_name) gitea.create_repository(name=args.repo_name)
self.create_repository_parser = self.subparser.add_parser( self.create_repository_parser = self.subparser.add_parser(
name="create_repo", name="create_repo",
description="Create repository on Forgejo", description="Create repository on Gitea",
help="Create repository on Forgejo", help="Create repository on Gitea",
) )
self.__add_credentials_parser(self.create_repository_parser) self.__add_credentials_parser(self.create_repository_parser)
self.create_repository_parser.set_defaults(func=run) self.create_repository_parser.set_defaults(func=run)
@ -88,10 +88,10 @@ class Forgejo:
def install_sso(self): def install_sso(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.login() gitea.login()
print(f"CLIENT ID: {args.client_id}") print(f"CLIENT ID: {args.client_id}")
forgejo.install_sso( gitea.install_sso(
sso_name=args.sso_name, sso_name=args.sso_name,
client_id=args.client_id, client_id=args.client_id,
client_secret=args.client_secret, client_secret=args.client_secret,
@ -100,8 +100,8 @@ class Forgejo:
self.install_sso_parser = self.subparser.add_parser( self.install_sso_parser = self.subparser.add_parser(
name="install_sso", name="install_sso",
description="Install SSO on Forgejo", description="Install SSO on Gitea",
help="Install SSO on Forgejo", help="Install SSO on Gitea",
) )
self.__add_credentials_parser(self.install_sso_parser) self.__add_credentials_parser(self.install_sso_parser)
self.install_sso_parser.add_argument( self.install_sso_parser.add_argument(
@ -123,14 +123,14 @@ class Forgejo:
def add_deploy_key(self): def add_deploy_key(self):
def run(args, c: Session): def run(args, c: Session):
forgejo = forgejo_from_args(args, c=c) gitea = gitea_from_args(args, c=c)
forgejo.login() gitea.login()
forgejo.add_deploy_key(repo=args.repo_name, key=args.key_file) gitea.add_deploy_key(repo=args.repo_name, key=args.key_file)
self.add_deploy_key_parser = self.subparser.add_parser( self.add_deploy_key_parser = self.subparser.add_parser(
name="add_deploy_key", name="add_deploy_key",
description="Create repository on Forgejo", description="Create repository on Gitea",
help="Add deploy key to a repository on Forgejo", help="Add deploy key to a repository on Gitea",
) )
self.__add_credentials_parser(self.add_deploy_key_parser) self.__add_credentials_parser(self.add_deploy_key_parser)
self.add_deploy_key_parser.add_argument( self.add_deploy_key_parser.add_argument(
@ -203,21 +203,21 @@ class Hostea:
def support(self): def support(self):
def run(args, c: Session): def run(args, c: Session):
from .forgejo import ForgejoSSO from .gitea import GiteaSSO
dash = dash_from_args(args, c=c) dash = dash_from_args(args, c=c)
dash.login() dash.login()
forgejo = ForgejoSSO( gitea = GiteaSSO(
username=dash.username, username=dash.username,
email=dash.email, email=dash.email,
forgejo_host=args.forgejo_host, gitea_host=args.gitea_host,
hostea_org=args.forgejo_hostea_org, hostea_org=args.gitea_hostea_org,
support_repo=args.support_repo, support_repo=args.support_repo,
c=c, c=c,
) )
dash.new_ticket(forgejo.new_issues_uri) dash.new_ticket(gitea.new_issues_uri)
forgejo.new_issue() gitea.new_issue()
self.support_parser = self.subparser.add_parser( self.support_parser = self.subparser.add_parser(
name="support", name="support",
@ -226,12 +226,12 @@ class Hostea:
) )
self.__add_credentials_parser(self.support_parser) self.__add_credentials_parser(self.support_parser)
self.support_parser.add_argument( self.support_parser.add_argument(
"forgejo_host", type=str, help="URI at which Forgejo is running" "gitea_host", type=str, help="URI at which Gitea is running"
) )
self.support_parser.add_argument( self.support_parser.add_argument(
"forgejo_hostea_org", "gitea_hostea_org",
type=str, type=str,
help="Hostea namespace(username/org) on Forgejo, where support repository is hosted", help="Hostea namespace(username/org) on Gitea, where support repository is hosted",
) )
self.support_parser.add_argument( self.support_parser.add_argument(
"support_repo", type=str, help="support repository name" "support_repo", type=str, help="support repository name"
@ -245,28 +245,28 @@ class Cli:
c = Session() c = Session()
self.c = c self.c = c
self.parser = argparse.ArgumentParser( self.parser = argparse.ArgumentParser(
description="Install and Bootstrap Forgejo and Hostea Dashboard" description="Install and Bootstrap Gitea and Hostea Dashboard"
) )
self.subparser = self.parser.add_subparsers() self.subparser = self.parser.add_subparsers()
self.check_env() self.check_env()
self.forgejo() self.gitea()
self.hostea() self.hostea()
def __add_credentials_parser(self, parser): def __add_credentials_parser(self, parser):
group = parser.add_argument_group("credentials", "User credentials") group = parser.add_argument_group("credentials", "User credentials")
group.add_argument("username", type=str, help="Forgejo user's username") group.add_argument("username", type=str, help="Gitea user's username")
group.add_argument("password", type=str, help="Forgejo user's password") group.add_argument("password", type=str, help="Gitea user's password")
group.add_argument("email", type=str, help="Forgejo user's email") group.add_argument("email", type=str, help="Gitea user's email")
def check_env(self): def check_env(self):
def run(args, c: Session): def run(args, c: Session):
from .forgejo import Forgejo from .gitea import Gitea
from .hostea import Hostea from .hostea import Hostea
Hostea.check_online( Hostea.check_online(
dashboard_host=args.hostea_host, maildev_host=args.maildev_host dashboard_host=args.hostea_host, maildev_host=args.maildev_host
) )
Forgejo.check_online(host=args.forgejo_host) Gitea.check_online(host=args.gitea_host)
self.check_env_parser = self.subparser.add_parser( self.check_env_parser = self.subparser.add_parser(
name="check_env", name="check_env",
@ -275,7 +275,7 @@ class Cli:
) )
self.check_env_parser.add_argument( self.check_env_parser.add_argument(
"forgejo_host", type=str, help="URI at which Forgejo is running" "gitea_host", type=str, help="URI at which Gitea is running"
) )
self.check_env_parser.add_argument( self.check_env_parser.add_argument(
@ -295,13 +295,13 @@ class Cli:
) )
Hostea(parser=self.hostea, c=self.c) Hostea(parser=self.hostea, c=self.c)
def forgejo(self): def gitea(self):
self.forgejo = self.subparser.add_parser( self.gitea = self.subparser.add_parser(
name="forgejo", name="gitea",
description="Forgejo", description="Gitea",
help="Forgejo-related functionality", help="Gitea-related functionality",
) )
Forgejo(parser=self.forgejo, c=self.c) Gitea(parser=self.gitea, c=self.c)
def parse(self): def parse(self):
return self.parser.parse_args() return self.parser.parse_args()

View File

@ -13,7 +13,7 @@ class ParseCSRF(HTMLParser):
# return cls(name="csrfmiddlewaretoken") # return cls(name="csrfmiddlewaretoken")
# #
# @classmethod # @classmethod
# def forgejo_parser(cls) -> "ParseCSRF": # def gitea_parser(cls) -> "ParseCSRF":
# return cls(name="_csrf") # return cls(name="_csrf")
# #
def handle_starttag(self, tag: str, attrs: (str, str)): def handle_starttag(self, tag: str, attrs: (str, str)):

View File

@ -10,15 +10,15 @@ import requests
from .csrf import ParseCSRF from .csrf import ParseCSRF
# FORGEJO_USER = "root" # GITEA_USER = "root"
# FORGEJO_EMAIL = "root@example.com" # GITEA_EMAIL = "root@example.com"
# FORGEJO_PASSWORD = "foobarpassword" # GITEA_PASSWORD = "foobarpassword"
# HOST = "http://localhost:8080" # HOST = "http://localhost:8080"
# #
# REPOS = [] # REPOS = []
class Forgejo: class Gitea:
def __init__(self, host: str, username: str, password: str, email: str, c: Session): def __init__(self, host: str, username: str, password: str, email: str, c: Session):
self.host = host self.host = host
self.username = username self.username = username
@ -48,7 +48,7 @@ class Forgejo:
@staticmethod @staticmethod
def check_online(host: str): def check_online(host: str):
""" """
Check if Forgejo instance is online Check if Gitea instance is online
""" """
count = 0 count = 0
parsed = urlparse(host) parsed = urlparse(host)
@ -67,7 +67,7 @@ class Forgejo:
def install(self): def install(self):
""" """
Install Forgejo, first form that a user sees when a new instance is Install Gitea, first form that a user sees when a new instance is
deployed deployed
""" """
# cwd = os.environ.get("PWD") # cwd = os.environ.get("PWD")
@ -77,12 +77,12 @@ class Forgejo:
"db_host": "localhost:3306", "db_host": "localhost:3306",
"db_user": "root", "db_user": "root",
"db_passwd": "", "db_passwd": "",
"db_name": "forgejo", "db_name": "gitea",
"ssl_mode": "disable", "ssl_mode": "disable",
"db_schema": "", "db_schema": "",
"charset": "utf8", "charset": "utf8",
"db_path": "/data/gitea/gitea.db", "db_path": "/data/gitea/gitea.db",
"app_name": "Forgejo:+Beyond+Coding+We+Forge", "app_name": "Gitea:+Git+with+a+cup+of+tea",
"repo_root_path": "/data/git/repositories", "repo_root_path": "/data/git/repositories",
"lfs_root_path": "/data/git/lfs", "lfs_root_path": "/data/git/lfs",
"run_user": "git", "run_user": "git",
@ -316,26 +316,26 @@ class ParseSSOLogin(HTMLParser):
return return
class ForgejoSSO: class GiteaSSO:
def __init__( def __init__(
self, self,
username: str, username: str,
email: str, email: str,
forgejo_host: str, gitea_host: str,
hostea_org: str, hostea_org: str,
support_repo: str, support_repo: str,
c: Session, c: Session,
): ):
self.c = c self.c = c
self.username = username self.username = username
self.forgejo_host = forgejo_host self.gitea_host = gitea_host
self.hostea_org = hostea_org self.hostea_org = hostea_org
self.support_repo = support_repo self.support_repo = support_repo
self.email = email self.email = email
self.__csrf_key = "_csrf" self.__csrf_key = "_csrf"
url = urlparse(self.forgejo_host) url = urlparse(self.gitea_host)
repo = f"{self.hostea_org}/{self.support_repo}" repo = f"{self.hostea_org}/{self.support_repo}"
issues = f"{repo}/issues" issues = f"{repo}/issues"
new_issues = f"{issues}/new" new_issues = f"{issues}/new"
@ -371,8 +371,8 @@ class ForgejoSSO:
parser = ParseSSOLogin() parser = ParseSSOLogin()
parser.feed(resp.text) parser.feed(resp.text)
url = urlparse(self.forgejo_host) url = urlparse(self.gitea_host)
## SSO URL in Forgejo login page ## SSO URL in Gitea login page
sso = urlunparse((url.scheme, url.netloc, parser.url, "", "", "")) sso = urlunparse((url.scheme, url.netloc, parser.url, "", "", ""))
# redirects are enabled to for a cleaner implementation. Commented out # redirects are enabled to for a cleaner implementation. Commented out

View File

@ -11,12 +11,12 @@ is_ci(){
if is_ci if is_ci
then then
MAILDEV_URL="http://smtp:1080" MAILDEV_URL="http://smtp:1080"
FORGEJO_URL="http://forgejo:3000" GITEA_URL="http://gitea:3000"
FORGEJO_SSH_URL="ssh://git@forgejo:22" GITEA_SSH_URL="ssh://git@gitea:22"
else else
MAILDEV_URL="http://localhost:1080" MAILDEV_URL="http://localhost:1080"
FORGEJO_URL="http://localhost:3000" GITEA_URL="http://localhost:3000"
FORGEJO_SSH_URL="ssh://git@localhost:22" GITEA_SSH_URL="ssh://git@localhost:22"
fi fi
readonly DASHBOARD_URL="http://localhost:8000" readonly DASHBOARD_URL="http://localhost:8000"
@ -27,22 +27,22 @@ readonly DASHBOARD_OIDC_DISCOVERY_URL="$DASHBOARD_URL/o/.well-known/openid-confi
readonly DASHBOARD_ADMIN_USERNAME=root readonly DASHBOARD_ADMIN_USERNAME=root
readonly DASHBOARD_ADMIN_PASSWORD=supercomplicatedpassword readonly DASHBOARD_ADMIN_PASSWORD=supercomplicatedpassword
readonly DASHBOARD_ADMIN_EMAIL="$DASHBOARD_ADMIN_USERNAME@dash.example.org" readonly DASHBOARD_ADMIN_EMAIL="$DASHBOARD_ADMIN_USERNAME@dash.example.org"
readonly DASHBOARD_OIDC_APP_NAME=hostea-forgejo readonly DASHBOARD_OIDC_APP_NAME=hostea-gitea
readonly FORGEJO_ROOT_USERNAME=root readonly GITEA_ROOT_USERNAME=root
readonly FORGEJO_ROOT_EMAIL="$FORGEJO_ROOT_USERNAME@example.org" readonly GITEA_ROOT_EMAIL="$GITEA_ROOT_USERNAME@example.org"
readonly FORGEJO_ROOT_PASSOWRD=supercomplicatedpassword readonly GITEA_ROOT_PASSOWRD=supercomplicatedpassword
readonly FORGEJO_HOSTEA_SSO_NAME=hostea-sso readonly GITEA_HOSTEA_SSO_NAME=hostea-sso
readonly FORGEJO_OIDC_CALLBACK="$FORGEJO_URL/user/oauth2/$FORGEJO_HOSTEA_SSO_NAME/callback" readonly GITEA_OIDC_CALLBACK="$GITEA_URL/user/oauth2/$GITEA_HOSTEA_SSO_NAME/callback"
readonly FORGEJO_HOSTEA_FLEET_DEPLOY_KEY="$(realpath tests/fleet-deploy-key.pub)" readonly GITEA_HOSTEA_FLEET_DEPLOY_KEY="$(realpath tests/fleet-deploy-key.pub)"
readonly FORGEJO_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE="$(realpath tests/fleet-deploy-key)" readonly GITEA_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE="$(realpath tests/fleet-deploy-key)"
readonly FORGEJO_HOSTEA_USERNAME=hostea readonly GITEA_HOSTEA_USERNAME=hostea
readonly FORGEJO_HOSTEA_PASSWORD=supercomplicatedpassword readonly GITEA_HOSTEA_PASSWORD=supercomplicatedpassword
readonly FORGEJO_HOSTEA_EMAIL="$FORGEJO_HOSTEA_USERNAME@example.org" readonly GITEA_HOSTEA_EMAIL="$GITEA_HOSTEA_USERNAME@example.org"
readonly FORGEJO_HOSTEA_SUPPORT_REPO="support" readonly GITEA_HOSTEA_SUPPORT_REPO="support"
readonly FORGEJO_HOSTEA_FLEET_REPO="fleet" readonly GITEA_HOSTEA_FLEET_REPO="fleet"
readonly FORGEJO_HOSTEA_FLEET_REPO_REMOTE="$FORGEJO_SSH_URL/$FORGEJO_HOSTEA_USERNAME/$FORGEJO_HOSTEA_FLEET_REPO.git" readonly GITEA_HOSTEA_FLEET_REPO_REMOTE="$GITEA_SSH_URL/$GITEA_HOSTEA_USERNAME/$GITEA_HOSTEA_FLEET_REPO.git"
readonly HOSTEA_CUSTOMER_USERNAME=batman readonly HOSTEA_CUSTOMER_USERNAME=batman
readonly HOSTEA_CUSTOMER_PASSWORD=supercomplicatedpassword readonly HOSTEA_CUSTOMER_PASSWORD=supercomplicatedpassword
@ -53,7 +53,7 @@ OIDC_CLIENT_SECRET=""
wait_for_env() { wait_for_env() {
python -m integration \ python -m integration \
check_env $FORGEJO_URL $DASHBOARD_URL $MAILDEV_URL check_env $GITEA_URL $DASHBOARD_URL $MAILDEV_URL
} }
# create OIDC app on Hostea Dashboard # create OIDC app on Hostea Dashboard
@ -67,74 +67,74 @@ oidc_dashboard_init() {
resp=$(python manage.py create_oidc \ resp=$(python manage.py create_oidc \
$DASHBOARD_OIDC_APP_NAME $DASHBOARD_ADMIN_USERNAME \ $DASHBOARD_OIDC_APP_NAME $DASHBOARD_ADMIN_USERNAME \
$FORGEJO_OIDC_CALLBACK) $GITEA_OIDC_CALLBACK)
OIDC_CLIENT_ID=$(echo $resp | cut -d ":" -f 2 | cut -d " " -f 2) OIDC_CLIENT_ID=$(echo $resp | cut -d ":" -f 2 | cut -d " " -f 2)
OIDC_CLIENT_SECRET=$(echo $resp | cut -d ":" -f 3 | cut -d " " -f 2) OIDC_CLIENT_SECRET=$(echo $resp | cut -d ":" -f 3 | cut -d " " -f 2)
} }
# register root user on Forgejo to simulate Hoste admin and integrate SSO # register root user on Gitea to simulate Hoste admin and integrate SSO
forgejo_root(){ gitea_root(){
python -m integration \ python -m integration \
forgejo install \ gitea install \
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \ $GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
$FORGEJO_ROOT_EMAIL \ $GITEA_ROOT_EMAIL \
$FORGEJO_URL $GITEA_URL
python -m integration \ python -m integration \
forgejo register \ gitea register \
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \ $GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
$FORGEJO_ROOT_EMAIL \ $GITEA_ROOT_EMAIL \
$FORGEJO_URL $GITEA_URL
python -m integration \ python -m integration \
forgejo login \ gitea login \
$FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \ $GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
$FORGEJO_ROOT_EMAIL \ $GITEA_ROOT_EMAIL \
$FORGEJO_URL $GITEA_URL
# python -m integration \ # python -m integration \
# forgejo install_sso \ # gitea install_sso \
# $FORGEJO_ROOT_USERNAME $FORGEJO_ROOT_PASSOWRD \ # $GITEA_ROOT_USERNAME $GITEA_ROOT_PASSOWRD \
# $FORGEJO_ROOT_EMAIL \ # $GITEA_ROOT_EMAIL \
# $FORGEJO_URL \ # $GITEA_URL \
# $FORGEJO_HOSTEA_SSO_NAME \ # $GITEA_HOSTEA_SSO_NAME \
# $OIDC_CLIENT_ID $OIDC_CLIENT_SECRET \ # $OIDC_CLIENT_ID $OIDC_CLIENT_SECRET \
# $DASHBOARD_OIDC_DISCOVERY_URL # $DASHBOARD_OIDC_DISCOVERY_URL
} }
# register user "Hostea" on Forgejo and create support repository # register user "Hostea" on Gitea and create support repository
support_repo_init() { support_repo_init() {
python -m integration \ python -m integration \
forgejo register \ gitea register \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL $GITEA_URL
python -m integration \ python -m integration \
forgejo login \ gitea login \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL $GITEA_URL
python -m integration \ python -m integration \
forgejo create_repo \ gitea create_repo \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL \ $GITEA_URL \
$FORGEJO_HOSTEA_SUPPORT_REPO $GITEA_HOSTEA_SUPPORT_REPO
} }
new_fleet_repo_init() { new_fleet_repo_init() {
python -m integration \ python -m integration \
forgejo create_repo \ gitea create_repo \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL \ $GITEA_URL \
$1 $1
python -m integration \ python -m integration \
forgejo add_deploy_key \ gitea add_deploy_key \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL \ $GITEA_URL \
$1 \ $1 \
$FORGEJO_HOSTEA_FLEET_DEPLOY_KEY $GITEA_HOSTEA_FLEET_DEPLOY_KEY
tmp_dir=$(mktemp -d) tmp_dir=$(mktemp -d)
pushd $tmp_dir pushd $tmp_dir
@ -144,13 +144,13 @@ new_fleet_repo_init() {
then then
git config user.email "hostea-dashobard-test@example.org" git config user.email "hostea-dashobard-test@example.org"
git config user.name "hoste-dashobard-test" git config user.name "hoste-dashobard-test"
chmod 600 $FORGEJO_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE chmod 600 $GITEA_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE
fi fi
git add README git add README
git commit -m "init" git commit -m "init"
REMOTE="$FORGEJO_SSH_URL/$FORGEJO_HOSTEA_USERNAME/$1.git" REMOTE="$GITEA_SSH_URL/$GITEA_HOSTEA_USERNAME/$1.git"
git remote add origin $REMOTE git remote add origin $REMOTE
GIT_SSH_COMMAND="/usr/bin/ssh -oStrictHostKeyChecking=no -i $FORGEJO_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE" \ GIT_SSH_COMMAND="/usr/bin/ssh -oStrictHostKeyChecking=no -i $GITEA_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE" \
git push --set-upstream origin master git push --set-upstream origin master
popd popd
rm -rf $tmp_dir rm -rf $tmp_dir
@ -158,20 +158,20 @@ new_fleet_repo_init() {
} }
# register user "Hostea" on Forgejo and create support repository # register user "Hostea" on Gitea and create support repository
fleet_repo_init() { fleet_repo_init() {
python -m integration \ python -m integration \
forgejo register \ gitea register \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL || true $GITEA_URL || true
python -m integration \ python -m integration \
forgejo login \ gitea login \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_PASSWORD \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \
$FORGEJO_HOSTEA_EMAIL \ $GITEA_HOSTEA_EMAIL \
$FORGEJO_URL $GITEA_URL
new_fleet_repo_init $FORGEJO_HOSTEA_FLEET_REPO new_fleet_repo_init $GITEA_HOSTEA_FLEET_REPO
} }
@ -192,8 +192,8 @@ hostea_customer_simulation() {
$HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \ $HOSTEA_CUSTOMER_USERNAME $HOSTEA_CUSTOMER_PASSWORD \
$HOSTEA_CUSTOMER_EMAIL \ $HOSTEA_CUSTOMER_EMAIL \
$DASHBOARD_URL \ $DASHBOARD_URL \
$FORGEJO_URL \ $GITEA_URL \
$FORGEJO_HOSTEA_USERNAME $FORGEJO_HOSTEA_SUPPORT_REPO $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_SUPPORT_REPO
} }
setup_env() { setup_env() {

View File

@ -15,7 +15,7 @@ django-oauth-toolkit==2.0.0
django-payments==1.0.0 django-payments==1.0.0
django-phonenumber-field==6.3.0 django-phonenumber-field==6.3.0
djangorestframework==3.13.1 djangorestframework==3.13.1
greenlet==1.1.3.post0 greenlet==1.1.2
idna==3.3 idna==3.3
install==1.3.5 install==1.3.5
isort==5.10.1 isort==5.10.1

View File

@ -24,8 +24,8 @@ from .utils import IssueTracker
hostea_issue_tracker_settings = settings.HOSTEA hostea_issue_tracker_settings = settings.HOSTEA
hostea_issue_tracker_settings["META"] = { hostea_issue_tracker_settings["META"] = {
"FORGEJO_INSTANCE": "https://forgejo.gna.org", "GITEA_INSTANCE": "https://gitea.gna.org",
"FORGEJO_ORG_NAME": "Hostea", "GITEA_ORG_NAME": "Hostea",
"SUPPORT_REPOSITORY": "support", "SUPPORT_REPOSITORY": "support",
} }
@ -41,8 +41,8 @@ class IssueTrackerTests(TestCase):
Verify default credentials; all further tests are based on defaults set Verify default credentials; all further tests are based on defaults set
""" """
it = IssueTracker() it = IssueTracker()
self.assertEqual(it.config["FORGEJO_INSTANCE"], "https://forgejo.gna.org") self.assertEqual(it.config["GITEA_INSTANCE"], "https://gitea.gna.org")
self.assertEqual(it.config["FORGEJO_ORG_NAME"], "Hostea") self.assertEqual(it.config["GITEA_ORG_NAME"], "Hostea")
self.assertEqual(it.config["SUPPORT_REPOSITORY"], "support") self.assertEqual(it.config["SUPPORT_REPOSITORY"], "support")
def test_uri_builders(self): def test_uri_builders(self):
@ -51,10 +51,10 @@ class IssueTrackerTests(TestCase):
""" """
it = IssueTracker() it = IssueTracker()
self.assertEqual( self.assertEqual(
it.get_issue_tracker(), "https://forgejo.gna.org/Hostea/support/issues" it.get_issue_tracker(), "https://gitea.gna.org/Hostea/support/issues"
) )
self.assertEqual( self.assertEqual(
it.open_issue(), "https://forgejo.gna.org/Hostea/support/issues/new" it.open_issue(), "https://gitea.gna.org/Hostea/support/issues/new"
) )

View File

@ -24,9 +24,9 @@ class IssueTracker:
def __init__(self): def __init__(self):
self.config = settings.HOSTEA["META"] self.config = settings.HOSTEA["META"]
self.instance = urlparse(self.config["FORGEJO_INSTANCE"]) self.instance = urlparse(self.config["GITEA_INSTANCE"])
self.repo = ( self.repo = (
f"{self.config['FORGEJO_ORG_NAME']}/{self.config['SUPPORT_REPOSITORY']}" f"{self.config['GITEA_ORG_NAME']}/{self.config['SUPPORT_REPOSITORY']}"
) )
self.issues = f"{self.repo}/issues" self.issues = f"{self.repo}/issues"