forked from toolshed/abra
Compare commits
1 Commits
main
...
filter-by-
Author | SHA1 | Date | |
---|---|---|---|
5fea97c776
|
@ -98,11 +98,6 @@ keys configured on your account.
|
||||
continue
|
||||
}
|
||||
|
||||
if _, exists := catalogue.CatalogueSkipList[recipeMeta.Name]; exists {
|
||||
catlBar.Add(1)
|
||||
continue
|
||||
}
|
||||
|
||||
versions, err := recipe.GetRecipeVersions(recipeMeta.Name, internal.Offline)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
|
@ -1,61 +0,0 @@
|
||||
package recipe
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// getGitDiffArgs builds the `git diff` invocation args
|
||||
func getGitDiffArgs(repoPath string) []string {
|
||||
return []string{
|
||||
"-C",
|
||||
repoPath,
|
||||
"--no-pager",
|
||||
"-c",
|
||||
"color.diff=always",
|
||||
"diff",
|
||||
}
|
||||
}
|
||||
|
||||
var recipeDiffCommand = cli.Command{
|
||||
Name: "diff",
|
||||
Usage: "Show unstaged changes in recipe config",
|
||||
Description: "Due to limitations in our underlying Git dependency, this command requires /usr/bin/git.",
|
||||
Aliases: []string{"d"},
|
||||
ArgsUsage: "<recipe>",
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := c.Args().First()
|
||||
|
||||
if recipeName != "" {
|
||||
internal.ValidateRecipe(c)
|
||||
}
|
||||
|
||||
_, err := exec.LookPath("git")
|
||||
if err != nil {
|
||||
logrus.Fatal("unable to locate 'git' command?")
|
||||
}
|
||||
|
||||
gitDiffArgs := getGitDiffArgs(path.Join(config.RECIPES_DIR, recipeName))
|
||||
diff, err := exec.Command("git", gitDiffArgs...).Output()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Print(string(diff))
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
@ -30,7 +30,5 @@ manner. Abra supports convenient automation for recipe maintainenace, see the
|
||||
recipeSyncCommand,
|
||||
recipeUpgradeCommand,
|
||||
recipeVersionCommand,
|
||||
recipeResetCommand,
|
||||
recipeDiffCommand,
|
||||
},
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
package recipe
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var recipeResetCommand = cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "Remove all unstaged changes from recipe config",
|
||||
Description: "WARNING, this will delete your changes. Be Careful.",
|
||||
Aliases: []string{"rs"},
|
||||
ArgsUsage: "<recipe>",
|
||||
Flags: []cli.Flag{
|
||||
internal.DebugFlag,
|
||||
internal.NoInputFlag,
|
||||
},
|
||||
Before: internal.SubCommandBefore,
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipeName := c.Args().First()
|
||||
|
||||
if recipeName != "" {
|
||||
internal.ValidateRecipe(c)
|
||||
}
|
||||
|
||||
repoPath := path.Join(config.RECIPES_DIR, recipeName)
|
||||
repo, err := git.PlainOpen(repoPath)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
ref, err := repo.Head()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
worktree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
opts := &git.ResetOptions{Commit: ref.Hash(), Mode: git.HardReset}
|
||||
if err := worktree.Reset(opts); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
@ -12,46 +12,6 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// CatalogueSkipList is all the repos that are not recipes.
|
||||
var CatalogueSkipList = map[string]bool{
|
||||
"abra": true,
|
||||
"abra-apps": true,
|
||||
"abra-aur": true,
|
||||
"abra-bash": true,
|
||||
"abra-capsul": true,
|
||||
"abra-gandi": true,
|
||||
"abra-hetzner": true,
|
||||
"abra-test-recipe": true,
|
||||
"apps": true,
|
||||
"aur-abra-git": true,
|
||||
"auto-mirror": true,
|
||||
"auto-recipes-catalogue-json": true,
|
||||
"backup-bot": true,
|
||||
"backup-bot-two": true,
|
||||
"beta.coopcloud.tech": true,
|
||||
"comrade-renovate-bot": true,
|
||||
"coopcloud.tech": true,
|
||||
"coturn": true,
|
||||
"docker-cp-deploy": true,
|
||||
"docker-dind-bats-kcov": true,
|
||||
"docs.coopcloud.tech": true,
|
||||
"drone-abra": true,
|
||||
"example": true,
|
||||
"gardening": true,
|
||||
"go-abra": true,
|
||||
"organising": true,
|
||||
"pyabra": true,
|
||||
"radicle-seed-node": true,
|
||||
"recipes-catalogue-json": true,
|
||||
"recipes-wishlist": true,
|
||||
"recipes.coopcloud.tech": true,
|
||||
"stack-ssh-deploy": true,
|
||||
"swarm-cronjob": true,
|
||||
"tagcmp": true,
|
||||
"traefik-cert-dumper": true,
|
||||
"tyop": true,
|
||||
}
|
||||
|
||||
// EnsureCatalogue ensures that the catalogue is cloned locally & present.
|
||||
func EnsureCatalogue() error {
|
||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -31,7 +32,7 @@ import (
|
||||
// RecipeCatalogueURL is the only current recipe catalogue available.
|
||||
const RecipeCatalogueURL = "https://recipes.coopcloud.tech/recipes.json"
|
||||
|
||||
// ReposMetadataURL is the recipe repository metadata
|
||||
// ReposMetadataURL is the recipe repository metadata.
|
||||
const ReposMetadataURL = "https://git.coopcloud.tech/api/v1/orgs/coop-cloud/repos"
|
||||
|
||||
// tag represents a git tag.
|
||||
@ -63,6 +64,11 @@ type RecipeMeta struct {
|
||||
Website string `json:"website"`
|
||||
}
|
||||
|
||||
// TopicMeta represents a list of topics for a repository.
|
||||
type TopicMeta struct {
|
||||
Topics []string `json:"topics"`
|
||||
}
|
||||
|
||||
// LatestVersion returns the latest version of a recipe.
|
||||
func (r RecipeMeta) LatestVersion() string {
|
||||
var version string
|
||||
@ -822,7 +828,16 @@ func ReadReposMetadata() (RepoCatalogue, error) {
|
||||
}
|
||||
|
||||
for idx, repo := range reposList {
|
||||
reposMeta[repo.Name] = reposList[idx]
|
||||
var topicMeta TopicMeta
|
||||
|
||||
topicsURL := getReposTopicUrl(repo.Name)
|
||||
if err := web.ReadJSON(topicsURL, &topicMeta); err != nil {
|
||||
return reposMeta, err
|
||||
}
|
||||
|
||||
if slices.Contains(topicMeta.Topics, "recipe") && repo.Name != "example" {
|
||||
reposMeta[repo.Name] = reposList[idx]
|
||||
}
|
||||
}
|
||||
|
||||
pageIdx++
|
||||
@ -1002,14 +1017,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error {
|
||||
retrieveBar.Add(1)
|
||||
return
|
||||
}
|
||||
if _, exists := catalogue.CatalogueSkipList[rm.Name]; exists {
|
||||
ch <- rm.Name
|
||||
retrieveBar.Add(1)
|
||||
return
|
||||
}
|
||||
|
||||
recipeDir := path.Join(config.RECIPES_DIR, rm.Name)
|
||||
|
||||
if err := gitPkg.Clone(recipeDir, rm.CloneURL); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
@ -1025,3 +1034,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// getReposTopicUrl retrieves the repository specific topic listing.
|
||||
func getReposTopicUrl(repoName string) string {
|
||||
return fmt.Sprintf("https://git.coopcloud.tech/api/v1/repos/coop-cloud/%s/topics", repoName)
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ABRA_VERSION="0.8.1-beta"
|
||||
ABRA_VERSION="0.8.0-beta"
|
||||
ABRA_RELEASE_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$ABRA_VERSION"
|
||||
RC_VERSION="0.8.1-beta"
|
||||
RC_VERSION="0.8.0-beta"
|
||||
RC_VERSION_URL="https://git.coopcloud.tech/api/v1/repos/coop-cloud/abra/releases/tags/$RC_VERSION"
|
||||
|
||||
for arg in "$@"; do
|
||||
@ -78,11 +78,11 @@ function install_abra_release {
|
||||
mv "$HOME/.local/bin/.abra-download" "$HOME/.local/bin/abra"
|
||||
chmod +x "$HOME/.local/bin/abra"
|
||||
|
||||
x=$(export $PATH | grep $HOME/.local/bin)
|
||||
x=$(echo $PATH | grep $HOME/.local/bin)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$(tput setaf 3)WARNING: $HOME/.local/bin/ is not in \$PATH! If you want to run abra by just typing "abra" you should add it to your \$PATH! To do that run:$(tput sgr0)"
|
||||
p=$HOME/.local/bin
|
||||
com="export PATH=\$PATH:$p"
|
||||
com="echo PATH=\$PATH:$p"
|
||||
if [[ $SHELL =~ "bash" ]]; then
|
||||
echo "$com >> $HOME/.bashrc"
|
||||
elif [[ $SHELL =~ "fizsh" ]]; then
|
||||
|
@ -35,7 +35,7 @@ setup(){
|
||||
|
||||
run $ABRA app check "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
refute_output --partial '❌'
|
||||
assert_output --partial 'all necessary environment variables defined'
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
@ -111,16 +111,12 @@ setup(){
|
||||
}
|
||||
|
||||
@test "error if missing env var" {
|
||||
run $ABRA app check "$TEST_APP_DOMAIN"
|
||||
assert_success
|
||||
refute_output --partial '❌'
|
||||
|
||||
run bash -c 'echo "NEW_VAR=foo" >> "$ABRA_DIR/recipes/$TEST_RECIPE/.env.sample"'
|
||||
assert_success
|
||||
|
||||
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
|
||||
assert_success
|
||||
assert_output --partial '❌'
|
||||
assert_failure
|
||||
assert_output --partial "NEW_VAR"
|
||||
|
||||
_checkout_recipe
|
||||
}
|
||||
|
@ -321,8 +321,6 @@ teardown(){
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "COMPOSE_FILE with \$COMPOSE_FILE override works" {
|
||||
_reset_recipe
|
||||
|
||||
run sed -i 's/#COMPOSE_FILE="$COMPOSE_FILE:compose.extra_env.yml"/COMPOSE_FILE="$COMPOSE_FILE:compose.extra_env.yml"/g' \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_success
|
||||
|
@ -110,11 +110,10 @@ setup(){
|
||||
assert_success
|
||||
assert_output --partial 'test_pass_one'
|
||||
|
||||
run bash -c '$ABRA app secret ls $TEST_APP_DOMAIN --machine | \
|
||||
jq -r ".[] | select(.name==\"test_pass_one\") | .version"'
|
||||
run docker -c "$TEST_SERVER" secret ls
|
||||
assert_success
|
||||
assert_output --partial 'v2'
|
||||
refute_output --partial 'v1'
|
||||
assert_output --regexp ".*_test_pass_one_v2"
|
||||
refute_output --regexp ".*_test_pass_one_v1"
|
||||
|
||||
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
||||
assert_success
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "show unstaged changes" {
|
||||
run $ABRA recipe diff "$TEST_RECIPE"
|
||||
assert_success
|
||||
refute_output --partial 'traefik.enable'
|
||||
|
||||
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe diff "$TEST_RECIPE"
|
||||
assert_success
|
||||
assert_output --partial 'traefik.enable'
|
||||
|
||||
_reset_recipe
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "reset unstaged changes" {
|
||||
run $ABRA recipe fetch "$TEST_RECIPE"
|
||||
assert_success
|
||||
|
||||
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe diff "$TEST_RECIPE"
|
||||
assert_success
|
||||
assert_output --partial 'traefik.enable'
|
||||
|
||||
run $ABRA recipe reset "$TEST_RECIPE"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe diff "$TEST_RECIPE"
|
||||
assert_success
|
||||
refute_output --partial 'traefik.enable'
|
||||
}
|
Reference in New Issue
Block a user