From 9378db1979c2b81ab0d6ffc2ad64ed65eab4be1e Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 4 Aug 2021 22:51:07 +0200 Subject: [PATCH 1/2] fix: look up ipv4 from host correctly We use a custom resolver now instead of relying on the baked-in Golang resolver which has issues. We use a friendly librehoster DNS resolver and not Google because fuck that. --- cli/server/init.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/cli/server/init.go b/cli/server/init.go index f423844b..d9a44d67 100644 --- a/cli/server/init.go +++ b/cli/server/init.go @@ -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 From 202f7ce561caecc059695980f4a7be749ef422fe Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 4 Aug 2021 23:52:34 +0200 Subject: [PATCH 2/2] WIP: spec'ing out the release command See https://git.coopcloud.tech/coop-cloud/go-abra/issues/39. --- cli/recipe/recipe.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cli/recipe/recipe.go b/cli/recipe/recipe.go index d59629d9..7ed08f21 100644 --- a/cli/recipe/recipe.go +++ b/cli/recipe/recipe.go @@ -149,6 +149,38 @@ var recipeCreateCommand = &cli.Command{ }, } +var recipeReleaseCommand = &cli.Command{ + Name: "release", + Usage: "Release a new recipe version", + ArgsUsage: "", + 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, }, }