Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add farm management support #88

Merged
merged 17 commits into from
Nov 3, 2023
Merged

Conversation

chl178
Copy link
Contributor

@chl178 chl178 commented Jun 16, 2023

Related Issue: #57

Background:

Our previous discussions have highlighted the need to provide more flexibility and efficiency in managing wiki farms in Canasta, which is a Docker-based MediaWiki distribution. The initial implementation included the ability to run multiple wikis (or a wiki farm) within a single container, which was a significant stride towards our project's goal. However, for even more user-friendly and effective management of wiki farms, the enhancement of Canasta's CLI became evident.

Summary

This PR introduces two new commands to the CLI for managing wiki farms: add and remove. Furthermore, we've updated the create command to directly create a wiki farm in a Canasta instance using a wikis.yaml file.

Importantly, our design philosophy in adding wiki farm support ensures the continuity of the original functionality. If you choose not to use the wiki farm related features, all other command operations will work as before. This makes the adoption of wiki farm features completely optional, allowing you to continue using the CLI in the way you're familiar with if desired.

Table of Contents

  • Enhancements
    • create
    • extension
    • skin
  • New Commands
    • add
    • remove
  • Docker-Compose Structure
  • Next Steps
  • Version Migration

Enhancements

create

Description: Creates a Canasta installation. Enhanced to support wiki farm setup with the -f flag.

Usage:
sudo go run canasta.go create [flags]

  • -p, --path: Canasta directory.
  • -o, --orchestrator: Orchestrator to use for installation (default: "docker-compose").
  • -i, --id: Canasta instance ID.
  • -w, --wiki: Name of the wiki.
  • -n, --domain-name: Domain name (default: "localhost").
  • -a, --WikiSysop: Initial wiki admin username.
  • -s, --password: Initial wiki admin password.
  • -f, --yamlfile: Initial wiki yaml file for wiki farm setup.
  • -k, --keep-config: Keep the config files on installation failure.

YAML Format for Wiki Farm:
To create a wiki farm, you need to provide a YAML file with the following format:

wikis:
  - id: [WIKI_ID] # Example: "wiki1"
    url: [WIKI_URL] # Example: "mywiki1.example.com"
    name: [WIKI_SITENAME] # Example: "mywiki1"

sudo go run canasta.go create -f [yamlfile] # Example: "wikis.yaml

extension

Description: Manage Canasta extensions. Enhanced to target a specific wiki within the farm using the -w flag.

Subcommands:

  • list: Lists all the installed Canasta extensions.
  • enable: Enables specified extensions.
  • disable: Disables specified extensions.

Usage:
sudo go run canasta.go extension [subcommand] [flags]
Flags:

  • -i, --id: Specifies the Canasta instance ID.
  • -p, --path: Specifies the Canasta installation directory.
  • -w, --wiki: Specifies the ID of a specific wiki within the Canasta farm.
  • -v, --verbose: Enables verbose output.

New Commands

add

Description: Adds a new wiki to a Canasta instance.

Usage:
sudo go run canasta.go add [flags]
Flags:

  • -w, --wiki: ID of the new wiki.
  • -u, --url: URL of the new wiki.
  • -s, --site-name: Name of the new wiki site.
  • -p, --path: Path to the new wiki.
  • -i, --id: Canasta instance ID.
  • -o, --orchestrator: Orchestrator to use for installation (default: "docker-compose").
  • -d, --database: Path to the existing database dump.

remove

Description: Removes a wiki from a Canasta instance.

Usage:
sudo go run canasta.go remove [flags]
Flags:

  • -w, --wiki: ID of the wiki to be removed.
  • -p, --path: Path to the wiki.
  • -i, --id: Canasta instance ID.

Docker-Compose Structure

Our current docker compose structure is as follows:

config/
	CommonSettings.php
	Caddyfile
	CanastaFooterIcon.php
	composer.local.json
	default.vcl
        wikis.yaml
  	settings/
                *.php
  	wiki1/
		Settings.php
    		*.php
  	wiki2/
    		Settings.php
    		*.php
images/
        wiki1/
  	wiki2/

Each wiki's settings file is contained within a directory of their name under the config directory. These settings include a CommonSettings.php file.
Eache wiki's images are stored in their corresponding file under images/[WIKIID].

In the new version, we consider all Canasta instances as wiki farms, even if there is only one wiki in that instance.Therefore, manual imports of settings and images must be placed in the corresponding wiki ID's folder.

Version Migration

To make it more convenient for users to migrate to the new version, the new Canasta CLI will automatically detect when used, and then create configuration files such as YAML, images folder, etc. If the number of wikis in the farm is more than 1, then the LocalSettings.php will be renamed to CommonSettings.php.

Next Steps:

we will initiate server tests to evaluate the practicality and performance of these updates. Your support and collaboration in this testing phase will be crucial to ensure that our modifications not only align with technical specifications but also cater to real-world usage scenarios.

@chl178 chl178 changed the title Daft PR for CLI farm management support Draft PR for CLI farm management support Jun 16, 2023
@olsonjaredm
Copy link

I like using add/remove for the commands (I can't come up with any better terms).

As far as PHP file structure I'd say default to CommonSettings.php for the upper level with the expectation that for single-wiki 'farms' this file is a stub and ignored by admins.
Then each of the subfolders for individual wikis contain their own LocalSettings.php. I also like the idea of it concatenating all PHP files in the folders so admins can rename them what they like.

return err
}

fmt.Println("Successfully Added the Wiki '" + name + "in Canasta instance '" + instance.Id + "'...")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be a space between name +" and in Canasta?

cmd/add/add.go Outdated
}

// addWiki accepts the Canasta instance ID, the name, domain and path of the new wiki, and the initial admin info, then creates a new wiki in the instance.
func AddWiki(name, domain, wikipath, siteName, databasePath string, instance config.Installation) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for any of these params to be non-null but empty? If so, how is that handled?

}

// addWiki accepts the Canasta instance ID, the name, domain and path of the new wiki, and the initial admin info, then creates a new wiki in the instance.
func RemoveWiki(name string, instance config.Installation) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is removing the last wiki in the Canasta instance?

@@ -27,13 +28,15 @@ func CloneStackRepo(orchestrator, canastaId string, path *string) error {
*path += "/" + canastaId
logging.Print(fmt.Sprintf("Cloning the %s stack repo to %s \n", orchestrator, *path))
repo := orchestrators.GetRepoLink(orchestrator)
err := git.Clone(repo, *path)
err := git.Cloneb(repo, *path, "CLI")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is git.Cloneb? Is it a typo or is it different than git.Clone?

internal/canasta/canasta.go Outdated Show resolved Hide resolved
}

func RewriteSettings(path string, WikiNames []string) error {
for _, name := range WikiNames {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is name always guaranteed to be nonempty?

@yaronkoren yaronkoren changed the base branch from main to gsoc-wiki-farm November 3, 2023 16:46
@yaronkoren yaronkoren changed the title Draft PR for CLI farm management support Add farm management support Nov 3, 2023
@yaronkoren yaronkoren merged commit 81d2a71 into CanastaWiki:gsoc-wiki-farm Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants