From a70fdd86d9b38a0caa885f98a2353aecbf38ceba Mon Sep 17 00:00:00 2001 From: PatrickLaabs Date: Tue, 27 Feb 2024 18:58:06 +0100 Subject: [PATCH] updating readme, prep for render function of argohub template repo --- README.md | 19 +++-- cmd/frigg/bootstrap/bootstrap.go | 4 +- cmd/frigg/bootstrap/capd/capd.go | 4 +- cmd/frigg/bootstrap/capd/cluster/cluster.go | 8 +++ .../bootstrap/capd/reporender/reporender.go | 71 +++++++++++++++++++ cmd/frigg/bootstrap/sidero/sidero.go | 1 + cmd/frigg/root.go | 6 +- docs/providers/capd/README.md | 1 + docs/providers/capd/capd_docs.go | 3 +- go.mod | 2 +- tmpl/helmchartsproxies/helmchartproxies.go | 4 +- 11 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 cmd/frigg/bootstrap/capd/reporender/reporender.go create mode 100644 cmd/frigg/bootstrap/sidero/sidero.go diff --git a/README.md b/README.md index 9c9a256..fb623b8 100644 --- a/README.md +++ b/README.md @@ -46,28 +46,37 @@ Usage: frigg [command] Available Commands: - bootstrap bootstrap + bootstrap bootstrap various clusters on different providers completion Generate the autocompletion script for the specified shell - create Creates one of [cluster] delete Deletes one of [cluster] - functests functests help Help about any command version Prints the frigg CLI version ``` ``` -bootstrap +bootstrap various clusters on different providers Usage: frigg bootstrap [flags] frigg bootstrap [command] Available Commands: - capd capd + capd clusterapi provider docker capv capv capz capz harvester harvester +``` + +``` +Creates local Kubernetes clusters using clusterapi's provider capd (docker) +Usage: + frigg bootstrap capd [flags] + frigg bootstrap capd [command] + +Available Commands: + cluster Creates a local Kubernetes cluster + workloadcluster deploy workload cluster ``` ## Features diff --git a/cmd/frigg/bootstrap/bootstrap.go b/cmd/frigg/bootstrap/bootstrap.go index 33302d4..ac2032d 100644 --- a/cmd/frigg/bootstrap/bootstrap.go +++ b/cmd/frigg/bootstrap/bootstrap.go @@ -16,8 +16,8 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { c := &cobra.Command{ Args: cobra.NoArgs, Use: "bootstrap", - Short: "bootstrap", - Long: "bootstrap", + Short: "bootstrap various clusters on different providers", + Long: "bootstrap various clusters on different providers", RunE: func(cmd *cobra.Command, args []string) error { err := cmd.Help() if err != nil { diff --git a/cmd/frigg/bootstrap/capd/capd.go b/cmd/frigg/bootstrap/capd/capd.go index 0662b50..0630424 100644 --- a/cmd/frigg/bootstrap/capd/capd.go +++ b/cmd/frigg/bootstrap/capd/capd.go @@ -14,8 +14,8 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { c := &cobra.Command{ Args: cobra.NoArgs, Use: "capd", - Short: "capd", - Long: "capd", + Short: "clusterapi provider docker", + Long: "Creates local Kubernetes clusters using clusterapi's provider capd (docker)", RunE: func(cmd *cobra.Command, args []string) error { err := cmd.Help() if err != nil { diff --git a/cmd/frigg/bootstrap/capd/cluster/cluster.go b/cmd/frigg/bootstrap/capd/cluster/cluster.go index bf43962..1e3023d 100644 --- a/cmd/frigg/bootstrap/capd/cluster/cluster.go +++ b/cmd/frigg/bootstrap/capd/cluster/cluster.go @@ -112,6 +112,14 @@ func runE(logger log.Logger, streams cmd.IOStreams, flags *flagpole) error { fmt.Println("Found Github Username Environment variable. Continuing..") } + if os.Getenv("GITHUB_USERNAME_EMAIL") == "" { + fmt.Println("Missing Github Username, please set it. Exiting now.") + os.Exit(1) + } else { + os.Getenv("GITHUB_USERNAME_EMAIL") + fmt.Println("Found Github Username Environment variable. Continuing..") + } + // Create working directory named .frigg inside the users homedirectory. workdir.CreateDir() diff --git a/cmd/frigg/bootstrap/capd/reporender/reporender.go b/cmd/frigg/bootstrap/capd/reporender/reporender.go new file mode 100644 index 0000000..2954d31 --- /dev/null +++ b/cmd/frigg/bootstrap/capd/reporender/reporender.go @@ -0,0 +1,71 @@ +package reporender + +import ( + "fmt" + "os" +) + +// Renders the gitops Repo https://github.com/PatrickLaabs/argo-hub-template +// +// This Repo contains some placeholder strings. +// To be more precise: +// - GITHUB_USER +// - GITHUB_USER_EMAIL + +// FullStage combines everything, that is needed, to fully prepare the gitops repo for the end-user +func FullStage() { + fmt.Println("Rendering the gitops template repo") +} + +// retrieveEnvs retrieves and reads the os.Env variables needed for further preperation +// GITHUB_USER +// GITHUB_USER_EMAIL +// These Envs are mandatory to run this CLI and will be checked on cluster-creation runtime. +// At this point, they will be available +func retrieveEnvs() (string, string, error) { + // Get GITHUB_USERNAME environment var + var username string + var usermail string + + if os.Getenv("GITHUB_USERNAME") == "" { + fmt.Println("Missing Github Username, please set it. Exiting now.") + os.Exit(1) + } else { + username = os.Getenv("GITHUB_USERNAME") + } + + if os.Getenv("GITHUB_USER_EMAIL") == "" { + fmt.Println("Missing Github User Email, please set it. Exiting now.") + os.Exit(1) + } else { + usermail = os.Getenv("GITHUB_USER_EMAIL") + } + + return username, usermail, nil +} + +// gitClone clones the gitops template repo from github, to the local working directory +func gitClone() { + +} + +// gitConfigs configures the local git repo (user, mail, etc) +func gitConfigs() {} + +// replaceStrings replaces the Placeholder strings inside the gitops repo +func replaceStrings() { + username, usermail, err := retrieveEnvs() + if err != nil { + fmt.Println("Error retrieving token:", err) + os.Exit(1) + } + + fmt.Println(username) + fmt.Println(usermail) + + // we need to look over many files, and have to replace two different kind of Placeholder strings + +} + +// gitPush pushes the changes to the users github repository +func gitPush() {} diff --git a/cmd/frigg/bootstrap/sidero/sidero.go b/cmd/frigg/bootstrap/sidero/sidero.go new file mode 100644 index 0000000..68d4d7c --- /dev/null +++ b/cmd/frigg/bootstrap/sidero/sidero.go @@ -0,0 +1 @@ +package sidero diff --git a/cmd/frigg/root.go b/cmd/frigg/root.go index d99a384..0de864b 100644 --- a/cmd/frigg/root.go +++ b/cmd/frigg/root.go @@ -19,13 +19,11 @@ package frigg import ( "github.com/PatrickLaabs/frigg/cmd/frigg/bootstrap" - "github.com/PatrickLaabs/frigg/cmd/frigg/functests" "io" "github.com/spf13/cobra" "github.com/PatrickLaabs/frigg/cmd" - "github.com/PatrickLaabs/frigg/cmd/frigg/create" "github.com/PatrickLaabs/frigg/cmd/frigg/delete" "github.com/PatrickLaabs/frigg/cmd/frigg/version" "github.com/PatrickLaabs/frigg/pkg/log" @@ -77,14 +75,14 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { // add all top level subcommands //c.AddCommand(build.NewCommand(logger)) //c.AddCommand(completion.NewCommand(streams)) - c.AddCommand(create.NewCommand(logger, streams)) + //c.AddCommand(create.NewCommand(logger, streams)) c.AddCommand(delete.NewCommand(logger)) //c.AddCommand(export.NewCommand(logger, streams)) //c.AddCommand(get.NewCommand(logger, streams)) c.AddCommand(version.NewCommand(logger, streams)) //c.AddCommand(load.NewCommand(logger)) c.AddCommand(bootstrap.NewCommand(logger, streams)) - c.AddCommand(functests.NewCommand(logger, streams)) + //c.AddCommand(functests.NewCommand(logger, streams)) return c } diff --git a/docs/providers/capd/README.md b/docs/providers/capd/README.md index adecfde..c297879 100644 --- a/docs/providers/capd/README.md +++ b/docs/providers/capd/README.md @@ -5,5 +5,6 @@ You will need to pass two Environment variables: - GITHUB_TOKEN - GITHUB_USERNAME +- GITHUB_USERNAME_EMAIL Updated on: 27 Feb 2024 \ No newline at end of file diff --git a/docs/providers/capd/capd_docs.go b/docs/providers/capd/capd_docs.go index 780cd00..c4eaa61 100644 --- a/docs/providers/capd/capd_docs.go +++ b/docs/providers/capd/capd_docs.go @@ -14,7 +14,8 @@ func MakeReadme(filename string) { body := "## Get started \n\n" + "You will need to pass two Environment variables: \n" + "- GITHUB_TOKEN\n" + - "- GITHUB_USERNAME" + "- GITHUB_USERNAME\n" + + "- GITHUB_USERNAME_EMAIL" footer := "Updated on: " + date data := fmt.Sprintf("%s\n\n%s\n\n%s", header, body, footer) diff --git a/go.mod b/go.mod index 0f6238b..f17c8be 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/PatrickLaabs/frigg -go 1.22 +go 1.22.0 require ( github.com/BurntSushi/toml v1.3.2 diff --git a/tmpl/helmchartsproxies/helmchartproxies.go b/tmpl/helmchartsproxies/helmchartproxies.go index a9dccf5..7805467 100644 --- a/tmpl/helmchartsproxies/helmchartproxies.go +++ b/tmpl/helmchartsproxies/helmchartproxies.go @@ -109,7 +109,7 @@ func MgmtArgoCD() { username, err := retrieveUsername() if err != nil { - fmt.Println("Error retrieving token:", err) + fmt.Println("Error retrieving github username:", err) os.Exit(1) } @@ -150,7 +150,7 @@ func retrieveUsername() (string, error) { var username string if os.Getenv("GITHUB_USERNAME") == "" { - fmt.Println("Missing Github Token, please set it. Exiting now.") + fmt.Println("Missing Github Username, please set it. Exiting now.") os.Exit(1) } else { username = os.Getenv("GITHUB_USERNAME")