Skip to content

Commit

Permalink
Merge branch 'main' into feat-custom-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
jokestax authored Aug 28, 2024
2 parents d301204 + 14d2118 commit 6fa2d22
Show file tree
Hide file tree
Showing 40 changed files with 134 additions and 139 deletions.
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "devcontainer",
"image": "ghcr.io/kubefirst/devcontainers/full",
"features": {},
"customizations": {
"vscode": {
"extensions": [],
"settings": {}
}
}
}
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.go]
indent_style = tab
indent_size = 4

[Makefile]
indent_style = tab
indent_size = 4
34 changes: 31 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,43 @@ Before making a code change, first discuss your idea via an [issue](https://gith

## Getting Started with the Code

### Dev containers

A [.devcontainer](https://containers.dev/) configuration is provided to allow for a full-featured development environment.

### Local development

#### The CLI

Kubefirst is created using the [Go Programming Language](https://go.dev). To set up your computer, follow [these steps](https://go.dev/doc/install).

Once Go is installed, you can run Kubefirst from any branch using `go run .`. Go will automatically install the needed modules listed in the [go.mod](go.mod) file. As an example, if you want to create a [local cluster](https://docs.kubefirst.io/kubefirst/local/install.html), the command would be `go run . k3d create`. Note that even if you run kubefirst from `main`, the [gitops-template](https://github.com/kubefirst/gitops-template) version used will be the [latest release](https://github.com/kubefirst/gitops-template/releases). If you also want to use the latest from `main` for the template also, you need to run to use the `--gitops-template-url`, and the `--gitops-template-branch` as follow:
Once Go is installed, you can run Kubefirst from any branch using `go run .`. Go will automatically install the needed modules listed in the [go.mod](go.mod) file. Since Go is a compiled programming language, every time you use the `run` command, Go will compile the code before running it. If you want to save time, you can compile your code using `go build`, which will generate a file named `kubefirst`. You will then be able to run your compiled version with the `./kubefirst` command.

If you want to create a [Civo cluster](https://docs.kubefirst.io/kubefirst/local/install.html), the command would be `go run . civo create`.

#### GitOps Template

Note that even if you run kubefirst from `main`, the [gitops-template](https://github.com/kubefirst/gitops-template) version used will be the [latest release](https://github.com/kubefirst/gitops-template/releases). If you also want to use the latest from `main` for the template, you need to run to use the `--gitops-template-url`, and the `--gitops-template-branch` as follow:

```shell
go run . k3d create --gitops-template-url https://github.com/kubefirst/gitops-template --gitops-template-branch main
go run . civo create --gitops-template-url https://github.com/kubefirst/gitops-template --gitops-template-branch main
```

#### Kubefirst API

If you need to use a specific branch or latest from `main` that wasn't released yet for the [kubefirst-api](https://github.com/kubefirst/kubefirst-api) repository, you will need to first run it locally as described in [its documentation](https://github.com/kubefirst/kubefirst-api#running-locally). You will also need to run the code from [console](https://github.com/kubefirst/console) repository, whether you need to use a specific version of the code or not, as we don't expose the API directly. To do so, follow the [instructions in its README](https://github.com/kubefirst/console#setup-instructions). Before running the CLI as mentionned "The CLI" section, you need to export a local variable:

```shell
export K1_CONSOLE_REMOTE_URL="http://localhost:3000"
```

The previous steps will work for all clouds except k3d which use our runtime for now: we have plan to remove this dependencies completely and use the API also to make the code easier to maintain, and less prone to issues. For that step, instead of running the API, and console locally, you simply need to clone the [kubefirst-api](https://github.com/kubefirst/kubefirst-api) repository locally, and add the following line in the `go.mod` file:

```go
github.com/kubefirst/kubefirst-api vX.X.XX => /path-to/kubefirst-api/
```

Since Go is a compiled programming language, every time you use the `run` command, Go will compile the code before running it. If you want to save time, you can compile your code using `go build`, which will generate a file named `kubefirst`. You will then be able to run your compiled version with the `./kubefirst` command.
Replace `vX.X.XX` with the latest version used in the mode file for the API, and the `/path-to/kubefirst-api/` with the path to the folder of your locally Kubefirst API folder.

## Getting Started with the Documentation

Expand Down
6 changes: 4 additions & 2 deletions cmd/akamai/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (
nodeTypeFlag string
nodeCountFlag string
installCatalogApps string
installKubefirstProFlag bool

// RootCredentials
copyArgoCDPasswordToClipboardFlag bool
Expand All @@ -59,7 +60,7 @@ func NewCommand() *cobra.Command {
Long: "kubefirst akamai",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("To learn more about akamai in kubefirst, run:")
fmt.Println(" kubefirst akamai --help")
fmt.Println(" kubefirst beta akamai --help")

if progress.Progress != nil {
progress.Progress.Quit()
Expand Down Expand Up @@ -102,8 +103,9 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
createCmd.Flags().StringVar(&gitopsRepoName, "gitops-repo-name", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphor-repo-name", "metaphor", "the custom metaphor name")
createCmd.Flags().StringVar(&adminTeamName, "admin-team-name", "admins", "admin team name for this repo")
Expand Down
1 change: 0 additions & 1 deletion cmd/akamai/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func createAkamai(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
8 changes: 1 addition & 7 deletions cmd/aws/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ var (
installCatalogApps string
installKubefirstProFlag bool

// RootCredentials
copyArgoCDPasswordToClipboardFlag bool
copyKbotPasswordToClipboardFlag bool
copyVaultPasswordToClipboardFlag bool

// Supported argument arrays
supportedDNSProviders = []string{"aws", "cloudflare"}
supportedGitProviders = []string{"github", "gitlab"}
Expand Down Expand Up @@ -104,7 +99,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&ecrFlag, "ecr", false, "whether or not to use ecr vs the git provider")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand All @@ -126,7 +121,6 @@ func Destroy() *cobra.Command {
}

return destroyCmd

}

func Quota() *cobra.Command {
Expand Down
2 changes: 0 additions & 2 deletions cmd/aws/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func createAws(cmd *cobra.Command, args []string) error {
Config: awsinternal.NewAwsV2(cloudRegionFlag),
}
creds, err := awsClient.Config.Credentials.Retrieve(aws.BackgroundContext())

if err != nil {
progress.Error(err.Error())
return nil
Expand All @@ -80,7 +79,6 @@ func createAws(cmd *cobra.Command, args []string) error {
}

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
3 changes: 1 addition & 2 deletions cmd/aws/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func printAwsQuotaWarning(messageHeader string, output map[string][]awsinternal.

// Write to logs, but also output to stdout
return createAwsQuotaWarning.String()

}

// evalAwsQuota provides an interface to the command-line
Expand All @@ -53,7 +52,7 @@ func evalAwsQuota(cmd *cobra.Command, args []string) error {
return err
}

var messageHeader = fmt.Sprintf(
messageHeader := fmt.Sprintf(
"AWS Quota Health\nRegion: %s\n\nIf you encounter issues deploying your kubefirst cluster, check these quotas and determine if you need to request a limit increase.",
cloudRegionFlag,
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/civo/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")

Expand Down
1 change: 0 additions & 1 deletion cmd/civo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func createCivo(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
3 changes: 1 addition & 2 deletions cmd/civo/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func returnCivoQuotaEvaluation(cloudRegion string) (string, int, int, error) {
}

// Parse the entire message
var messageHeader = fmt.Sprintf("Civo Quota Health\nRegion: %s\n\nNote that if any of these are approaching their limits, you may want to increase them.", cloudRegion)
messageHeader := fmt.Sprintf("Civo Quota Health\nRegion: %s\n\nNote that if any of these are approaching their limits, you may want to increase them.", cloudRegion)
sort.Strings(output)
result := printCivoQuotaWarning(messageHeader, output)

Expand Down Expand Up @@ -164,7 +164,6 @@ func printCivoQuotaWarning(messageHeader string, output []string) string {

// Write to logs, but also output to stdout
return createCivoQuotaWarning.String()

}

// evalCivoQuota provides an interface to the command-line
Expand Down
2 changes: 1 addition & 1 deletion cmd/digitalocean/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
createCmd.Flags().StringVar(&gitopsRepoName, "gitops-repo-name", "gitops", "the custom gitops name")
Expand Down
1 change: 0 additions & 1 deletion cmd/digitalocean/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func createDigitalocean(cmd *cobra.Command, args []string) error {
utilities.CreateK1ClusterDirectory(clusterNameFlag)

gitAuth, err := gitShim.ValidateGitCredentials(cliFlags.GitProvider, cliFlags.GithubOrg, cliFlags.GitlabGroup)

if err != nil {
progress.Error(err.Error())
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/google/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().BoolVar(&forceDestroyFlag, "force-destroy", false, "allows force destruction on objects (helpful for test environments, defaults to false)")
createCmd.Flags().BoolVar(&installKubefirstProFlag, "install-kubefirst-pro", true, "whether or not to install kubefirst pro")
Expand Down
1 change: 0 additions & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var infoCmd = &cobra.Command{
Short: "provides general Kubefirst setup data",
Long: `Provides machine data, files and folders paths`,
Run: func(cmd *cobra.Command, args []string) {

config := configs.ReadConfig()

content := `
Expand Down
2 changes: 1 addition & 1 deletion cmd/k3d/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Create() *cobra.Command {
createCmd.Flags().StringVar(&gitlabGroupFlag, "gitlab-group", "", "the GitLab group for the new gitops and metaphor projects - required if using gitlab")
createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository")
createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma seperated values of catalog apps to install after provision")
createCmd.Flags().StringVar(&installCatalogApps, "install-catalog-apps", "", "comma separated values of catalog apps to install after provision")
createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry")
createCmd.Flags().StringVar(&gitopsRepoName, "gitops-repo-name", "gitops", "the custom gitops name")
createCmd.Flags().StringVar(&metaphorRepoName, "metaphor-repo-name", "metaphor", "the custom metaphor name")
Expand Down
Loading

0 comments on commit 6fa2d22

Please sign in to comment.