Created
April 1, 2019 22:32
-
-
Save fubarhouse/4c8e8e75b2d94918da610af197d316a0 to your computer and use it in GitHub Desktop.
Magefile for Lagoon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build mage | |
// An abstraction layer for Amazeeio's Lagoon Make process. | |
// Made to suit compatibility with v0.22.1 | |
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
"strings" | |
"github.com/magefile/mage/sh" | |
) | |
// Build lagoon images on the localhost. | |
func Localhost_build() error { | |
return sh.Run("make", "build") | |
} | |
// Start lagoon on the localhost via docker-compose. | |
func Localhost_run() error { | |
return sh.Run("docker-compose", "up", "-d") | |
} | |
// Terminate lagoon on the localhost via docker-compose. | |
func Localhost_stop() error { | |
return sh.Run("docker-compose", "down") | |
} | |
// Removes and cleans up file system from built lagoon images. | |
func Localhost_clean() error { | |
return sh.Run("make", "down") | |
} | |
// Run lagoon tests on the localhost. | |
func Localhost_test() error { | |
return sh.Run("make", "tests") | |
} | |
// Push images from the localhost to MiniShift | |
func Minishift_push() error { | |
return sh.Run("make", "push-minishift") | |
} | |
// Setup Minishift Lagoon | |
func Minishift_setup() error { | |
return sh.Run("make", "openshift-lagoon-setup") | |
} | |
// Configure Lagoon Local | |
func Minishift_configure() error { | |
return sh.Run("make", "openshift/configure-lagoon-local") | |
} | |
// Setup UI for local development with docker-compose. | |
func Localhost_ui() error { | |
return sh.Run("make", "ui-development") | |
} | |
// Starts/installs minishift. | |
func Minishift() error { | |
return sh.Run("make", "minishift") | |
} | |
// Stop minishift. | |
func Minishift_stop() error { | |
return sh.Run("make", "minishift") | |
} | |
// Cleans minishift. | |
func Minishift_clean() error { | |
return sh.Run("make", "openshift/clean") | |
} | |
// Find any kubernetes objects files | |
func Find() error { | |
count := 0 | |
fileList := []string{} | |
err := filepath.Walk(".", func(path string, f os.FileInfo, err error) error { | |
if strings.HasSuffix(path, "yaml") || strings.HasSuffix(path, "yml") { | |
b, err := ioutil.ReadFile(path) | |
if err != nil { | |
panic(err) | |
} | |
s := string(b) | |
if strings.Contains(s, "spec:") && strings.Contains(s, "kind:") { | |
fileList = append(fileList, path) | |
count++ | |
} | |
} | |
return nil | |
}) | |
for _, file := range fileList { | |
fmt.Println(file) | |
} | |
fmt.Printf("\nFound %v Kubernetes object files\n", count) | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment