Skip to content

Commit

Permalink
added support for ingresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Matcuk committed Feb 1, 2018
1 parent dff762b commit f16a6eb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func main() {
flags.StringSliceVar(&kube.DaemonSetNames, "daemonsets", kube.DaemonSetNames, "(aka 'ds') Comma-separated names of DaemonSets to include")
flags.StringSliceVar(&kube.DeploymentNames, "deployments", kube.DeploymentNames, "(aka 'deploy') Comma-separated names of Deployments to include")
flags.StringSliceVar(&kube.HorizontalPodAutoscalerNames, "horizontalpodautoscalers", kube.HorizontalPodAutoscalers, "(aka 'hpa') Comma-separated names of Horizontal Pod Autoscalers to include")
flags.StringSliceVar(&kube.IngressNames, "ingresses", kube.IngressNames, "(aka 'ing') Comma-separated names of Ingresses to include")
flags.StringSliceVar(&kube.JobNames, "jobs", kube.JobNames, "Comma-separated names of Jobs to include")
flags.StringSliceVar(&kube.PersistentVolumeClaimNames, "persistentvolumeclaims", kube.PersistentVolumeClaimNames, "(aka 'pvc') Comma-separated names of PersistentVolumeClaims to include")
flags.StringSliceVar(&kube.PersistentVolumeNames, "persistentvolumes", kube.PersistentVolumeNames, "(aka 'pv') Comma-separated names of PersistentVolumes to include")
Expand Down Expand Up @@ -181,6 +182,8 @@ func main() {
name = "deployments"
case "hpa":
name = "horizontalpodautoscalers"
case "ing":
name = "ingresses"
case "pvc":
name = "persistentvolumeclaims"
case "pv":
Expand Down
4 changes: 4 additions & 0 deletions pkg/build_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (k *Kube) buildTemplates() ([]*chart.Template, string) {
manifest += addChartTemplate(templates, "hpa", name, k.HorizontalPodAutoscalers[i], idx)
idx++
}
for i, name := range k.IngressNames {
manifest += addChartTemplate(templates, "ingress", name, k.Ingresses[i], idx)
idx++
}
for i, name := range k.JobNames {
manifest += addChartTemplate(templates, "job", name, k.Jobs[i], idx)
idx++
Expand Down
30 changes: 30 additions & 0 deletions pkg/get_kube_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (k *Kube) GetKubeObjects(client *kubernetes.Clientset) error {
if err := k.getHorizontalPodAutoscalers(client); err != nil {
return err
}
if err := k.getIngresses(client); err != nil {
return err
}
if err := k.getJobs(client); err != nil {
return err
}
Expand Down Expand Up @@ -177,6 +180,33 @@ func (k *Kube) getHorizontalPodAutoscalers(client *kubernetes.Clientset) error {
return nil
}

func (k *Kube) getIngresses(client *kubernetes.Clientset) error {
for _, name := range k.IngressNames {
ingress, err := client.ExtensionsV1beta1().Ingresses(k.Namespace).Get(name, metav1.GetOptions{})
if err != nil {
return err
}
ref, err := apiref.GetReference(api.Scheme, ingress)
if err != nil {
return err
}
if ingress.Kind == "" {
ingress.Kind = ref.Kind
}
if ingress.APIVersion == "" {
ingress.APIVersion = makeAPIVersion(ingress.GetSelfLink())
}
cleanupMeta(&ingress.ObjectMeta)
yml, err := cleanupAndMarshalToYaml(ingress)
if err != nil {
return err
}
k.Ingresses = append(k.Ingresses, yml)
}
k.NumTemplates += len(k.Ingresses)
return nil
}

func (k *Kube) getJobs(client *kubernetes.Clientset) error {
for _, name := range k.JobNames {
job, err := client.BatchV1().Jobs(k.Namespace).Get(name, metav1.GetOptions{})
Expand Down
2 changes: 2 additions & 0 deletions pkg/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Kube struct {
DaemonSetNames []string
DeploymentNames []string
HorizontalPodAutoscalerNames []string
IngressNames []string
JobNames []string
PersistentVolumeClaimNames []string
PersistentVolumeNames []string
Expand All @@ -21,6 +22,7 @@ type Kube struct {
DaemonSets []string
Deployments []string
HorizontalPodAutoscalers []string
Ingresses []string
Jobs []string
PersistentVolumeClaims []string
PersistentVolumes []string
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: own
version: 0.2.0
version: 0.3.0
usage: Transfer ownership of a kubernetes release to helm
description: Transfer ownership of a kubernetes release to helm.
ignoreFlags: false
Expand Down

0 comments on commit f16a6eb

Please sign in to comment.