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

adding go-cli #67

Merged
merged 139 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
30da87c
adding go-cli
6za Jun 29, 2022
bd989f4
sign commit
6za Jun 29, 2022
c8db3e4
rename project
6za Jun 29, 2022
ee55614
adding init/create steps
6za Jun 29, 2022
171bd5d
adding globals note
6za Jun 29, 2022
9d7a5a7
removing the templates
6za Jun 30, 2022
de30a93
update globals
6za Jun 30, 2022
c0faaed
update security check
6za Jun 30, 2022
643070f
rebranding cli
6za Jun 30, 2022
6906657
Add check tools and update outputs
6za Jun 30, 2022
ebf480b
simplify os.shell calls
6za Jun 30, 2022
3a0d9bf
minor notes tweaks
6za Jul 1, 2022
ef7b21c
cleaning create steps
6za Jul 1, 2022
a03550f
address zip slip
6za Jul 1, 2022
0eecf34
address zip slip
6za Jul 1, 2022
4756113
cleaning some steps
6za Jul 1, 2022
410f0a3
reshuffle create steps
6za Jul 1, 2022
438fa36
Redirecting out to logs
6za Jul 4, 2022
97b5e70
add create dry-run
6za Jul 4, 2022
a98418a
Merge pull request #68 from kubefirst/go-cli-v0.0.2
6za Jul 4, 2022
d4d0076
add progress bars
6za Jul 4, 2022
8b2a84a
fix pr comments
6za Jul 4, 2022
bb64a1e
Merge pull request #70 from kubefirst/go-cli-v0.0.2
6za Jul 4, 2022
f0a63e4
reorg funcs
6za Jul 4, 2022
5c077bc
reorg funcs
6za Jul 4, 2022
e29a749
synching changes
6za Jul 5, 2022
f749ebb
synching changes
6za Jul 5, 2022
59774ac
synching changes
6za Jul 5, 2022
233a1a3
synching changes
6za Jul 5, 2022
de5b6b8
review create/init
6za Jul 5, 2022
92d9632
review imports
6za Jul 5, 2022
a0508c3
fix dry-run create
6za Jul 5, 2022
405f81d
Merge pull request #71 from kubefirst/go-cli-0.1.1
6za Jul 5, 2022
12e0d82
add some skip steps
6za Jul 5, 2022
145af0f
Adding skip steps
6za Jul 5, 2022
65bfc9d
feat: add docker compose to kubefirst-dev
Jul 6, 2022
5de2a04
Merge pull request #74 from kubefirst/add_docker_compose
Jul 6, 2022
a98e421
refactor: update gitlab folder structure, and clean up
Jul 6, 2022
961528b
Merge pull request #75 from kubefirst/update_gitlab_structure
Jul 6, 2022
0d8d641
refactor: update vault calls
Jul 6, 2022
18843fe
Add destroy buckets
6za Jul 6, 2022
eb292de
Merge conflict
6za Jul 6, 2022
ca6a4a3
added new lines
6za Jul 6, 2022
7bfcc0f
Merge pull request #72 from kubefirst/go-cli-v0.1.3
6za Jul 6, 2022
893b5d7
refactor: move setup functions to configs, add more descriptive docum…
Jul 6, 2022
00ef485
chore: add better log data
Jul 6, 2022
19d16d4
chore: add better log data
Jul 6, 2022
97d33ed
Merge pull request #76 from kubefirst/update_pkg_kubefirst
Jul 6, 2022
8b866ff
refactor: add initial single source of truth for config, re-structure
Jul 7, 2022
4928b34
refactor: move kubernetes client requests to internal
Jul 7, 2022
78e9b26
refactor: move kubernetes client requests to internal
Jul 7, 2022
17a77fc
refactor: move gitlab functions to gitlab internal
Jul 7, 2022
07d56c1
refactor: remove globals, add values to config
Jul 7, 2022
da76738
refactor: move git to internal
Jul 7, 2022
1145aee
refactor: remove unused commands, refactor argocd and helm calls
Jul 7, 2022
1576b1e
refactor: move ssh and gitlab functions
Jul 7, 2022
f5b2625
refactor: move vault and softserve to internal
Jul 7, 2022
0bfeb1e
chore: update logs to use logs.panic
Jul 7, 2022
0c8ed06
refactor: move command line flags to function callers
Jul 8, 2022
96d9b6d
refactor: update init progress bar
Jul 11, 2022
97ea13e
added cluster-name and gitops-version
pagottoo Jul 11, 2022
d756e18
blank space
pagottoo Jul 11, 2022
6ca1e55
Merge pull request #82 from kubefirst/feat/cluster-name-gitops-version
pagottoo Jul 11, 2022
f20eb40
chore: merge arcocdsync and clean commands
Jul 11, 2022
52e2a56
chore: merge in progress, code is breaking, now we can start validati…
Jul 11, 2022
96869c7
chore: merge in progress, code is breaking at init command
Jul 11, 2022
b533dd6
refactor: update progress bar
Jul 11, 2022
95fc203
chore: update step names
Jul 11, 2022
b414683
chore: update installation steps
Jul 11, 2022
88b2813
Merge pull request #84 from kubefirst/update_cmd_structure-manual-mer…
Jul 12, 2022
d2a5864
Merge pull request #78 from kubefirst/update_cmd_structure
Jul 12, 2022
97b0940
Rename repo
6za Jul 12, 2022
1ecda99
Merge pull request #86 from kubefirst/go-cli-rename
Jul 12, 2022
f98a324
docs: update readme with more general details
Jul 12, 2022
76d3db8
docs: fix typo
Jul 12, 2022
e44c80b
Merge pull request #87 from kubefirst/update_readme
Jul 12, 2022
e7f0890
reapply branch code
6za Jul 12, 2022
2d7157c
revert terraform action
6za Jul 12, 2022
4d74f47
fix err
6za Jul 12, 2022
c2092ae
re-ordering the functions (#89)
jarededwards Jul 12, 2022
c48813f
merge conflict
6za Jul 12, 2022
2f934f4
Merge pull request #88 from kubefirst/go-cli-reapply-branch
6za Jul 12, 2022
e4154e1
fix change
6za Jul 12, 2022
16c891d
fix change again
6za Jul 12, 2022
a3b5a14
Merge pull request #91 from kubefirst/go-cli-fix-20220712-v2
6za Jul 12, 2022
78fbe91
feat: expose argocd container port
Jul 12, 2022
1edef42
fix: fix aws profile config
Jul 12, 2022
f325a13
chore: expose gitlab and vault ports
Jul 12, 2022
171f3ee
Merge pull request #93 from kubefirst/fix_tf_profile
Jul 12, 2022
abb4352
Adding new ways to call shell
6za Jul 13, 2022
e938e41
Migrate most of terraforms
6za Jul 13, 2022
d46a034
Fix Var
6za Jul 13, 2022
a91d3de
Fix err
6za Jul 13, 2022
ce0b930
Fix err
6za Jul 13, 2022
6736de7
feat: update files and folders to follow rebranding
Jul 13, 2022
2e7b483
Merge pull request #94 from kubefirst/go-cli-0713-update-output
6za Jul 13, 2022
f3c50d5
chore: update naming left overs
Jul 13, 2022
1e11ff7
Merge pull request #95 from kubefirst/update_kubefirst_path
Jul 13, 2022
8555ff2
add new progress lib
6za Jul 13, 2022
980c464
create go-release-binaries workflow
johndietz Jul 13, 2022
5fe9b3c
add additional os/arch
johndietz Jul 13, 2022
810fb23
Merge pull request #97 from kubefirst/go-cli-0713-new-progress-bars
6za Jul 14, 2022
5e817ba
Explore a smaller create flow
6za Jul 14, 2022
78c99af
restore dry-run create
6za Jul 14, 2022
a8a5155
Merge pull request #99 from kubefirst/go-cli-0714-create-dry-run
6za Jul 14, 2022
69ce039
feat: implement handoff screen for clean command
Jul 14, 2022
3cecb27
chore: clean up
Jul 14, 2022
5ff4987
Merge pull request #100 from kubefirst/final_message_mvp
Jul 14, 2022
b821488
clean portforward noise
6za Jul 14, 2022
c0aefcd
Merge pull request #101 from kubefirst/go-cli-0714-silence-portforward
6za Jul 14, 2022
e241413
adding retry spec to argocd registry (#102)
johndietz Jul 14, 2022
7eab4c7
enable bucket version
6za Jul 14, 2022
31da92a
Merge pull request #103 from kubefirst/go-cli-versioning-buckets
6za Jul 14, 2022
3d890c1
refactor: update k1srt folder to k1
Jul 14, 2022
f1881f1
Merge pull request #104 from kubefirst/update_k1_folder
Jul 14, 2022
f5e963c
feat: add info styled screen
Jul 14, 2022
c9e3ee2
remove more noise
6za Jul 14, 2022
9ab686d
fixing conflict
6za Jul 14, 2022
60b24f8
fix vars
6za Jul 14, 2022
50e22b4
fix lint stuff
6za Jul 14, 2022
2f5a24d
Merge pull request #106 from kubefirst/go-cli-silence-cmds
6za Jul 14, 2022
17920fb
Merge pull request #105 from kubefirst/add_handoff_screen_to_info
Jul 14, 2022
7989ee4
feat: add handoff for create command
Jul 14, 2022
74ad990
feat: add non styled info command
Jul 15, 2022
0483782
chore: clean up
Jul 15, 2022
5b88920
Merge pull request #109 from kubefirst/non-blocker-info
Jul 15, 2022
6397725
chore: clean up, and add tests
Jul 15, 2022
30eff08
chore: enable docker colors, use 256 colors to avoid colors mismatch
Jul 15, 2022
2ccdf9d
Merge pull request #107 from kubefirst/add_handoff_screen_for_create
Jul 15, 2022
f529818
chore: update info screen to be non blocking screen
Jul 15, 2022
25a6a5a
static kubeconfig naming convention (#112)
johndietz Jul 15, 2022
7f70744
Merge pull request #111 from kubefirst/add_non_blocker_info_screen
Jul 15, 2022
5b18d82
k-ray cluster create updates (#108)
jarededwards Jul 15, 2022
8c196a1
fixes for vault unseal (#114)
johndietz Jul 15, 2022
3c00bd1
Vault unseal (#117)
johndietz Jul 15, 2022
0206148
Vault unseal (#118)
johndietz Jul 15, 2022
a7fae7c
Vault unseal (#119)
johndietz Jul 15, 2022
79d1281
Vault unseal (#120)
johndietz Jul 19, 2022
7691507
Merge branch 'main' into go-cli
johndietz Jul 19, 2022
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ kubeconfig_*
*/cypress/screenshots/
*/cypress/videos/
.DS_Store
/git
/git
bin
.vscode/settings.json
log
lint_log.txt
137 changes: 0 additions & 137 deletions Dockerfile

This file was deleted.

73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,76 @@ With that context in mind, once you've removed the manual things you may have ad
```
docker run -it --env-file=kubefirst.env -v $PWD/gitops:/gitops -v $PWD/metaphor:/metaphor -v $PWD/scripts:/scripts -v $PWD/git:/git --entrypoint /scripts/nebulous/destroy.sh nebulous:foo
```

johndietz marked this conversation as resolved.
Show resolved Hide resolved
### New README

# Flare

- [Flare](#flare)
- [Start](#start)
- [Start Environment variables](#start-environment-variables)
- [Start Actions](#start-actions)
- [Start Confirmation](#start-confirmation)
- [Destroy](#destroy)
- [Destroy Actions](#destroy-actions)
- [Notes:](#notes)

## Start

### Start Environment variables

In order to start Kubefirst, the required environment variables are:

| Variable | example |
|------------------|--------------------|
| AWS_PROFILE | default |
| AWS_REGION | us-east-1 |
| HOSTED_ZONE_NAME | mydomain.com |
| ADMIN_EMAIL | myemail@somewhere.com |

### Start Actions

```bash
touch ~/.flare
mkdir -p ~/.kubefirst
cd ~/git/kubefirst/gitlab/flare # change to your dir if different
go build -o bin/flare main.go
./bin/flare nebulous init --admin-email $ADMIN_EMAIL --cloud aws --hosted-zone-name $HOSTED_ZONE_NAME --region $AWS_REGION
./bin/flare nebulous create
```

### Start Confirmation

```bash
aws eks update-kubeconfig --name kubefirst
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
kubectl -n argocd port-forward svc/argocd-server 8080:80
```

## Destroy

To destroy remote then local.

These environment variables are expected:

| Variable | example |
|------------------|-----------------------------------------------------------------------------------------------|
| AWS_PROFILE | default |
| AWS_REGION | us-east-1 |
| AWS_ACCOUNT_ID | 1xxxxxxxxxx4 |
| HOSTED_ZONE_NAME | mydomain.com |
| GITLAB_TOKEN | "xxxxx1-xx1x-x1xx-1" # replace with value from ~/.flare (only needed if you got to gitlab tf) |


### Destroy Actions
```bash
./bin/flare nebulous destroy
rm -rf ~/.kubefirst
rm ~/.flare
```

#### Notes:

added gitlab.yaml to registry
pushing local to soft origin

38 changes: 38 additions & 0 deletions cmd/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>

*/
package cmd

import (
"fmt"
"log"
"os"

"github.com/spf13/cobra"
)

// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
log.Println("removing $HOME/.kubefirst and $HOME/.flare")
// todo ask for user input to verify?
os.RemoveAll(fmt.Sprintf("%s/.kubefirst", home))
os.Remove(fmt.Sprintf("%s/.flare", home))
log.Println("removed $HOME/.kubefirst and $HOME/.flare")
// todo log.Println("proceed to kubefirst create ")
log.Println("proceed to flare nebulous create ")
},
}

func init() {
nebulousCmd.AddCommand(cleanCmd)
}
125 changes: 125 additions & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>

*/
package cmd

import (
"fmt"
"os"
"os/exec"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// destroyCmd represents the destroy command
var destroyCmd = &cobra.Command{
Use: "destroy",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
// todo this needs to be removed when we are no longer in the starter account
os.Setenv("AWS_PROFILE", "starter")

fmt.Println("\n\nTODO -- need to setup and argocd delete against registry and wait?\n\n")
// kubeconfig := os.Getenv("HOME") + "/.kube/config"
// config, err := argocdclientset.BuildConfigFromFlags("", kubeconfig)
// argocdclientset, err := argocdclientset.NewForConfig(config)
// if err != nil {
// return nil, err
// }

// todo should we git clone the gitops repo when destroy is run back to their local host to get the latest values of gitops ?

os.Setenv("AWS_REGION", viper.GetString("aws.region"))
os.Setenv("AWS_ACCOUNT_ID", viper.GetString("aws.accountid"))
os.Setenv("HOSTED_ZONE_NAME", viper.GetString("aws.domainname"))
os.Setenv("GITLAB_TOKEN", viper.GetString("gitlab.token"))

os.Setenv("TF_VAR_aws_account_id", viper.GetString("aws.accountid"))
os.Setenv("TF_VAR_aws_region", viper.GetString("aws.region"))
os.Setenv("TF_VAR_hosted_zone_name", viper.GetString("aws.domainname"))

skipGitlabTerraform, _ := cmd.Flags().GetBool("skip-gitlab-terraform")
//! terraform destroy gitlab
directory := fmt.Sprintf("%s/.kubefirst/gitops/terraform/gitlab", home)
err := os.Chdir(directory)
if err != nil {
fmt.Println("error changing dir: ", directory)
}

os.Setenv("GITLAB_BASE_URL", fmt.Sprintf("https://gitlab.%s", viper.GetString("aws.domainname")))

if !skipGitlabTerraform {
tfInitGitlabCmd := exec.Command(terraformPath, "init")
tfInitGitlabCmd.Stdout = os.Stdout
tfInitGitlabCmd.Stderr = os.Stderr
err = tfInitGitlabCmd.Run()
if err != nil {
fmt.Println("failed to call terraform init gitlab: ", err)
panic("failed to terraform init gitlab")
}

tfDestroyGitlabCmd := exec.Command(terraformPath, "destroy", "-auto-approve")
tfDestroyGitlabCmd.Stdout = os.Stdout
tfDestroyGitlabCmd.Stderr = os.Stderr
err = tfDestroyGitlabCmd.Run()
if err != nil {
fmt.Println("failed to call terraform destroy gitlab: ", err)
panic("failed to terraform destroy gitlab")
}

viper.Set("destroy.terraformdestroy.gitlab", true)
viper.WriteConfig()
}

//! terraform destroy base
directory = fmt.Sprintf("%s/.kubefirst/gitops/terraform/base", home)
err = os.Chdir(directory)
if err != nil {
fmt.Println("error changing dir: ", directory)
}

tfInitBaseCmd := exec.Command(terraformPath, "init")
tfInitBaseCmd.Stdout = os.Stdout
tfInitBaseCmd.Stderr = os.Stderr
err = tfInitBaseCmd.Run()
if err != nil {
fmt.Println("failed to call terraform init base: ", err)
}

tfDestroyBaseCmd := exec.Command(terraformPath, "destroy", "-auto-approve")
tfDestroyBaseCmd.Stdout = os.Stdout
tfDestroyBaseCmd.Stderr = os.Stderr
err = tfDestroyBaseCmd.Run()
if err != nil {
fmt.Println("failed to call terraform destroy base: ", err)
panic("failed to terraform destroy base")
}

viper.Set("destroy.terraformdestroy.base", true)
viper.WriteConfig()
},
}

func init() {
nebulousCmd.AddCommand(destroyCmd)

destroyCmd.Flags().Bool("skip-gitlab-terraform", false, "whether to skip the terraform destroy against gitlab - note: if you already deleted registry it doesnt exist")

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// destroyCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// destroyCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
Loading