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

Dev cli #30

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Dev cli #30

wants to merge 16 commits into from

Conversation

vahand
Copy link
Contributor

@vahand vahand commented Jun 9, 2023

Description

Add push function that :

  • read the .env file
  • take all variables except variables that begin with SECURE_ENV_
  • create in the Vault variables that not exist
  • update in the Vault variables that exist with their new key / content.

Edit Screate function :

  • now Screate take all secrets already created and create a new secret including the new one

Changes include

Bugfixe on Screate function
New push function

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the needed labels
  • I have linked this PR to an issue
  • I have linked this PR to a milestone
  • I have linked this PR to a project
  • I have tested this code
  • I have added / updated tests (unit / functional / end-to-end / ...)
  • I have updated the README and other relevant documents (guides...)
  • I have added sufficient documentation both in code, as well as in the READMEs

@vahand vahand requested a review from RezaRahemtola June 9, 2023 12:13
CLI/main.go Outdated
Comment on lines 18 to 20
var (
rootFlagSet = flag.NewFlagSet("textctl", flag.ExitOnError)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var (
rootFlagSet = flag.NewFlagSet("textctl", flag.ExitOnError)
)
rootFlagSet := flag.NewFlagSet("textctl", flag.ExitOnError)

CLI/main.go Outdated
vault_actions.Push(client)
return nil
},
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move these commands in their respective files and import them in the main, it will be cleaner as we will add more and more commands in the future

Comment on lines 1 to 4
SECURE_ENV_PROJECT_NAME="secure-env"
SECURE_ENV_HOST="https://secure-env.poc-innovation.com:8200/"
SECURE_ENV_PORT=8200
SECURE_ENV_TOKEN="hvs.NWAqB95aaCepzz7GXVrO43KW"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Don't push the .env ⚠️

You can remove it from your commit, and rename it .env for a more conventional name

Comment on lines 20 to 21
err := godotenv.Load("secure-env.env")
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err := godotenv.Load("secure-env.env")
if err != nil {
if err := godotenv.Load("env"); err != nil {

return variable
}

func IsVariableSecureEnvLocal(variable Variable) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you add an uppercase if it's only used in this file ?

Suggested change
func IsVariableSecureEnvLocal(variable Variable) bool {
func isVariableSecureEnvLocal(variable Variable) bool {

return result
}

func Create_var(data string) Variable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Value string
}

func LinesInFile(fileName string) []string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}
return push
}

func Push(client *vault.Client) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it's this function that is exported for nothing imo as it's only used in this file

}
return screate
}

func Screate(name string, secretData map[string]interface{}, client *vault.Client) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
return sdelete
}

func Sdelete(name string, client *vault.Client) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
return sget
}

func Sget(name string, key string, client *vault.Client) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and again 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants