Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat_atlantis_ngrok_traefik_ssl #799

Merged
merged 5 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions cmd/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewCommand() *cobra.Command {
// todo: UPDATE IT BEFORE MERGING
// todo: UPDATE IT BEFORE MERGING
// todo: UPDATE IT BEFORE MERGING
localCmd.Flags().StringVar(&gitOpsBranch, "gitops-branch", "add-ingress-localhost", "version/branch used on git clone")
localCmd.Flags().StringVar(&gitOpsBranch, "gitops-branch", "fix_atlantis_tcp", "version/branch used on git clone")
localCmd.Flags().StringVar(&gitOpsRepo, "gitops-repo", "gitops", "")
localCmd.Flags().StringVar(&templateTag, "template-tag", "",
"when running a built version, and ldflag is set for the Kubefirst version, it will use this tag value to clone the templates (gitops and metaphor's)",
Expand Down Expand Up @@ -374,19 +374,6 @@ func runLocal(cmd *cobra.Command, args []string) error {
var wg sync.WaitGroup
wg.Add(1)
go func() {
// Atlantis port-forward
atlantisStopChannel := make(chan struct{}, 1)
defer func() {
close(atlantisStopChannel)
}()
k8s.OpenPortForwardPodWrapper(
pkg.AtlantisPodName,
pkg.AtlantisNamespace,
pkg.AtlantisPodPort,
pkg.AtlantisPodLocalPort,
atlantisStopChannel,
)

gitHubClient := githubWrapper.New()
err = gitHubClient.CreatePR(branchName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/local/prerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func validateLocal(cmd *cobra.Command, args []string) error {

viper.Set("argocd.local.service", pkg.ArgoCDLocalURL)
viper.Set("vault.local.service", pkg.VaultLocalURL)
go pkg.RunNgrok(context.TODO(), pkg.LocalAtlantisURLTEMPORARY)
go pkg.RunNgrok(context.TODO())

// addons
addon.AddAddon("github")
Expand Down
9 changes: 7 additions & 2 deletions pkg/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func DetokenizeDirectory(path string, fi os.FileInfo, err error) error {
githubRepoOwner := viper.GetString("github.owner")
githubOrg := viper.GetString("github.owner")
githubUser := viper.GetString("github.user")
ngrokUrl := viper.GetString("ngrok.url")

ngrokURL, err := url.Parse(viper.GetString("ngrok.url"))
if err != nil {
log.Println(err)
}

githubToken := os.Getenv("KUBEFIRST_GITHUB_AUTH_TOKEN")

Expand All @@ -148,7 +152,8 @@ func DetokenizeDirectory(path string, fi os.FileInfo, err error) error {
newContents = strings.Replace(newContents, "<GITHUB_USER>", githubUser, -1)
newContents = strings.Replace(newContents, "<GITHUB_TOKEN>", githubToken, -1)
newContents = strings.Replace(newContents, "<KUBEFIRST_VERSION>", configs.K1Version, -1)
newContents = strings.Replace(newContents, "<NGROK_HOST>", ngrokUrl, -1)
newContents = strings.Replace(newContents, "<NGROK_URL>", ngrokURL.String(), -1)
newContents = strings.Replace(newContents, "<NGROK_HOST>", ngrokURL.Host, -1)

var repoPathHTTPS string
var repoPathSSH string
Expand Down
8 changes: 4 additions & 4 deletions pkg/ngrok.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/sync/errgroup"
)

func RunNgrok(ctx context.Context, dest string) {
func RunNgrok(ctx context.Context) {

// todo: use it when atlantis port forward missing port in address issued is fixed
//atlantisURL, err := url.Parse(dest)
Expand Down Expand Up @@ -43,14 +43,14 @@ func RunNgrok(ctx context.Context, dest string) {

go func() {

err := handleConn(ctx, dest, conn)
err := handleConn(ctx, conn)
log.Println("connection closed:", err)
}()
}
}

func handleConn(ctx context.Context, dest string, conn net.Conn) error {
next, err := net.Dial("tcp", dest)
func handleConn(ctx context.Context, conn net.Conn) error {
next, err := net.Dial("tcp", ":80")
if err != nil {
return err
}
Expand Down