diff --git a/util/kubernetes/api/request.go b/util/kubernetes/api/request.go index 5abbeb7d..92bcbed6 100644 --- a/util/kubernetes/api/request.go +++ b/util/kubernetes/api/request.go @@ -163,12 +163,12 @@ func (r *Request) request() (*http.Request, error) { case "namespace": // /api/v1/namespaces/ url = fmt.Sprintf("%s/api/v1/namespaces/", r.host) - case "pod", "service", "endpoint", "serviceaccount": - // /api/v1/namespaces/{namespace}/pods - url = fmt.Sprintf("%s/api/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource) case "deployment": // /apis/apps/v1/namespaces/{namespace}/deployments/{name} url = fmt.Sprintf("%s/apis/apps/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource) + default: + // /api/v1/namespaces/{namespace}/{resource} + url = fmt.Sprintf("%s/api/v1/namespaces/%s/%ss/", r.host, r.namespace, r.resource) } // append resourceName if it is present diff --git a/util/kubernetes/client/templates.go b/util/kubernetes/client/templates.go index 2442caf3..9c2851c8 100644 --- a/util/kubernetes/client/templates.go +++ b/util/kubernetes/client/templates.go @@ -4,6 +4,7 @@ var templates = map[string]string{ "deployment": deploymentTmpl, "service": serviceTmpl, "namespace": namespaceTmpl, + "secret": secretTmpl, "serviceaccount": serviceAccountTmpl, } @@ -125,6 +126,26 @@ metadata: {{- end }} ` +var secretTmpl = ` +apiVersion: v1 +kind: Secret +metadata: + name: "{{ .Metadata.Name }}" + namespace: "{{ .Metadata.Namespace }}" + labels: + {{- with .Metadata.Labels }} + {{- range $key, $value := . }} + {{ $key }}: "{{ $value }}" + {{- end }} + {{- end }} +data: +{{- with .Data }} +{{- range $key, $value := . }} +{{ $key }}: "{{ $value }}" +{{- end }} +{{- end }} +` + var serviceAccountTmpl = ` apiVersion: v1 kind: ServiceAccount diff --git a/util/kubernetes/client/types.go b/util/kubernetes/client/types.go index 3c4e20d9..1dc13e4e 100644 --- a/util/kubernetes/client/types.go +++ b/util/kubernetes/client/types.go @@ -195,6 +195,13 @@ type ImagePullSecret struct { Name string `json:"name"` } +// Secret +type Secret struct { + Type string `json:"type,omitempty"` + Data map[string]string `json:"data"` + Metadata *Metadata `json:"metadata"` +} + // ServiceAccount type ServiceAccount struct { Metadata *Metadata `json:"metadata,omitempty"`