Merge branch 'main' into dev
This commit is contained in:
commit
ed6d3d7b66
|
@ -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{
|
||||
Name: "lint",
|
||||
Usage: "Recipe configuration linter",
|
||||
|
@ -253,6 +285,7 @@ how reliable this app is to deploy and maintain in its current state.
|
|||
recipeListCommand,
|
||||
recipeVersionCommand,
|
||||
recipeCreateCommand,
|
||||
recipeReleaseCommand,
|
||||
recipeLintCommand,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -5,11 +5,13 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/client"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -36,20 +38,31 @@ later for more advanced use cases.
|
|||
return err
|
||||
}
|
||||
|
||||
var ipv4 net.IP
|
||||
ips, _ := net.LookupIP(host)
|
||||
for _, ip := range ips {
|
||||
ipv4 = ip.To4()
|
||||
}
|
||||
|
||||
if string(ipv4) == "" {
|
||||
return fmt.Errorf("unable to retrieve ipv4 address for %s", host)
|
||||
resolver := &net.Resolver{
|
||||
PreferGo: false,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{
|
||||
Timeout: time.Millisecond * time.Duration(10000),
|
||||
}
|
||||
// comrade librehosters DNS resolver https://snopyta.org/service/dns/
|
||||
return d.DialContext(ctx, "udp", "95.216.24.230:53")
|
||||
},
|
||||
}
|
||||
|
||||
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{
|
||||
ListenAddr: "0.0.0.0:2377",
|
||||
AdvertiseAddr: string(ipv4),
|
||||
AdvertiseAddr: ipv4,
|
||||
}
|
||||
if _, err := cl.SwarmInit(ctx, initReq); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue