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

IMPLEMENT CREATE APPS + ADD TESTING TO POC CODE #1

Open
patrick-hermann-sva opened this issue Jan 3, 2024 · 0 comments
Open

IMPLEMENT CREATE APPS + ADD TESTING TO POC CODE #1

patrick-hermann-sva opened this issue Jan 3, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@patrick-hermann-sva
Copy link
Contributor

go

package main

import (
	"encoding/json"
	"os"
)

type Substitute struct {
	Variables        map[string]string
	Secrets          map[string]string
	SecretsResources []string
}

type VersionTarget struct {
	Name, Kind, Namespace, Path, Version string
}

type SourceRef struct {
	Name, Kind string
}

type Kustomization struct {
	Name, Namespace, Version, Path string
	SourceRef                      SourceRef
	VersionTarget                  VersionTarget
	Substitute                     Substitute
}

type DefaultKustomizations struct {
	Defaults []Kustomization
}

type Cluster struct {
	Name, Cloud, Operator string
	InfraKustomization    []Kustomization
	Ips                   []string
}

func main() {

	// GENERAL KUSTOMIZATION STRUCT DEFAULTS

	defaultKustomizations := DefaultKustomizations{
		[]Kustomization{Kustomization{
			Name:          "ingress-nginx",
			Namespace:     "flux-system",
			Version:       "1.2.3",
			Path:          "./infra/ingress-nginx",
			SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
			VersionTarget: VersionTarget{Name: "ingress-nginx", Kind: "HelmRelease", Namespace: "ingress-nginx", Path: "/spec/chart/spec/version", Version: "1.2.3"},
		}, Kustomization{
			Name:          "longhorn",
			Namespace:     "flux-system",
			Version:       "4.8.3",
			Path:          "./infra/longhorn",
			SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
			VersionTarget: VersionTarget{Name: "longhorn", Kind: "HelmRelease", Namespace: "ingress-nginx", Path: "/spec/chart/spec/version", Version: "4.8.3"},
		}, Kustomization{
			Name:          "metallb",
			Namespace:     "flux-system",
			Version:       "4.8.3",
			Path:          "./infra/metallb",
			SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
			VersionTarget: VersionTarget{Name: "metallb", Kind: "HelmRelease", Namespace: "ingress-nginx", Path: "/spec/chart/spec/version", Version: "4.8.3"},
			Substitute:    Substitute{Variables: map[string]string{"IP_RANGE": ""}},
		}, Kustomization{
			Name:          "cert-manager",
			Namespace:     "flux-system",
			Version:       "5.1.3",
			Path:          "./infra/cert-manager",
			SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
			VersionTarget: VersionTarget{Name: "cert-manager", Kind: "HelmRelease", Namespace: "ingress-nginx", Path: "/spec/chart/spec/version", Version: "5.1.3"},
			Substitute:    Substitute{Variables: map[string]string{"IP_RANGE": "invokeMethod+GetVIP", "INGRESS_DOMAIN": "clusterVars+ingressDomain", "HOSTNAME": "defaultVar+cert-manager"}, Secrets: map[string]string{"APPROLE": ""}, SecretsResources: []string{"flux-vault-secrets"}},
		}}}

	file, _ := json.MarshalIndent(defaultKustomizations, "", " ")

	_ = os.WriteFile("defaults.json", file, 0644)

	clusters := Cluster{
		Name:     "maverick",
		Cloud:    "pve",
		Operator: "flux2",
		InfraKustomization: []Kustomization{
			Kustomization{
				Name:          "metallb",
				Namespace:     "flux-system",
				Version:       "123",
				Path:          "./infra/metallb",
				SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
				VersionTarget: VersionTarget{Name: "metallb", Kind: "HelmRelease", Namespace: "metallb-system", Path: "/spec/chart/spec/version", Version: "123"},
				Substitute:    Substitute{Variables: map[string]string{"IP_RANGE": "10.31.103.13-10.31.103.14"}},
			},
			Kustomization{
				Name:          "cert-manager",
				Namespace:     "flux-system",
				Version:       "123",
				Path:          "./infra/metallb",
				SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
				VersionTarget: VersionTarget{Name: "cert-manager", Kind: "HelmRelease", Namespace: "cert-manager", Path: "/spec/chart/spec/version", Version: "123"},
				Substitute:    Substitute{Variables: map[string]string{"INGRESS_DOMAIN": "clusterVars+ingressDomain"}},
			},
			Kustomization{
				Name:          "ingress-nginx",
				Namespace:     "ingress-nginx",
				Version:       "123",
				Path:          "./infra/ingress-nginx",
				SourceRef:     SourceRef{Name: "flux-system", Kind: "GitRepository"},
				VersionTarget: VersionTarget{Name: "ingress-nginx", Kind: "HelmRelease", Namespace: "ingress-nginx", Path: "/spec/chart/spec/version", Version: "123"},
			},
		},
		Ips: []string{"192.124.24.12", ""},
	}

	clusterFile, _ := json.MarshalIndent(clusters, "", " ")

	_ = os.WriteFile("clusters.json", clusterFile, 0644)
}
@patrick-hermann-sva patrick-hermann-sva added the enhancement New feature or request label Jan 3, 2024
@patrick-hermann-sva patrick-hermann-sva self-assigned this Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant