Skip to content

Commit

Permalink
Merge pull request #165 from kubefirst/feat-pkg-fix-import_export
Browse files Browse the repository at this point in the history
feat: establish pkg folder and update types
  • Loading branch information
claywd authored Sep 26, 2023
2 parents b94709f + 4a1304f commit 373cb53
Show file tree
Hide file tree
Showing 76 changed files with 3,612 additions and 198 deletions.
14 changes: 7 additions & 7 deletions extensions/aws/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
"github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/k8s"
"github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/kubefirst/runtime/pkg/vault"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
Expand All @@ -29,7 +29,7 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
return existingKubernetesSecret["root-token"]
}

func GetAwsTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetAwsTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
// needed for s3 api connectivity to object storage
envs["AWS_ACCESS_KEY_ID"] = cl.StateStoreCredentials.AccessKeyID
envs["AWS_SECRET_ACCESS_KEY"] = cl.StateStoreCredentials.SecretAccessKey
Expand All @@ -44,7 +44,7 @@ func GetAwsTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]s
return envs
}

func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGithubTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GITHUB_TOKEN"] = cl.GitAuth.Token
envs["GITHUB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -60,7 +60,7 @@ func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[strin
return envs
}

func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster) map[string]string {
func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *pkgtypes.Cluster) map[string]string {
envs["GITLAB_TOKEN"] = cl.GitAuth.Token
envs["GITLAB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -78,7 +78,7 @@ func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster)
return envs
}

func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs["VAULT_TOKEN"] = readVaultTokenFromSecret(clientset)
envs["VAULT_ADDR"] = providerConfigs.VaultPortForwardURL
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
Expand All @@ -87,7 +87,7 @@ func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, e
return envs
}

func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
envs[fmt.Sprintf("%s_OWNER", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Owner
envs["TF_VAR_email_address"] = cl.AlertsEmail
Expand Down
6 changes: 3 additions & 3 deletions extensions/aws/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"fmt"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
providerConfig "github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/aws"
providerConfig "github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/rs/zerolog/log"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -22,7 +22,7 @@ import (

func BootstrapAWSMgmtCluster(
clientset *kubernetes.Clientset,
cl *types.Cluster,
cl *pkgtypes.Cluster,
destinationGitopsRepoURL string,
awsClient *aws.AWSConfiguration,
) error {
Expand Down
14 changes: 7 additions & 7 deletions extensions/civo/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
"github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/k8s"
"github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/kubefirst/runtime/pkg/vault"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
Expand All @@ -29,7 +29,7 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
return existingKubernetesSecret["root-token"]
}

func GetCivoTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetCivoTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["CIVO_TOKEN"] = cl.CivoAuth.Token
// needed for s3 api connectivity to object storage
envs["AWS_ACCESS_KEY_ID"] = cl.StateStoreCredentials.AccessKeyID
Expand All @@ -41,7 +41,7 @@ func GetCivoTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]
return envs
}

func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGithubTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GITHUB_TOKEN"] = cl.GitAuth.Token
envs["GITHUB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -54,7 +54,7 @@ func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[strin
return envs
}

func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster) map[string]string {
func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *pkgtypes.Cluster) map[string]string {
envs["GITLAB_TOKEN"] = cl.GitAuth.Token
envs["GITLAB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -70,7 +70,7 @@ func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster)
return envs
}

func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs["VAULT_TOKEN"] = readVaultTokenFromSecret(clientset)
envs["VAULT_ADDR"] = providerConfigs.VaultPortForwardURL
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
Expand All @@ -79,7 +79,7 @@ func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, e
return envs
}

