Skip to content

Commit

Permalink
Add new property secret to support non clear values
Browse files Browse the repository at this point in the history
  • Loading branch information
ivancorrales committed Mar 6, 2022
1 parent 724474c commit 5236a80
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 51 deletions.
79 changes: 41 additions & 38 deletions cmd/client/templatizer-ui/src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,48 +100,51 @@ export const TemplatizerForm = () => {
}

return (
<Paper
style={{
display: "grid",
gridRowGap: "20px",
padding: "20px",
margin: "10px 300px",
}}
>
<Typography variant="h3">{title}</Typography>
{!showTemplateVars &&
<Grid container spacing={1}>
<RepositoryDetails control={control} setValue={setValue} />
<hr />
<Button className="btn-primary" onClick={() => loadVariables()} variant={"outlined"}>
{" "}Next{" "}
</Button>
</Grid>
}
{showTemplateVars &&
<Grid container spacing={1}>
<div>
<Paper
style={{
display: "grid",
gridRowGap: "20px",
padding: "20px",
margin: "10px 300px",
}}
>
<Typography variant="h3">{title}</Typography>
{!showTemplateVars &&
<Grid container spacing={1}>
<RepositoryDetails control={control} setValue={setValue} />
<hr />
<Button className="btn-primary" onClick={() => loadVariables()} variant={"outlined"}>
{" "}Next{" "}
</Button>
</Grid>
}
{showTemplateVars &&
<Grid container spacing={1}>

<Grid item lg={12}>
<Typography variant="h6">Tempalte variables</Typography>
</Grid>
<TemplateVars control={control} setValue={setValue} updateParam={updateParam} />
<Button onClick={() => {
setTemplateVars(false)
}} variant={"outlined"}>
{" "}Back{" "}
</Button>
<hr />
<Button onClick={() => processTemplate()} variant={"outlined"}>
{" "}
Process Template{" "}
</Button>

<Grid item lg={12}>
<Typography variant="h6">Tempalte variables</Typography>
</Grid>
<TemplateVars control={control} setValue={setValue} updateParam={updateParam} />
<Button onClick={() => {
setTemplateVars(false)
}} variant={"outlined"}>
{" "}Back{" "}
</Button>
<hr />
<Button onClick={() => processTemplate()} variant={"outlined"}>
{" "}
Process Template{" "}
</Button>

</Grid>

}
}

</Paper>
<div className="footer">
<p>Developed by <a href="https://www.linkedin.com/in/ivan-corrales-solera/">Iván Corrales</a></p>
<p>Developed by <a href="https://www.linkedin.com/in/ivan-corrales-solera/">Iván Corrales</a></p>
</div>
</Paper>
</div>
);
};
1 change: 1 addition & 0 deletions cmd/client/templatizer-ui/src/components/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Var {
description: string;
type: string;
default: string;
secret?: boolean;
}

export interface ProcessTemplateRequest extends LoadParametersRequest {
Expand Down
11 changes: 6 additions & 5 deletions cmd/client/templatizer-ui/src/components/RepositoryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const defaultValues = {
url: "https://github.com/ivancorrales/seed.git",
branchDefault: "default",
authMechanism: 'none',
configPath: '.templatizer.yml'
};


Expand Down Expand Up @@ -153,7 +152,7 @@ export const RepositoryDetails: React.FC<RepositoryDetailsProps> = ({
<TextField
fullWidth
label="Username"
helperText={"develop, stable, release/v1.0.1"}
helperText={"Introduce your username"}
error={!!error}
onChange={onChange}
value={value}
Expand All @@ -170,11 +169,12 @@ export const RepositoryDetails: React.FC<RepositoryDetailsProps> = ({
<TextField
fullWidth
label="Password"
helperText={"develop, stable, release/v1.0.1"}
helperText={"The OAuth tokens of popular servers (e.g. GitHub, Bitbucket, GitLab)"}
error={!!error}
onChange={onChange}
value={value}
variant="standard"
type={"password"}
/>
)} />

Expand All @@ -189,11 +189,12 @@ export const RepositoryDetails: React.FC<RepositoryDetailsProps> = ({
<TextField
fullWidth
label="Token"
helperText={"develop, stable, release/v1.0.1"}
helperText={"Use the basic authentication If you OAuth tokens of popular servers (e.g. GitHub, Bitbucket, GitLab)"}
error={!!error}
onChange={onChange}
value={value}
variant="standard"
type={"password"}
/>
)} />
</Grid>
Expand All @@ -210,7 +211,7 @@ export const RepositoryDetails: React.FC<RepositoryDetailsProps> = ({
<TextField
fullWidth
label="Path"
helperText={"i.e .template/templatizer.yml"}
helperText={"By default Templatizer will search for file `.templatizer.yml` in the root of the repository"}
error={!!error}
onChange={onChange}
value={value}
Expand Down
4 changes: 3 additions & 1 deletion cmd/client/templatizer-ui/src/components/TemplateVars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const TemplateVars: React.FC<TemplateVarsProps> = ({
render={({
field: { value },
}) => (
<TextField

< TextField
fullWidth
value={value}
label={variable.name}
Expand All @@ -45,6 +46,7 @@ export const TemplateVars: React.FC<TemplateVarsProps> = ({
setValue(name, val.target.value)
updateParam(variable.name, val.target.value)
}}
type={variable.secret ? "password" : "text"}
/>
)}
/>
Expand Down
6 changes: 2 additions & 4 deletions cmd/client/templatizer-ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ code {
}

.footer{
margin-top: 1rem;
margin-top: 2rem;
padding: 1rem;
background-color: #d3fdb7;
position: fixed;
/* position: fixed; */
bottom: 0;
left: 0;
width: 100%;

}
1 change: 1 addition & 0 deletions internal/templatizer/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func WithBasicAuth(username, password string) Option {

func WithTokenAuth(token string) Option {
return func(act *executor) {
println(token)
act.auth = &http.TokenAuth{
Token: token,
}
Expand Down
7 changes: 4 additions & 3 deletions internal/templatizer/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
func cloneRepositorty(repoURL string, branch string, auth http.AuthMethod) (*git.Worktree, error) {
log.Debug("- clone repository")
repo, err := git.Clone(memory.NewStorage(), memfs.New(), &git.CloneOptions{
URL: repoURL,
Auth: auth,
Progress: os.Stdout,
URL: repoURL,
Auth: auth,
Progress: os.Stdout,
InsecureSkipTLS: true,
})
if err != nil {
log.Error("unexpected error while clonning the repository")
Expand Down
3 changes: 3 additions & 0 deletions pkg/handlers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ func buildExecutor(req resources.ConnectionRequest) templatizer.Executor {
options = append(options, templatizer.WithTokenAuth(req.Auth.Token))
}
}
if req.ConfigPath != "" {
options = append(options, templatizer.WithConfigPath(req.ConfigPath))
}
return templatizer.New(options...)
}
1 change: 1 addition & 0 deletions pkg/handlers/loadParameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func LoadParamaters(c *gin.Context) {
return
}
executor := buildExecutor(req)

templateSettings, err := executor.LoadTemplatizerconfig()
if err != nil {
processError(err, c)
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Variable struct {
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
Default string `json:"default,omitempty"`
Secret bool `json:"secret"`
}
type Config struct {
Versino string `json:"version,omitempty"`
Expand Down

0 comments on commit 5236a80

Please sign in to comment.