Skip to content

Commit

Permalink
Migrate provision package to inletsctl
Browse files Browse the repository at this point in the history
This package comes over from the operator to keep the provision-
ing code separate from the operator. The operator will vendor
it back after the next release.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Nov 28, 2019
1 parent bdcda2e commit 1b1eb6c
Show file tree
Hide file tree
Showing 22 changed files with 462 additions and 137 deletions.
30 changes: 13 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 56 additions & 5 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,66 @@
[prune]
go-tests = true
unused-packages = true
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/digitalocean/godo"
version = "1.27.0"

[[constraint]]
name = "github.com/morikuni/aec"
version = "1.0.0"

[[constraint]]
name = "github.com/packethost/packngo"
version = "0.2.0"

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.1"

[[constraint]]
name = "github.com/scaleway/scaleway-sdk-go"
version = "1.0.0-beta.4"

[[constraint]]
name = "github.com/sethvargo/go-password"
version = "0.1.3"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.5"

[[constraint]]
name = "github.com/inlets/inlets-operator"
version = "0.4.3"
name = "github.com/spf13/pflag"
version = "1.0.5"

[[constraint]]
branch = "master"
name = "golang.org/x/oauth2"

[prune]
go-tests = true
unused-packages = true
8 changes: 4 additions & 4 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"
"time"

"github.com/inlets/inletsctl/pkg"
names "github.com/inlets/inletsctl/pkg/names"
provision "github.com/inlets/inletsctl/pkg/provision"

provision "github.com/inlets/inlets-operator/pkg/provision"
"github.com/pkg/errors"
password "github.com/sethvargo/go-password/password"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -121,7 +121,7 @@ func runCreate(cmd *cobra.Command, _ []string) error {

remoteTCP, _ := cmd.Flags().GetString("remote-tcp")

name := strings.Replace(pkg.GetRandomName(10), "_", "-", -1)
name := strings.Replace(names.GetRandomName(10), "_", "-", -1)

inletsControlPort := 8080

Expand Down Expand Up @@ -198,7 +198,7 @@ func getProvisioner(provider, accessToken, secretKey, organisationID, region str
} else if provider == "packet" {
return provision.NewPacketProvisioner(accessToken)
} else if provider == "civo" {
return pkg.NewCivoProvisioner(accessToken)
return provision.NewCivoProvisioner(accessToken)
} else if provider == "scaleway" {
return provision.NewScalewayProvisioner(accessToken, secretKey, organisationID, region)
}
Expand Down
11 changes: 9 additions & 2 deletions cmd/inletsctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import (
)

var (
Version string
// Version as per git repo
Version string

// GitCommit as per git repo
GitCommit string
)

// WelcomeMessage to introduce inletsctl
const WelcomeMessage = "Welcome to inletsctl! Find out more at https://github.com/inlets/inletsctl"

func init() {
Expand All @@ -29,7 +33,10 @@ var inletsCmd = &cobra.Command{
Long: `
inletsctl can create exit nodes for you on your preferred cloud provider
so that you can run a single command and then connect with your inlets
client.`,
client.
See also: inlets-operator for Kubernetes and inlets-pro for TCP tunnelling.
`,
Run: runInlets,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/names.go → pkg/names/names.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Docker Author(s) 2019. All rights reserved.

package pkg
package names

import (
"fmt"
Expand Down
19 changes: 10 additions & 9 deletions pkg/civo.go → pkg/provision/civo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package pkg
// Copyright (c) Inlets Author(s) 2019. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

package provision

import (
"encoding/json"
Expand All @@ -10,8 +13,6 @@ import (

"strings"
"time"

"github.com/inlets/inlets-operator/pkg/provision"
)

// CivoProvisioner creates instances on civo.com
Expand All @@ -27,8 +28,8 @@ func NewCivoProvisioner(accessKey string) (*CivoProvisioner, error) {
}, nil
}

func (p *CivoProvisioner) Status(id string) (*provision.ProvisionedHost, error) {
host := &provision.ProvisionedHost{}
func (p *CivoProvisioner) Status(id string) (*ProvisionedHost, error) {
host := &ProvisionedHost{}

apiURL := fmt.Sprint("https://api.civo.com/v2/instances/", id)

Expand Down Expand Up @@ -61,7 +62,7 @@ func (p *CivoProvisioner) Status(id string) (*provision.ProvisionedHost, error)
return host, unmarshalErr
}

return &provision.ProvisionedHost{
return &ProvisionedHost{
ID: instance.ID,
IP: instance.PublicIP,
Status: strings.ToLower(instance.Status),
Expand Down Expand Up @@ -103,7 +104,7 @@ func (p *CivoProvisioner) Delete(id string) error {
return nil
}

func (p *CivoProvisioner) Provision(host provision.BasicHost) (*provision.ProvisionedHost, error) {
func (p *CivoProvisioner) Provision(host BasicHost) (*ProvisionedHost, error) {

log.Printf("Provisioning host with Civo\n")

Expand All @@ -117,12 +118,12 @@ func (p *CivoProvisioner) Provision(host provision.BasicHost) (*provision.Provis
return nil, err
}

return &provision.ProvisionedHost{
return &ProvisionedHost{
ID: res.ID,
}, nil
}

func provisionCivoInstance(host provision.BasicHost, key string) (CreatedInstance, error) {
func provisionCivoInstance(host BasicHost, key string) (CreatedInstance, error) {
instance := CreatedInstance{}

apiURL := "https://api.civo.com/v2/instances"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions vendor/github.com/digitalocean/godo/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/digitalocean/godo/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b1eb6c

Please sign in to comment.