Documentation ¶
Index ¶
- Constants
- Variables
- func ChallengesHealthProber(waitTime int)
- func CommitChallengeContainer(challName string) error
- func CopyDir(src string, dst string) error
- func CopyFile(src, dst string) error
- func CopyToStaticContent(challengeName, staticContentDir string) error
- func DeployChallenge(challengeName string) error
- func DeployChallengePipeline(challengeDir string) error
- func DeployStaticChallenge(challConf *cfg.BeastChallengeConfig, challenge *database.Challenge, ...)
- func DeployStaticContentContainer() error
- func GenerateChallengeDockerfileCtx(config *cfg.BeastChallengeConfig) (string, error)
- func GenerateDockerfile(config *cfg.BeastChallengeConfig) (string, error)
- func GetAvailableChallenges() ([]string, error)
- func GetCommandAndImageForWebChall(webRoot, port string, challengeInfo []string) (string, string)
- func GetDeployWork(challengeName string) (*wpool.Task, error)
- func GetStaticContentDir(configFile, contextDir string) (string, error)
- func HandleAll(action string, user string) []string
- func HandleTagRelatedChallenges(action string, tag string, user string) []string
- func LogTransaction(identifier string, action string, authorization string) error
- func PurgeChallenge(challengeName string) error
- func RedeployChallenge(challengeName string) error
- func ResetBeastRemote() error
- func RunBeastBootsetps() error
- func StartDeployPipeline(challengeDir string, skipStage bool, skipCommit bool)
- func StartUndeployChallenge(challengeName string, purge bool) error
- func SyncBeastRemote() error
- func UnTarChallengeFolder(tarContextPath, dstPath string) (string, error)
- func UndeployChallenge(challengeName string) error
- func UndeployStaticContentContainer()
- func UpdateChallenges()
- func UpdateOrCreateChallengeDbEntry(challEntry *database.Challenge, config cfg.BeastChallengeConfig) error
- func ValidateChallengeConfig(challengeDir string) error
- func ValidateChallengeDir(challengeDir string) error
- type BeastBareDockerfile
- type BeastXinetdConf
- type ChallengePreview
- type TaskInfo
- type Worker
Constants ¶
const CHALLENGE_HOST = "127.0.0.1"
const MAX_RETRIES = 3
Variables ¶
var ChallengeActionHandlers = map[string]func(string) error{ core.MANAGE_ACTION_DEPLOY: DeployChallenge, core.MANAGE_ACTION_UNDEPLOY: UndeployChallenge, core.MANAGE_ACTION_REDEPLOY: RedeployChallenge, core.MANAGE_ACTION_PURGE: PurgeChallenge, }
var Q *wpool.Queue
Functions ¶
func ChallengesHealthProber ¶
func ChallengesHealthProber(waitTime int)
func CommitChallengeContainer ¶
Function which commits the deployed challenge provided
func CopyToStaticContent ¶
Copies the Static content to the staging/static/folder
func DeployChallenge ¶
func DeployChallengePipeline ¶
Main function which starts the deploy of a challenge provided directory inside the hack git database. We validate the challenge config first and return early starting a goroutine to start out the deploy process. The early return consist of validation of the provided challenge config in the directory.
func DeployStaticChallenge ¶
func DeployStaticChallenge(challConf *cfg.BeastChallengeConfig, challenge *database.Challenge, challengeDir string)
Deploy a static challenge
func DeployStaticContentContainer ¶
func DeployStaticContentContainer() error
Deploy the static content container for beast The image for the static container should be prebuilt, which can be found in /extras/static-content/ of the root of the project The image name for the static content docker image shoule be specified in the BEAST_STATIC_CONTAINER_NAME:latest variable This function does not build the image for static containers. The port for the deployment of the static container is specified in the variable BEAST_CHALLENGES_STATIC_PORT, this port should be free and will be the port on which nginx container for static files will be running.
Each challenges have its own static file folder inside the challenges directory. The whole staging area of beast configuration is mounted on the docker container to serve the static files to the user. The location of the static content for each challenge for staging area is $BEAST_ROOT/staging/$CHALLENGE/static This directory is automatically populated with the desired challenge static files when the challenge is commanded to be staged.
func GenerateChallengeDockerfileCtx ¶
func GenerateChallengeDockerfileCtx(config *cfg.BeastChallengeConfig) (string, error)
Generate dockerfile context for the challnge from the challenge config file path provided as an argument. The config provided must be a valid beast configuration, which is to be ensured by the caller. It does not check if the config even exist or is valid. The validation for the dockerfile should be done before calling this function. If the file does not exist or there is some error while parsing the setup file this function will simply return the error without logging anything.
func GenerateDockerfile ¶
func GenerateDockerfile(config *cfg.BeastChallengeConfig) (string, error)
From the provided configFIle path it generates the dockerfile for the challenge and returns it as a string. This function again assumes that the validation for the configFile is done beforehand before calling this function.
func GetAvailableChallenges ¶
func GetCommandAndImageForWebChall ¶
This function provides the run command and image for a particular type of web challenge
webRoot: relative path to web challenge directory
port: web port
challengeInfo
It returns the run command for challenge and the docker base image corresponding to language
func GetDeployWork ¶
Start deploying a challenge using the challenge Name(we are not using ID here), if the challenge is already present and the container is running, then don't do anything. If the challenge does not exist then first check if the challenge is in staged state, if it is then deploy challenge from there on or else start deploy pipeline for the challenge.
This will start deploy pipeline if it finds there is no problem in deployment, else it will notify the user via return value if there is an error or if the deployement request cannot be processed.
func GetStaticContentDir ¶
Provides the Static Content Folder Name from the config
func HandleTagRelatedChallenges ¶
Handle tag related challenges.
func LogTransaction ¶
Takes and save the data to transaction table
func PurgeChallenge ¶
func RedeployChallenge ¶
func ResetBeastRemote ¶
func ResetBeastRemote() error
func RunBeastBootsetps ¶
func RunBeastBootsetps() error
func StartDeployPipeline ¶
This is just a decorator function over bootstrapDeployPipeline and generate notifications to slack on the basis of the result of the deploy pipeline.
func StartUndeployChallenge ¶
func SyncBeastRemote ¶
func SyncBeastRemote() error
Sync the beast remote directory with the actual git repository.
func UnTarChallengeFolder ¶
UnTars challenge folder in a destination directory
func UndeployChallenge ¶
func UndeployStaticContentContainer ¶
func UndeployStaticContentContainer()
This cleans up the container deployed by DeployStaticContentContainer function The image is preserved after calling the function and thus need not be build again.
func UpdateChallenges ¶
func UpdateChallenges()
func UpdateOrCreateChallengeDbEntry ¶
func UpdateOrCreateChallengeDbEntry(challEntry *database.Challenge, config cfg.BeastChallengeConfig) error
TODO: Refactor this.
func ValidateChallengeConfig ¶
This if the function which validates the challenge directory which is provided as an arguments. This validtions includes * A valid directory pointed by challengeDir * Valid config file for the challenge in the challengeDir root named as beast.toml * Valid challenge directory name in accordance to the challenge config.
func ValidateChallengeDir ¶
Validates a directory which is considered as a challenge directory The function returns an error if the directory is not valid or if it does not have valid structure required by beast.