diff --git a/kardinal-cli/cmd/root.go b/kardinal-cli/cmd/root.go index 284f1dc2..dc9f7cec 100644 --- a/kardinal-cli/cmd/root.go +++ b/kardinal-cli/cmd/root.go @@ -79,7 +79,7 @@ var deployCmd = &cobra.Command{ Short: "Deploy services", Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { - serviceConfigs, ingressConfigs, err := parseKubernetesManifestFile(kubernetesManifestFile) + serviceConfigs, ingressConfigs, namespace, err := parseKubernetesManifestFile(kubernetesManifestFile) if err != nil { log.Fatalf("Error loading k8s manifest file: %v", err) } @@ -88,7 +88,7 @@ var deployCmd = &cobra.Command{ log.Fatal("Error getting or creating user tenant UUID", err) } - deploy(tenantUuid.String(), serviceConfigs, ingressConfigs) + deploy(tenantUuid.String(), serviceConfigs, ingressConfigs, namespace) }, } @@ -104,7 +104,7 @@ var templateCreateCmd = &cobra.Command{ // A valid template only modifies services // A valid template has metadata.name // A valid template modifies at least one service - serviceConfigs, _, err := parseKubernetesManifestFile(templateYamlFile) + serviceConfigs, _, _, err := parseKubernetesManifestFile(templateYamlFile) if err != nil { log.Fatalf("Error loading template file: %v", err) } @@ -390,14 +390,15 @@ func parsePairs(pairs []string) map[string]string { return pairsMap } -func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.ServiceConfig, []api_types.IngressConfig, error) { +func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.ServiceConfig, []api_types.IngressConfig, string, error) { fileBytes, err := loadKubernetesManifestFile(kubernetesManifestFile) if err != nil { log.Fatalf("Error loading kubernetest manifest file: %v", err) - return nil, nil, err + return nil, nil, "", err } manifest := string(fileBytes) + var namespace string serviceConfigs := map[string]*api_types.ServiceConfig{} ingressConfigs := map[string]*api_types.IngressConfig{} decode := scheme.Codecs.UniversalDeserializer().Decode @@ -407,7 +408,7 @@ func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.Ser } obj, _, err := decode([]byte(spec), nil, nil) if err != nil { - return nil, nil, stacktrace.Propagate(err, "An error occurred parsing the spec: %s", spec) + return nil, nil, "", stacktrace.Propagate(err, "An error occurred parsing the spec: %s", spec) } switch obj := obj.(type) { case *corev1.Service: @@ -436,8 +437,12 @@ func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.Ser ingress := obj ingressName := getObjectName(ingress.GetObjectMeta().(*metav1.ObjectMeta)) ingressConfigs[ingressName] = &api_types.IngressConfig{Ingress: *ingress} + case *corev1.Namespace: + namespaceObj := obj + namespaceName := getObjectName(namespaceObj.GetObjectMeta().(*metav1.ObjectMeta)) + namespace = namespaceName default: - return nil, nil, stacktrace.NewError("An error occurred parsing the manifest because of an unsupported kubernetes type") + return nil, nil, "", stacktrace.NewError("An error occurred parsing the manifest because of an unsupported kubernetes type") } } @@ -451,7 +456,7 @@ func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.Ser finalIngressConfigs = append(finalIngressConfigs, *ingressConfig) } - return finalServiceConfigs, finalIngressConfigs, nil + return finalServiceConfigs, finalIngressConfigs, namespace, nil } func parseTemplateArgs(filename string) (map[string]interface{}, error) { @@ -557,12 +562,13 @@ func createDevFlow(tenantUuid api_types.Uuid, pairsMap map[string]string, templa os.Exit(1) } -func deploy(tenantUuid api_types.Uuid, serviceConfigs []api_types.ServiceConfig, ingressConfigs []api_types.IngressConfig) { +func deploy(tenantUuid api_types.Uuid, serviceConfigs []api_types.ServiceConfig, ingressConfigs []api_types.IngressConfig, namespace string) { ctx := context.Background() body := api_types.PostTenantUuidDeployJSONRequestBody{ ServiceConfigs: &serviceConfigs, IngressConfigs: &ingressConfigs, + Namespace: &namespace, } client := getKontrolServiceClient() diff --git a/libs/cli-kontrol-api/api/golang/server/server.gen.go b/libs/cli-kontrol-api/api/golang/server/server.gen.go index 8410fe75..9f0d546f 100644 --- a/libs/cli-kontrol-api/api/golang/server/server.gen.go +++ b/libs/cli-kontrol-api/api/golang/server/server.gen.go @@ -858,29 +858,29 @@ func (sh *strictHandler) GetTenantUuidTopology(ctx echo.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Fid7m8br8fPGtWOnjIiBDKHa8WwYGrhEvYXS5vG3wP", - "OHKyQU/mU/Agt4XrpBsC666+HQdw6lQuUKGaWMelq6/UwTkzCLQr7G0eCnO6qL1gx9O38yawGEwmNzZk", - "VwvNUUZ3cNRMp/pNq3/TNjhycNq2OIp0PZ37OBOZlUW9BpI0pQYZkt90hNwSMx6J3u7Hkza2ec3zcSIb", - "I0/Zhts2pNpO/6u36/gfzrTkOfrjZo0busIrfLm8WF6YYLkARgTFK/yrfeVAt0nHWyC5KcBo2+USuW8o", - "2ULygBLnBUfY3wkNRnZVWad4hf8C/bczNdjqfrm4OGnLCWyJ/chuyyQBpTZljmpHRqyKcKyBEabjZ7OK", - "VrHjClt1rgIh33Cl76zGfUlTR5QWm/a/A96HB3IrEtutt/rgKglK/8nT/Un5Hhr440tKAA8XOCJISJ4i", - "zvI9SpzOaBuvXlibQ7HaG3owvB0yt2eUSLB2kdJEl8o05quLV1NmmzjjZleuIvybC/iwgt+yQy1hAolt", - "IDC3L0xeV07ju/fGeNv5qDyRHSuFJbwuUc1R7LFlaBlyVubs+Q4yRFBa179UlGWoji1CXDi2zffokeot", - "Iqjn/hx6981Z9e2zX0crx9Y5uCbuN++1fd9vX/NvnX5l+0ZH5eot2XV6t0RPT+PB0vCBzeAMcLWhTs20", - "PpDqJRTwgt6dtR26Jh5dmc6bkGt6mlmEu0b8jAvRLCEzivGWKm0vinVizd5sbuQMObR+bGlOHJhNjX7U", - "1JxTm+nrVDO4GDx27+7fbxq1/TOOrv52Xoc3fu798HTSgGrapX545366+jazqv8D2byJ1WB+DhNLd34W", - "mcGXtfSPoctDXT78mSfU7P4bMluvLKyX7wF6Vf0fAAD//62ffaEjHgAA", + "/RBAEc/98h0e6xknvBCcAdMKr56xIJIUoEHa/zY5f1zQ1DymoBJJhaac4RV+k/NHRFNgmm4oSBxhal4L", + "orc4wowUgFcNd4QlfCmphBSvtCwhwirZQkGMWL0XhlRpSVmGqyrCGgqREw0LJ2Wo2bxFfIP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X+1r1zQrdPxFkhuEjDa", + "hblE7gwlW0geUOK04Aj7G6OJkV1k1ile4b9A/+1EDXa+Xy4uTtqBAjtk37LbMklAqU2Zo1qRIasiHGtg", + "hOn42SyqVeywwmadq4DJN1zpO8txX9LUAaWNTftjwfvwQG5JYrsTVx9cJkHpP3m6P8nfQwN/fIUJxMMZ", + "jggSkqeIs3yPEscz2tWrF+bmkK32/h40b4fM3RolEqxcpDTRpTKF+eri1ZTYxs642aSrCP/mDD7M4Hfw", + "UEkYQ2JrCMytC+PXleP47rUx3oU+Kg9kx1JhAa8LVHMYe2gZWpWclDm/AriQIYLSOv+loixDtW0R4sKh", + "bb5Hj1RvEUE99edQu2/Oqm6f/bJaObTOwRVxv3iv7ft++Zq/dfqV5Rsdpat3aFfp3RQ9PY0HS4MH1oMz", + "iKs1dWqm9QOpXgIBL6jdWduhK+LRlem8AbmGp5lJuGvIzzgRzRIyIxlvqdL2olg71uzN5kbOkIvWj03N", + "iQOzydGPmppzcjN9nWoGF4PH7t39+02jtn7G1tVn59W88XPvs9RJA6opl/rhnfuw9W1mVf/z2byJ1cT8", + "HCaW7nw0mYGXNfWPgctDVT78CBQqdn+GzNYrC6vlewS9qv4PAAD//38SsWFBHgAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/libs/cli-kontrol-api/api/golang/types/types.gen.go b/libs/cli-kontrol-api/api/golang/types/types.gen.go index 0127142a..366f9e7c 100644 --- a/libs/cli-kontrol-api/api/golang/types/types.gen.go +++ b/libs/cli-kontrol-api/api/golang/types/types.gen.go @@ -55,6 +55,7 @@ type IngressConfig struct { // MainClusterConfig defines model for MainClusterConfig. type MainClusterConfig struct { IngressConfigs *[]IngressConfig `json:"ingress-configs,omitempty"` + Namespace *string `json:"namespace,omitempty"` ServiceConfigs *[]ServiceConfig `json:"service-configs,omitempty"` } diff --git a/libs/cli-kontrol-api/api/typescript/client/types.d.ts b/libs/cli-kontrol-api/api/typescript/client/types.d.ts index 76d9a39b..4a149529 100644 --- a/libs/cli-kontrol-api/api/typescript/client/types.d.ts +++ b/libs/cli-kontrol-api/api/typescript/client/types.d.ts @@ -197,6 +197,7 @@ export interface components { MainClusterConfig: { "service-configs"?: components["schemas"]["ServiceConfig"][]; "ingress-configs"?: components["schemas"]["IngressConfig"][]; + namespace?: string; }; Flow: { "flow-id": string; diff --git a/libs/cli-kontrol-api/specs/api.yaml b/libs/cli-kontrol-api/specs/api.yaml index 68fba497..6c66e256 100644 --- a/libs/cli-kontrol-api/specs/api.yaml +++ b/libs/cli-kontrol-api/specs/api.yaml @@ -242,6 +242,8 @@ components: type: array items: $ref: "#/components/schemas/IngressConfig" + namespace: + type: string Flow: type: object