Skip to content

Commit

Permalink
fix(webseal): optional namespace in dev (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon authored Oct 24, 2022
1 parent 4ccd68c commit fea4890
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 234 deletions.
19 changes: 11 additions & 8 deletions packages/webseal/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,25 @@ const Editor = () => {
if (data.value && data.value !== formData.value) {
const pemKey = certificates[data.cluster];
const values = parseClearText(data.value);
const sealedSecret = await getSealedSecret({
pemKey,
namespace: data.namespace || null,
name: data.name || "some-secret-name",
scope: data.scope,
values,
});
if (!data.namespace || !data.name) {

if ((data.cluster === "prod" && !data.namespace) || !data.name) {
console.log("namespace and name are mandatory");
setYamlResult("");
setEncrypted("");
return;
} else if (!data.value) {
console.log("value is mandatory");
setYamlResult("");
setEncrypted("");
return;
} else {
const sealedSecret = await getSealedSecret({
pemKey,
namespace: data.namespace || null,
name: data.name || "some-secret-name",
scope: data.scope,
values,
});
const keys = Object.keys(values);
if (keys.length === 1) {
setEncrypted(sealedSecret.spec.encryptedData[keys[0]]);
Expand Down
10 changes: 6 additions & 4 deletions packages/webseal/src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const Form = ({ onSubmit, initialFormData }) => {
onChange={(e) => {
setValue("cluster", e.target.value);
setValue("scope", "cluster");
setValue("namespace", undefined);
setValue("name", undefined);
// setValue("namespace", undefined);
// setValue("name", undefined);
trigger();
}}
/>
Expand Down Expand Up @@ -157,14 +157,16 @@ export const Form = ({ onSubmit, initialFormData }) => {
</Col>
</Row>
<BsForm.Group as={Row}>
<BsForm.Label column>Namespace *</BsForm.Label>
<BsForm.Label column>
Namespace {cluster === "prod" ? "*" : ""}
</BsForm.Label>
<Col sm="9">
<BsForm.Control
name="namespace"
{...register("namespace", { required: true })}
required
type="text"
placeholder="K8s Namespace"
placeholder="K8s Namespace (optional in dev)"
/>
</Col>
</BsForm.Group>
Expand Down
Loading

0 comments on commit fea4890

Please sign in to comment.