Skip to content

develop.juggler #

Juggler

Juggler is a CI/CD tool that gets it's instructions from a private IT environment configuration repository, and starts juggling as webhooks hit the juggler's /trigger endpoint.

Using Templates for UI

The Juggler templates must be copied from a private repository because they aren't open source. We have provided a script to help you copy these templates to your local environment. Follow the steps below:

Steps to Copy Juggler Templates

  1. Ensure you have cloned the private repository at the specified location in your environment. By default, the script assumes the repository is located at $HOME/code/github/freeflowuniverse/webcomponents. If your repository is located elsewhere, set the CODEROOT environment variable accordingly.

  2. Execute the script to copy the templates to the directory where the script is located:

bash copy_templates.sh

This will copy the juggler_templates folder to the directory containing the script and rename it to templates.

If you encounter any issues, ensure that the source path of the templates is correct and that you have the necessary permissions to read from and write to the directories involved.

fn configure #

fn configure(cfg Config) !&Juggler

fn get #

fn get(j Juggler) !&Juggler

fn git_service #

fn git_service(req http.Request) !GitService

git_service returns the git service responsible for a request

fn is_authenticated #

fn is_authenticated(mut ctx Context) bool

enum GitAction #

enum GitAction {
	push
	commit
	manual
}

enum GitService #

enum GitService {
	@none
	gitea
	github
}

enum ScriptCategory #

enum ScriptCategory {
	@none
	hero
	vlang
	shell
	hybrid
}

enum Status #

enum Status {
	starting
	running
	success
	error
}

struct Commit #

struct Commit {
pub:
	committer string
	message   string
	time      time.Time
	hash      string
	url       string
}

struct CommitUser #

struct CommitUser {
pub:
	name     string
	email    string
	username string
}

struct Config #

struct Config {
pub mut:
	name     string
	url      string
	reset    bool
	pull     bool
	port     int
	host     string
	coderoot string
	username string
	password string
	secret   string
}

struct Context #

struct Context {
	veb.Context
}

fn (Context) error #

fn (mut ctx Context) error(err JugglerError) veb.Result

struct CustomEvent #

struct CustomEvent {
pub:
	time time.Time
}

struct Event #

struct Event {
pub mut:
	id        u32
	subject   string
	object_id u32
	commit    Commit
	time      time.Time
	action    GitAction
}

fn (Event) name #

fn (e Event) name() string

fn (Event) category #

fn (e Event) category() string

fn (Event) card #

fn (event Event) card(repository Repository) string

struct GitEvent #

struct GitEvent {
pub mut:
	id         u32
	repository Repository
	commit     Commit
	time       time.Time
	action     GitAction
}

fn (GitEvent) category #

fn (e GitEvent) category() string

fn (GitEvent) name #

fn (e GitEvent) name() string

struct GitTrigger #

struct GitTrigger {
	// repository Repository
	action GitAction
}

struct GiteaCommit #

struct GiteaCommit {
pub:
	id           string
	message      string
	url          string
	author       CommitUser
	committer    CommitUser
	verification ?string
	timestamp    string
	added        ?[]string
	removed      ?[]string
	modified     ?[]string
}

struct GiteaEvent #

struct GiteaEvent {
pub:
	ref           string @[required]
	before        string
	after         string
	compare_url   string
	commits       []GiteaCommit
	total_commits int
	head_commit   GiteaCommit
	repository    GiteaRepository @[required]
	pusher        User
	sender        User
}

struct GiteaRepository #

struct GiteaRepository {
pub:
	id                                int
	owner                             User
	name                              string
	full_name                         string @[required]
	description                       string
	empty                             bool
	private                           bool
	fork                              bool
	template                          bool
	parent                            ?string
	mirror                            bool
	size                              int
	language                          string
	languages_url                     string
	html_url                          string
	url                               string @[required]
	link                              string
	ssh_url                           string
	clone_url                         string @[required]
	original_url                      string
	website                           string
	stars_count                       int
	forks_count                       int
	watchers_count                    int
	open_issues_count                 int
	open_pr_counter                   int
	release_counter                   int
	default_branch                    string
	archived                          bool
	created_at                        string
	updated_at                        string
	archived_at                       string
	permissions                       Permissions
	has_issues                        bool
	internal_tracker                  InternalTracker
	has_wiki                          bool
	has_pull_requests                 bool
	has_projects                      bool
	has_releases                      bool
	has_packages                      bool
	has_actions                       bool
	ignore_whitespace_conflicts       bool
	allow_merge_commits               bool
	allow_rebase                      bool
	allow_rebase_explicit             bool
	allow_squash_merge                bool
	allow_rebase_update               bool
	default_delete_branch_after_merge bool
	default_merge_style               string
	default_allow_maintainer_edit     bool
	avatar_url                        string
	internal                          bool
	mirror_interval                   string
	mirror_updated                    string
	repo_transfer                     ?string
}

struct InternalTracker #

struct InternalTracker {
pub:
	enable_time_tracker                   bool
	allow_only_contributors_to_track_time bool
	enable_issue_dependencies             bool
}

struct Juggler #

struct Juggler {
	actor.Actor
	veb.StaticHandler
	veb.Middleware[Context]
pub:
	name        string
	host        string
	port        int
	username    string
	password    string
	secret      string
	config_path string
	url         string
	repo_path   string // local path to the itenv repository defining dag's per repos
}

