Merge branch 'main' into dev

This commit is contained in:
knoflook 2021-08-05 16:54:27 +00:00
commit ed6d3d7b66
2 changed files with 55 additions and 9 deletions

View File

@ -149,6 +149,38 @@ var recipeCreateCommand = &cli.Command{
}, },
} }
var recipeReleaseCommand = &cli.Command{
Name: "release",
Usage: "Release a new recipe version",
ArgsUsage: "<recipe>",
Action: func(c *cli.Context) error {
recipe := c.Args().First()
if recipe == "" {
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
}
//TODO: read all local tags and read all upstream tags
// and then ask which you'd like to upgrade to
// ensure that this release isn't in local or upstream already
// after each choice, make change and show diff
//TODO: read the apps catalogue and read the latest version of the recipe
// read the latest local tag of the recipe
// if there are no new changes, and upstream/local point to same commit, there is nothing to update, bail
// if there are changes and the commit they both point to is different, then this is a new release
// figure out the new version
// if the catalogue latest and the local latest are the same, N+1 release
// otherwise, use the local latest tag as the new version
// apply that version to all labels and show diff
//TODO: offer to commit all the things
// offer to make a git tag for that with the new version
// offer to git push that upstream
return nil
},
}
var recipeLintCommand = &cli.Command{ var recipeLintCommand = &cli.Command{
Name: "lint", Name: "lint",
Usage: "Recipe configuration linter", Usage: "Recipe configuration linter",
@ -253,6 +285,7 @@ how reliable this app is to deploy and maintain in its current state.
recipeListCommand, recipeListCommand,
recipeVersionCommand, recipeVersionCommand,
recipeCreateCommand, recipeCreateCommand,
recipeReleaseCommand,
recipeLintCommand, recipeLintCommand,
}, },
} }

View File

@ -5,11 +5,13 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"time"
"coopcloud.tech/abra/cli/internal" "coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/client" "coopcloud.tech/abra/client"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
@ -36,20 +38,31 @@ later for more advanced use cases.
return err return err
} }
var ipv4 net.IP resolver := &net.Resolver{
ips, _ := net.LookupIP(host) PreferGo: false,
for _, ip := range ips { Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
ipv4 = ip.To4() d := net.Dialer{
Timeout: time.Millisecond * time.Duration(10000),
} }
// comrade librehosters DNS resolver https://snopyta.org/service/dns/
if string(ipv4) == "" { return d.DialContext(ctx, "udp", "95.216.24.230:53")
return fmt.Errorf("unable to retrieve ipv4 address for %s", host) },
} }
ctx := context.Background() ctx := context.Background()
ips, err := resolver.LookupIPAddr(ctx, host)
if err != nil {
logrus.Fatal(err)
}
if len(ips) == 0 {
return fmt.Errorf("unable to retrieve ipv4 address for %s", host)
}
ipv4 := ips[0].IP.To4().String()
initReq := swarm.InitRequest{ initReq := swarm.InitRequest{
ListenAddr: "0.0.0.0:2377", ListenAddr: "0.0.0.0:2377",
AdvertiseAddr: string(ipv4), AdvertiseAddr: ipv4,
} }
if _, err := cl.SwarmInit(ctx, initReq); err != nil { if _, err := cl.SwarmInit(ctx, initReq); err != nil {
return err return err