Skip to content

Commit

Permalink
Merge branch 'release/0.32.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Holy committed Oct 5, 2021
2 parents 4ed7755 + 391c4f2 commit 3e824dd
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 104 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.31.1
0.32.0
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public List<ProducerRecord<String, SpecificRecordBase>> getRecords(Event event,
} else if (appId != null && !appId.equals(this.facebookAppId)) {
// Third party app
senderId = appId;
} else if (appId == null && !"instagram".equals(channel.getSource())) {
} else if (appId == null) {
// Sent by Facebook moderator via Facebook inbox
senderId = getSourceConversationId(rootNode);
} else {
Expand Down
3 changes: 3 additions & 0 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ require (
github.com/kr/pretty v0.2.1
github.com/mitchellh/copystructure v1.1.2 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/thanhpk/randstr v1.0.4
github.com/txn2/txeh v1.3.0
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
goji.io v2.0.2+incompatible
gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.19.0
k8s.io/apimachinery v0.19.0
Expand Down
6 changes: 6 additions & 0 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 h1:ZuhckGJ10ulaKkdvJtiAqsLTiPrLaXSdnVgXJKJkTxE=
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3/go.mod h1:9/Rh6yILuLysoQnZ2oNooD2g7aBnvM7r/fNVxRNWfBc=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down Expand Up @@ -326,6 +328,8 @@ github.com/txn2/txeh v1.3.0/go.mod h1:O7M6gUTPeMF+vsa4c4Ipx3JDkOYrruB1Wry8QRsMcw
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
Expand Down Expand Up @@ -504,6 +508,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/segmentio/analytics-go.v3 v3.1.0 h1:UzxH1uaGZRpMKDhJyBz0pexz6yUoBU3x8bJsRk/HV6U=
gopkg.in/segmentio/analytics-go.v3 v3.1.0/go.mod h1:4QqqlTlSSpVlWA9/9nDcPw+FkM2yv1NQoYjUbL9/JAw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
1 change: 1 addition & 0 deletions cli/pkg/cmd/create/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
"@com_github_spf13_cobra//:cobra",
"@com_github_spf13_viper//:viper",
"@com_github_twinproduction_go_color//:go-color",
"@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
"@io_k8s_api//batch/v1:go_default_library",
"@io_k8s_api//core/v1:go_default_library",
"@io_k8s_api//rbac/v1:go_default_library",
Expand Down
36 changes: 26 additions & 10 deletions cli/pkg/cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ import (
"cli/pkg/workspace"
"fmt"
"os"
"runtime"

"github.com/TwinProduction/go-color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gopkg.in/segmentio/analytics-go.v3"
)

var (
providerName string
providerConfig map[string]string
namespace string
version string
initOnly bool
noApply bool
CreateCmd = &cobra.Command{
providerName string
providerConfig map[string]string
namespace string
version string
initOnly bool
noApply bool
disableTracking bool
CreateCmd = &cobra.Command{
Use: "create [workspace directory]",
Short: "Creates an instance of Airy Core",
Long: `Creates a workspace directory (default .) with default configuration and starts an Airy Core instance using the given provider`,
Expand All @@ -37,6 +40,7 @@ func init() {
CreateCmd.Flags().StringVar(&namespace, "namespace", "default", "(optional) Kubernetes namespace that Airy should be installed to.")
CreateCmd.Flags().BoolVar(&initOnly, "init-only", false, "Only create the airy workspace directory and exit.")
CreateCmd.Flags().BoolVar(&noApply, "no-apply", false, "Don't apply any component configuration found in an existing airy.yaml file after creation.")
CreateCmd.Flags().BoolVar(&disableTracking, "disable-tracking", false, "Disables sending anonymous events to Segment.")
CreateCmd.MarkFlagRequired("provider")
}

Expand All @@ -49,7 +53,16 @@ func create(cmd *cobra.Command, args []string) {
w := console.GetMiddleware(func(input string) string {
return color.Colorize(color.Cyan, "#\t"+input)
})
provider := providers.MustGet(providers.ProviderName(providerName), w)

var rtm runtime.MemStats
runtime.ReadMemStats(&rtm)

airyAnalytics := console.NewAiryAnalytics(disableTracking)
airyAnalytics.Track(analytics.Track{
AnonymousId: "AiryUser",
Event: "installation_started",
})
provider := providers.MustGet(providers.ProviderName(providerName), w, airyAnalytics)
overrides := provider.GetOverrides()
overrides.Version = version
overrides.Namespace = namespace
Expand All @@ -58,7 +71,7 @@ func create(cmd *cobra.Command, args []string) {
console.Exit("could not initialize Airy workspace directory", err)
}
fmt.Println("📁 Initialized Airy workspace directory at", dir.GetPath("."))
if initOnly == true {
if initOnly {
os.Exit(0)
}

Expand Down Expand Up @@ -117,11 +130,14 @@ func create(cmd *cobra.Command, args []string) {
viper.Set("namespace", namespace)
viper.WriteConfig()

if noApply != true {
if !noApply {
fmt.Println("⚙️ Applying config from airy.yaml")
config.ApplyConfig(workspacePath)
}

airyAnalytics.Track(analytics.Track{
AnonymousId: "AiryUser",
Event: "installation_succesful"})
fmt.Printf("📚 For more information about the %s provider visit https://airy.co/docs/core/getting-started/installation/%s", providerName, providerName)
fmt.Println()
}
Expand Down
4 changes: 4 additions & 0 deletions cli/pkg/console/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ go_library(
srcs = [
"failure.go",
"output.go",
"segment.go",
],
importpath = "cli/pkg/console",
visibility = ["//visibility:public"],
deps = [
"@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
],
)
25 changes: 25 additions & 0 deletions cli/pkg/console/segment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package console

import (
"fmt"

"gopkg.in/segmentio/analytics-go.v3"
)

type AiryAnalytics struct {
client analytics.Client
disableTracking bool
}

func NewAiryAnalytics(disableTracking bool) *AiryAnalytics {
return &AiryAnalytics{client: analytics.New("7OOYJk8lQ2jfmZXKz5jJuvcK50BNDHit"), disableTracking: disableTracking}
}

func (a *AiryAnalytics) Track(message analytics.Message) {
if !a.disableTracking {
err := a.client.Enqueue(message)
if err != nil {
fmt.Println(err)
}
}
}
1 change: 1 addition & 0 deletions cli/pkg/providers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
importpath = "cli/pkg/providers",
visibility = ["//visibility:public"],
deps = [
"//cli/pkg/console",
"//cli/pkg/kube",
"//cli/pkg/providers/aws",
"//cli/pkg/providers/minikube",
Expand Down
1 change: 1 addition & 0 deletions cli/pkg/providers/aws/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"@com_github_aws_aws_sdk_go_v2_service_iam//:iam",
"@com_github_aws_aws_sdk_go_v2_service_iam//types",
"@com_github_twinproduction_go_color//:go-color",
"@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
],
)
12 changes: 10 additions & 2 deletions cli/pkg/providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"text/template"
"time"

"gopkg.in/segmentio/analytics-go.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/TwinProduction/go-color"
Expand All @@ -35,11 +36,13 @@ type provider struct {
ec2Client *ec2.Client
iamClient *iam.Client
eksClient *eks.Client
analytics console.AiryAnalytics
}

func New(w io.Writer) *provider {
func New(w io.Writer, analytics *console.AiryAnalytics) *provider {
return &provider{
w: w,
w: w,
analytics: *analytics,
}
}

Expand All @@ -66,6 +69,11 @@ func (p *provider) Provision(providerConfig map[string]string, dir workspace.Con
}

id := RandString(8)
p.analytics.Track(analytics.Identify{
UserId: id,
Traits: analytics.NewTraits().
Set("provider", "AWS"),
})
name := "Airy-" + id
fmt.Fprintf(p.w, "Creating Airy Core instance with id: %s. This might take a while.\n", name)
p.iamClient = iam.NewFromConfig(cfg)
Expand Down
2 changes: 2 additions & 0 deletions cli/pkg/providers/minikube/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ go_library(
importpath = "cli/pkg/providers/minikube",
visibility = ["//visibility:public"],
deps = [
"//cli/pkg/console",
"//cli/pkg/kube",
"//cli/pkg/workspace",
"//cli/pkg/workspace/template",
"@com_github_txn2_txeh//:txeh",
"@in_gopkg_segmentio_analytics_go_v3//:analytics-go_v3",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_client_go//util/homedir:go_default_library",
],
Expand Down
23 changes: 19 additions & 4 deletions cli/pkg/providers/minikube/minikube.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package minikube

import (
"cli/pkg/console"
"cli/pkg/kube"
"cli/pkg/workspace"
"cli/pkg/workspace/template"
Expand All @@ -9,8 +10,10 @@ import (
"io"
"os/exec"
"path/filepath"
"runtime"
"strings"

"gopkg.in/segmentio/analytics-go.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/homedir"
)
Expand All @@ -22,13 +25,15 @@ const (
)

type provider struct {
context kube.KubeCtx
w io.Writer
context kube.KubeCtx
w io.Writer
analytics console.AiryAnalytics
}

func New(w io.Writer) *provider {
func New(w io.Writer, analytics *console.AiryAnalytics) *provider {
return &provider{
w: w,
w: w,
analytics: *analytics,
}
}

Expand All @@ -44,6 +49,7 @@ func (p *provider) Provision(providerConfig map[string]string, dir workspace.Con
return kube.KubeCtx{}, err
}


if err := p.startCluster(); err != nil {
return kube.KubeCtx{}, err
}
Expand Down Expand Up @@ -121,6 +127,15 @@ func (p *provider) PostInstallation(providerConfig map[string]string, dir worksp
if err != nil {
return err
}

p.analytics.Track(analytics.Identify{
UserId: coreId,
Traits: analytics.NewTraits().
Set("provider", "minikube").
Set("numCpu", runtime.NumCPU()),
},
)

ngrokEndpoint := fmt.Sprintf("https://%s.tunnel.airy.co", strings.Trim(coreId, "'"))

configMap.Data["NGROK"] = ngrokEndpoint
Expand Down
7 changes: 4 additions & 3 deletions cli/pkg/providers/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package providers

import (
"cli/pkg/console"
"cli/pkg/kube"
"cli/pkg/providers/aws"
"cli/pkg/providers/minikube"
Expand All @@ -23,13 +24,13 @@ type Provider interface {
PostInstallation(providerConfig map[string]string, dir workspace.ConfigDir) error
}

func MustGet(providerName ProviderName, w io.Writer) Provider {
func MustGet(providerName ProviderName, w io.Writer, analytics *console.AiryAnalytics) Provider {
if providerName == Minikube {
return minikube.New(w)
return minikube.New(w, analytics)
}

if providerName == Aws {
return aws.New(w)
return aws.New(w, analytics)
}

panic(fmt.Sprintf("unknown provider \"%v\"", providerName))
Expand Down
2 changes: 0 additions & 2 deletions cli/pkg/workspace/airy_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type IngressConf struct {
Https bool `yaml:"https,omitempty"`
LetsencryptEmail string `yaml:"letsencryptEmail,omitempty"`
LoadbalancerAnnotations map[string]string `yaml:"loadbalancerAnnotations,omitempty"`
HttpsTermination string `yaml:"httpsTermination,omitempty"`
HttpsCertificate string `yaml:"httpsCertificate,omitempty"`
}

type SecurityConf struct {
Expand Down
Loading

0 comments on commit 3e824dd

Please sign in to comment.