func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
envs[fmt.Sprintf("%s_OWNER", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Owner
envs["TF_VAR_email_address"] = cl.AlertsEmail
Expand Down
7 changes: 3 additions & 4 deletions extensions/civo/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ import (
"context"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
providerConfig "github.com/kubefirst/runtime/pkg/providerConfigs"
providerConfig "github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/rs/zerolog/log"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)

func BootstrapCivoMgmtCluster(clientset *kubernetes.Clientset, cl *types.Cluster, destinationGitopsRepoURL string) error {
func BootstrapCivoMgmtCluster(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, destinationGitopsRepoURL string) error {

err := providerConfig.BootstrapMgmtCluster(
clientset,
Expand Down
14 changes: 7 additions & 7 deletions extensions/digitalocean/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
"github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/k8s"
"github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/kubefirst/runtime/pkg/vault"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
Expand All @@ -29,7 +29,7 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
return existingKubernetesSecret["root-token"]
}

func GetDigitaloceanTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetDigitaloceanTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["DO_TOKEN"] = cl.DigitaloceanAuth.Token
envs["TF_VAR_do_token"] = cl.DigitaloceanAuth.Token
envs["AWS_ACCESS_KEY_ID"] = cl.StateStoreCredentials.AccessKeyID
Expand All @@ -41,7 +41,7 @@ func GetDigitaloceanTerraformEnvs(envs map[string]string, cl *types.Cluster) map
return envs
}

func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGithubTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GITHUB_TOKEN"] = cl.GitAuth.Token
envs["GITHUB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -56,7 +56,7 @@ func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[strin
return envs
}

func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster) map[string]string {
func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *pkgtypes.Cluster) map[string]string {
envs["GITLAB_TOKEN"] = cl.GitAuth.Token
envs["GITLAB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -74,7 +74,7 @@ func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster)
return envs
}

func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs["VAULT_TOKEN"] = readVaultTokenFromSecret(clientset)
envs["VAULT_ADDR"] = providerConfigs.VaultPortForwardURL
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
Expand All @@ -89,7 +89,7 @@ func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, e
return envs
}

func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
envs[fmt.Sprintf("%s_OWNER", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Owner
envs["TF_VAR_email_address"] = cl.AlertsEmail
Expand Down
6 changes: 3 additions & 3 deletions extensions/digitalocean/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (
"context"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
providerConfig "github.com/kubefirst/runtime/pkg/providerConfigs"
providerConfig "github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/rs/zerolog/log"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)

func BootstrapDigitaloceanMgmtCluster(clientset *kubernetes.Clientset, cl *types.Cluster, destinationGitopsRepoURL string) error {
func BootstrapDigitaloceanMgmtCluster(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, destinationGitopsRepoURL string) error {


err := providerConfig.BootstrapMgmtCluster(
Expand Down
15 changes: 7 additions & 8 deletions extensions/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
"github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/k8s"
"github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/kubefirst/runtime/pkg/vault"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
Expand All @@ -25,11 +25,10 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
log.Printf("Error reading existing Secret data: %s", err)
return ""
}

return existingKubernetesSecret["root-token"]
}

func GetCivoTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetCivoTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["CIVO_TOKEN"] = cl.CivoAuth.Token
// needed for s3 api connectivity to object storage
envs["AWS_ACCESS_KEY_ID"] = cl.StateStoreCredentials.AccessKeyID
Expand All @@ -41,7 +40,7 @@ func GetCivoTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]
return envs
}

func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGithubTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GITHUB_TOKEN"] = cl.GitAuth.Token
envs["GITHUB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -54,7 +53,7 @@ func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[strin
return envs
}

func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster) map[string]string {
func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *pkgtypes.Cluster) map[string]string {
envs["GITLAB_TOKEN"] = cl.GitAuth.Token
envs["GITLAB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -70,7 +69,7 @@ func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster)

return envs
}
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs["VAULT_TOKEN"] = readVaultTokenFromSecret(clientset)
envs["VAULT_ADDR"] = providerConfigs.VaultPortForwardURL
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
Expand All @@ -79,7 +78,7 @@ func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, e
return envs
}

func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
envs[fmt.Sprintf("%s_OWNER", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Owner
envs["TF_VAR_email_address"] = cl.AlertsEmail
Expand Down
14 changes: 7 additions & 7 deletions extensions/google/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
"github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/kubefirst/runtime/pkg/k8s"
"github.com/kubefirst/runtime/pkg/providerConfigs"
"github.com/kubefirst/runtime/pkg/vault"
log "github.com/sirupsen/logrus"
"k8s.io/client-go/kubernetes"
Expand All @@ -29,15 +29,15 @@ func readVaultTokenFromSecret(clientset *kubernetes.Clientset) string {
return existingKubernetesSecret["root-token"]
}

func GetGoogleTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGoogleTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GOOGLE_CLOUD_KEYFILE_JSON"] = cl.GoogleAuth.KeyFile
envs["TF_VAR_project"] = cl.GoogleAuth.ProjectId
//envs["TF_LOG"] = "debug"

return envs
}

func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[string]string {
func GetGithubTerraformEnvs(envs map[string]string, cl *pkgtypes.Cluster) map[string]string {
envs["GITHUB_TOKEN"] = cl.GitAuth.Token
envs["GITHUB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -46,7 +46,7 @@ func GetGithubTerraformEnvs(envs map[string]string, cl *types.Cluster) map[strin
return envs
}

func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster) map[string]string {
func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *pkgtypes.Cluster) map[string]string {
envs["GITLAB_TOKEN"] = cl.GitAuth.Token
envs["GITLAB_OWNER"] = cl.GitAuth.Owner
envs["TF_VAR_atlantis_repo_webhook_secret"] = cl.AtlantisWebhookSecret
Expand All @@ -58,7 +58,7 @@ func GetGitlabTerraformEnvs(envs map[string]string, gid int, cl *types.Cluster)
return envs
}

func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs["VAULT_TOKEN"] = readVaultTokenFromSecret(clientset)
envs["VAULT_ADDR"] = providerConfigs.VaultPortForwardURL
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
Expand All @@ -67,7 +67,7 @@ func GetUsersTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, e
return envs
}

func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *types.Cluster, envs map[string]string) map[string]string {
func GetVaultTerraformEnvs(clientset *kubernetes.Clientset, cl *pkgtypes.Cluster, envs map[string]string) map[string]string {
envs[fmt.Sprintf("%s_TOKEN", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Token
envs[fmt.Sprintf("%s_OWNER", strings.ToUpper(cl.GitProvider))] = cl.GitAuth.Owner
envs["TF_VAR_email_address"] = cl.AlertsEmail
Expand Down
6 changes: 3 additions & 3 deletions extensions/google/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"context"
"strings"

"github.com/kubefirst/kubefirst-api/internal/types"
providerConfig "github.com/kubefirst/runtime/pkg/providerConfigs"
providerConfig "github.com/kubefirst/kubefirst-api/pkg/providerConfigs"
pkgtypes "github.com/kubefirst/kubefirst-api/pkg/types"
"github.com/rs/zerolog/log"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -20,7 +20,7 @@ import (

func BootstrapGoogleMgmtCluster(
clientset *kubernetes.Clientset,
cl *types.Cluster,
cl *pkgtypes.Cluster,
destinationGitopsRepoURL string,
) error {

Expand Down
Loading

0 comments on commit 373cb53

Please sign in to comment.