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

Add Toggle for NewModule Form and skipCRDs Support in Backend #616

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cyclops-ctrl/api/v1alpha1/module_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ModuleSpec struct {
TargetNamespace string `json:"targetNamespace"`
TemplateRef TemplateRef `json:"template"`
Values apiextensionsv1.JSON `json:"values"`
SkipCRDs bool `json:"skipCRDs,omitempty"`
}

type ModuleValue struct {
Expand Down
15 changes: 9 additions & 6 deletions cyclops-ctrl/internal/modulecontroller/module_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,17 @@ func (r *ModuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
}

func (r *ModuleReconciler) moduleToResources(template *models.Template, module *cyclopsv1alpha1.Module) ([]string, []cyclopsv1alpha1.GroupVersionResource, error) {
crdInstallErrors := r.applyCRDs(template)
var crdInstallErrors []string
if !module.Spec.SkipCRDs {
crdInstallErrors = r.applyCRDs(template)
}

installErrors, childrenGVRs, err := r.generateResources(r.kubernetesClient, *module, template)
if err != nil {
return nil, nil, err
}
installErrors, childrenGVRs, err := r.generateResources(r.kubernetesClient, *module, template)
if err != nil {
return nil, nil, err
}

return append(crdInstallErrors, installErrors...), childrenGVRs, nil
return append(crdInstallErrors, installErrors...), childrenGVRs, nil
}

func (r *ModuleReconciler) generateResources(
Expand Down
18 changes: 18 additions & 0 deletions cyclops-ui/src/components/pages/NewModule/NewModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Modal,
Spin,
notification,
Switch,
} from "antd";
import axios from "axios";
import { findMaps, flattenObjectKeys, mapsToArray } from "../../../utils/form";
Expand Down Expand Up @@ -117,6 +118,7 @@ const NewModule = () => {
const handleSubmit = (values: any) => {
const moduleName = values["cyclops_module_name"];
const moduleNamespace = values["cyclops_module_namespace"];
const skipCRDs = values["cyclops_module_skip_crds"];

values = findMaps(config.root.properties, values, initialValuesRaw);

Expand All @@ -125,6 +127,7 @@ const NewModule = () => {
name: moduleName,
namespace: moduleNamespace,
values: values,
skipCRDs: skipCRDs,
template: {
repo: template.repo,
path: template.path,
Expand Down Expand Up @@ -576,6 +579,21 @@ const NewModule = () => {
))}
</Select>
</Form.Item>
<Form.Item
name="cyclops_module_skip_crds"
valuePropName="checked"
style={{ padding: "12px 12px 0px 12px" }}
label={
<div>
Skip CRDs
<p style={{ color: "#8b8e91", marginBottom: "0px" }}>
Skip CRDs creation
</p>
</div>
}
>
<Switch />
</Form.Item>
</div>
<div className={"expandadvanced"} onClick={toggleExpand}>
{advancedOptionsExpanded ? (
Expand Down
Loading