Juggler is a Continuous Integration Juggler that listens for triggers from gitea repositories.

fn (Juggler) activity #

fn (mut j Juggler) activity(mut ctx Context) veb.Result

This is how endpoints are defined in veb. This is the index route

fn (Juggler) event_card #

fn (mut j Juggler) event_card(event Event) !string

fn (Juggler) get_event #

fn (mut j Juggler) get_event(req http.Request) !Event

get repository returns the Repository which belongs to the webhook being evented

fn (Juggler) get_gitea_event #

fn (mut j Juggler) get_gitea_event(data string) !Event

fn (Juggler) get_github_event #

fn (mut j Juggler) get_github_event(data string) !Event

fn (Juggler) get_scripts #

fn (mut j Juggler) get_scripts(t Trigger) ![]Script

fn (Juggler) get_triggers #

fn (mut j Juggler) get_triggers(e Event) ![]Trigger

fn (Juggler) index #

fn (j &Juggler) index(mut ctx Context) veb.Result

This is how endpoints are defined in veb. This is the index route

fn (Juggler) info #

fn (j Juggler) info() string

fn (Juggler) is_triggered #

fn (mut j Juggler) is_triggered(trigger Trigger, event Event) bool

fn (Juggler) load_script_from_path #

fn (mut j Juggler) load_script_from_path(path_ pathlib.Path) !u32

fn (Juggler) load_scripts_from_path #

fn (mut j Juggler) load_scripts_from_path(path_ pathlib.Path) ![]u32

fn (Juggler) login #

fn (j &Juggler) login(mut ctx Context) veb.Result

fn (Juggler) login_post #

fn (j &Juggler) login_post(mut ctx Context) veb.Result

fn (Juggler) new_repository #

fn (mut j Juggler) new_repository(repo_ Repository) !u32

fn (Juggler) new_trigger #

fn (mut j Juggler) new_trigger(t_ Trigger) !u32

fn (Juggler) play #

fn (mut j Juggler) play(mut ctx Context, id string) veb.Result

// success_rate_str := '${math.round_sig(success_rate*100, 1)}%' // return ctx.html($tmpl('../../../../webcomponents/webcomponents/tailwind/juggler_templates/play.html')) // }

fn (Juggler) restart #

fn (mut j Juggler) restart() !

fn (Juggler) row #

fn (mut j Juggler) row(play Play) string

fn (Juggler) run #

fn (mut j Juggler) run(port int) !

fn (Juggler) run_play #

fn (mut j Juggler) run_play(play Play) !

fn (Juggler) script #

fn (mut j Juggler) script(mut ctx Context, id string) veb.Result

fn (Juggler) script_play #

fn (mut j Juggler) script_play(mut ctx Context, id string) veb.Result

fn (Juggler) scripts #

fn (mut j Juggler) scripts(mut ctx Context) veb.Result

fn (Juggler) scripts_create #

fn (j &Juggler) scripts_create(mut ctx Context) veb.Result

fn (Juggler) start #

fn (mut j Juggler) start() !

fn (Juggler) stop #

fn (mut j Juggler) stop() !

fn (Juggler) trigger #

fn (mut j Juggler) trigger(mut ctx Context) veb.Result

This is how endpoints are defined in veb. This is the index route

fn (Juggler) trigger_row #

fn (mut j Juggler) trigger_row(trigger Trigger) string

fn (Juggler) triggers #

fn (mut j Juggler) triggers(mut ctx Context) veb.Result

This is how endpoints are defined in veb. This is the index route

fn (Juggler) update_plays #

fn (mut j Juggler) update_plays() !

struct JugglerError #

struct JugglerError {}

struct LoginForm #

struct LoginForm {}

struct Permissions #

struct Permissions {
pub:
	admin bool
	push  bool
	pull  bool
}

struct Play #

struct Play {
pub mut:
	id         u32
	script_id  u32 // id of script that is played
	event_id   u32 // id of event that triggered the play
	trigger_id u32
	status     Status    // status of the play
	output     string    // output of the play
	start      time.Time // time the play started
	end        time.Time // time the play ended
}

a play of a script due to a trigger that occurs

fn (Play) duration #

fn (p Play) duration() time.Duration

struct Repository #

struct Repository {
pub mut:
	id     u32
	owner  string @[required]
	name   string @[required]
	host   string @[required]
	branch string @[required]
}

fn (Repository) identifier #

fn (r Repository) identifier() string

fn (Repository) path #

fn (r Repository) path() string

fn (Repository) full_name #

fn (r Repository) full_name() string

struct Script #

struct Script {
pub mut:
	id          u32
	name        string
	description string
	url         string
	path        string
	status      string
	category    ScriptCategory
}

fn (Script) id #

fn (s Script) id() string

struct Trigger #

struct Trigger {
	GitTrigger
pub mut:
	id          u32
	name        string
	description string
	object_id   u32
	script_ids  []u32 // the ids of scripts that the trigger triggers
}

struct User #

struct User {
pub:
	id                  int
	login               string
	login_name          string
	full_name           string
	email               string
	avatar_url          string
	language            string
	is_admin            bool
	last_login          string
	created             string
	restricted          bool
	active              bool
	prohibit_login      bool
	location            string
	website             string
	description         string
	visibility          string
	followers_count     int
	following_count     int
	starred_repos_count int
	username            string
}