chore: move around structs to be closer to the functions using them
This commit is contained in:
@@ -31,86 +31,6 @@ type Chart struct {
|
|||||||
Version string `yaml:"version"`
|
Version string `yaml:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateIngressRoutesInput struct {
|
|
||||||
AppName string
|
|
||||||
ChartDir string
|
|
||||||
Deployment appsv1.Deployment
|
|
||||||
Namespace string
|
|
||||||
PortMaps []PortMap
|
|
||||||
Service v1.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
type Deployment struct {
|
|
||||||
AppName string
|
|
||||||
Command []string
|
|
||||||
Image string
|
|
||||||
ImagePullSecrets string
|
|
||||||
ImageSourceType string
|
|
||||||
Healthchecks []appjson.Healthcheck
|
|
||||||
Namespace string
|
|
||||||
PrimaryPort int32
|
|
||||||
PortMaps []PortMap
|
|
||||||
ProcessType string
|
|
||||||
Replicas int32
|
|
||||||
WorkingDir string
|
|
||||||
}
|
|
||||||
|
|
||||||
type IngressRouteEntrypoint string
|
|
||||||
|
|
||||||
const (
|
|
||||||
IngressRouteEntrypoint_HTTP IngressRouteEntrypoint = "web"
|
|
||||||
IngressRouteEntrypoint_HTTPS IngressRouteEntrypoint = "websecure"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IngressRoute struct {
|
|
||||||
AppName string
|
|
||||||
Entrypoints []IngressRouteEntrypoint
|
|
||||||
Hostnames []string
|
|
||||||
Namespace string
|
|
||||||
PortMap PortMap
|
|
||||||
ProcessType string
|
|
||||||
ServiceName string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Job struct {
|
|
||||||
AppName string
|
|
||||||
Command []string
|
|
||||||
DeploymentID int64
|
|
||||||
Entrypoint string
|
|
||||||
Env map[string]string
|
|
||||||
ID string
|
|
||||||
Image string
|
|
||||||
ImagePullSecrets string
|
|
||||||
ImageSourceType string
|
|
||||||
Interactive bool
|
|
||||||
Labels map[string]string
|
|
||||||
Namespace string
|
|
||||||
ProcessType string
|
|
||||||
Schedule string
|
|
||||||
Suffix string
|
|
||||||
RemoveContainer bool
|
|
||||||
WorkingDir string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Secret struct {
|
|
||||||
AppName string
|
|
||||||
Env map[string]string
|
|
||||||
Namespace string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Service struct {
|
|
||||||
AppName string
|
|
||||||
Namespace string
|
|
||||||
PortMaps []PortMap
|
|
||||||
}
|
|
||||||
|
|
||||||
type WriteResourceInput struct {
|
|
||||||
AppendContents string
|
|
||||||
Object runtime.Object
|
|
||||||
Path string
|
|
||||||
Replacements *orderedmap.OrderedMap[string, string]
|
|
||||||
}
|
|
||||||
|
|
||||||
type Values struct {
|
type Values struct {
|
||||||
DeploymentID string `yaml:"deploment_id"`
|
DeploymentID string `yaml:"deploment_id"`
|
||||||
Secrets map[string]string `yaml:"secrets"`
|
Secrets map[string]string `yaml:"secrets"`
|
||||||
@@ -121,9 +41,13 @@ type ValuesProcess struct {
|
|||||||
Replicas int32 `yaml:"replicas"`
|
Replicas int32 `yaml:"replicas"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WriteYamlInput struct {
|
type CreateIngressRoutesInput struct {
|
||||||
Object interface{}
|
AppName string
|
||||||
Path string
|
ChartDir string
|
||||||
|
Deployment appsv1.Deployment
|
||||||
|
Namespace string
|
||||||
|
PortMaps []PortMap
|
||||||
|
Service v1.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func createIngressRoutesFiles(input CreateIngressRoutesInput) error {
|
func createIngressRoutesFiles(input CreateIngressRoutesInput) error {
|
||||||
@@ -169,6 +93,26 @@ func createIngressRoutesFiles(input CreateIngressRoutesInput) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Job struct {
|
||||||
|
AppName string
|
||||||
|
Command []string
|
||||||
|
DeploymentID int64
|
||||||
|
Entrypoint string
|
||||||
|
Env map[string]string
|
||||||
|
ID string
|
||||||
|
Image string
|
||||||
|
ImagePullSecrets string
|
||||||
|
ImageSourceType string
|
||||||
|
Interactive bool
|
||||||
|
Labels map[string]string
|
||||||
|
Namespace string
|
||||||
|
ProcessType string
|
||||||
|
Schedule string
|
||||||
|
Suffix string
|
||||||
|
RemoveContainer bool
|
||||||
|
WorkingDir string
|
||||||
|
}
|
||||||
|
|
||||||
func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) {
|
func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) {
|
||||||
if input.Schedule == "" {
|
if input.Schedule == "" {
|
||||||
return batchv1.CronJob{}, fmt.Errorf("Schedule cannot be empty")
|
return batchv1.CronJob{}, fmt.Errorf("Schedule cannot be empty")
|
||||||
@@ -343,6 +287,21 @@ func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) {
|
|||||||
return job, nil
|
return job, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Deployment struct {
|
||||||
|
AppName string
|
||||||
|
Command []string
|
||||||
|
Image string
|
||||||
|
ImagePullSecrets string
|
||||||
|
ImageSourceType string
|
||||||
|
Healthchecks []appjson.Healthcheck
|
||||||
|
Namespace string
|
||||||
|
PrimaryPort int32
|
||||||
|
PortMaps []PortMap
|
||||||
|
ProcessType string
|
||||||
|
Replicas int32
|
||||||
|
WorkingDir string
|
||||||
|
}
|
||||||
|
|
||||||
func templateKubernetesDeployment(input Deployment) (appsv1.Deployment, error) {
|
func templateKubernetesDeployment(input Deployment) (appsv1.Deployment, error) {
|
||||||
labels := map[string]string{
|
labels := map[string]string{
|
||||||
"app.kubernetes.io/instance": fmt.Sprintf("%s-%s", input.AppName, input.ProcessType),
|
"app.kubernetes.io/instance": fmt.Sprintf("%s-%s", input.AppName, input.ProcessType),
|
||||||
@@ -565,6 +524,23 @@ func templateKubernetesDeployment(input Deployment) (appsv1.Deployment, error) {
|
|||||||
return deployment, nil
|
return deployment, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IngressRouteEntrypoint string
|
||||||
|
|
||||||
|
const (
|
||||||
|
IngressRouteEntrypoint_HTTP IngressRouteEntrypoint = "web"
|
||||||
|
IngressRouteEntrypoint_HTTPS IngressRouteEntrypoint = "websecure"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IngressRoute struct {
|
||||||
|
AppName string
|
||||||
|
Entrypoints []IngressRouteEntrypoint
|
||||||
|
Hostnames []string
|
||||||
|
Namespace string
|
||||||
|
PortMap PortMap
|
||||||
|
ProcessType string
|
||||||
|
ServiceName string
|
||||||
|
}
|
||||||
|
|
||||||
func templateKubernetesIngressRoute(input IngressRoute) traefikv1alpha1.IngressRoute {
|
func templateKubernetesIngressRoute(input IngressRoute) traefikv1alpha1.IngressRoute {
|
||||||
entryPoint := IngressRouteEntrypoint_HTTP
|
entryPoint := IngressRouteEntrypoint_HTTP
|
||||||
if input.PortMap.Scheme == "https" {
|
if input.PortMap.Scheme == "https" {
|
||||||
@@ -768,6 +744,12 @@ func templateKubernetesJob(input Job) (batchv1.Job, error) {
|
|||||||
return job, nil
|
return job, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Secret struct {
|
||||||
|
AppName string
|
||||||
|
Env map[string]string
|
||||||
|
Namespace string
|
||||||
|
}
|
||||||
|
|
||||||
func templateKubernetesSecret(input Secret) corev1.Secret {
|
func templateKubernetesSecret(input Secret) corev1.Secret {
|
||||||
secretName := fmt.Sprintf("env-%s.DEPLOYMENT_ID", input.AppName)
|
secretName := fmt.Sprintf("env-%s.DEPLOYMENT_ID", input.AppName)
|
||||||
labels := map[string]string{
|
labels := map[string]string{
|
||||||
@@ -793,6 +775,12 @@ func templateKubernetesSecret(input Secret) corev1.Secret {
|
|||||||
return secret
|
return secret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
AppName string
|
||||||
|
Namespace string
|
||||||
|
PortMaps []PortMap
|
||||||
|
}
|
||||||
|
|
||||||
func templateKubernetesService(input Service) corev1.Service {
|
func templateKubernetesService(input Service) corev1.Service {
|
||||||
labels := map[string]string{
|
labels := map[string]string{
|
||||||
"app.kubernetes.io/instance": fmt.Sprintf("%s-%s", input.AppName, "web"),
|
"app.kubernetes.io/instance": fmt.Sprintf("%s-%s", input.AppName, "web"),
|
||||||
@@ -830,6 +818,13 @@ func templateKubernetesService(input Service) corev1.Service {
|
|||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WriteResourceInput struct {
|
||||||
|
AppendContents string
|
||||||
|
Object runtime.Object
|
||||||
|
Path string
|
||||||
|
Replacements *orderedmap.OrderedMap[string, string]
|
||||||
|
}
|
||||||
|
|
||||||
func writeResourceToFile(input WriteResourceInput) error {
|
func writeResourceToFile(input WriteResourceInput) error {
|
||||||
common.LogDebug(fmt.Sprintf("Printing resource: %s", input.Path))
|
common.LogDebug(fmt.Sprintf("Printing resource: %s", input.Path))
|
||||||
printr := printers.NewTypeSetter(runtimeScheme).ToPrinter(&printers.YAMLPrinter{})
|
printr := printers.NewTypeSetter(runtimeScheme).ToPrinter(&printers.YAMLPrinter{})
|
||||||
@@ -880,6 +875,11 @@ func writeResourceToFile(input WriteResourceInput) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WriteYamlInput struct {
|
||||||
|
Object interface{}
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
func writeYaml(input WriteYamlInput) error {
|
func writeYaml(input WriteYamlInput) error {
|
||||||
common.LogDebug(fmt.Sprintf("Printing resource: %s", input.Path))
|
common.LogDebug(fmt.Sprintf("Printing resource: %s", input.Path))
|
||||||
data, err := yaml.Marshal(input.Object)
|
data, err := yaml.Marshal(input.Object)
|
||||||
|
|||||||
Reference in New Issue
Block a user