Skip to content

Commit

Permalink
private key file for env + fix bug when application secret not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi Calizzano committed Aug 8, 2022
1 parent a747828 commit 96c7131
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ var envCmd = &cobra.Command{
}

type envFlags struct {
name string
value string
fleetBranch string
name string
value string
fleetBranch string
privateKeyFile string

authorName string
authorEmail string
Expand All @@ -40,6 +41,7 @@ func init() {
envCmd.PersistentFlags().StringVar(&envArgs.name, "name", "", "name of the env variable to add")
envCmd.PersistentFlags().StringVar(&envArgs.value, "value", "", "value of the env variable to add")
envCmd.PersistentFlags().StringVar(&envArgs.fleetBranch, "fleet-branch", "main", "Git branch of the fleet repository")
envCmd.PersistentFlags().StringVar(&envArgs.privateKeyFile, "private-key-file", "", "path to a private key file used for authenticating to the Git SSH server")

envCmd.PersistentFlags().StringVar(&envArgs.authorName, "author-name", "Lizz", "author name for Git commits")
envCmd.PersistentFlags().StringVar(&envArgs.authorEmail, "author-email", "", "author email for Git commits")
Expand Down
10 changes: 4 additions & 6 deletions cmd/env_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ var envGitCmd = &cobra.Command{
}

type envGitFlags struct {
fleetUrl string
username string
password string
privateKeyFile string
fleetUrl string
username string
password string
}

var envGitArgs envGitFlags
Expand All @@ -40,7 +39,6 @@ func init() {
envGitCmd.Flags().StringVar(&envGitArgs.fleetUrl, "fleet-url", "", "Git repository URL of the fleet repository")
envGitCmd.Flags().StringVarP(&envGitArgs.username, "username", "u", "git", "basic authentication username")
envGitCmd.Flags().StringVarP(&envGitArgs.password, "password", "p", "", "basic authentication password")
envGitCmd.Flags().StringVar(&envGitArgs.privateKeyFile, "private-key-file", "", "path to a private key file used for authenticating to the Git SSH server")

envCmd.AddCommand(envGitCmd)
}
Expand All @@ -54,7 +52,7 @@ func envGitCmdRun(cmd *cobra.Command, args []string) error {
Branch: envArgs.fleetBranch,
Username: envGitArgs.username,
Password: envGitArgs.password,
PrivateKeyFile: envGitArgs.privateKeyFile,
PrivateKeyFile: envArgs.privateKeyFile,
Timeout: rootArgs.timeout,
},
status,
Expand Down
1 change: 1 addition & 0 deletions cmd/env_gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func envGitlabCmdRun(cmd *cobra.Command, args []string) error {
Branch: removeArgs.fleetBranch,
Username: envGitlabArgs.owner,
Password: glToken,
PrivateKeyFile: envArgs.privateKeyFile,
Timeout: rootArgs.timeout,
Personal: envGitlabArgs.personal,
Reconcile: envGitlabArgs.reconcile,
Expand Down
3 changes: 3 additions & 0 deletions internal/repo/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func (r *ApplicationRepo) Render(destinationRepo *Repository, username, pwd stri
}
}
for _, v := range r.config.Values.ApplicationSecrets {
if v.Secret == nil {
continue
}
v.Secret["metadata"].(map[interface{}]interface{})["namespace"] = r.config.Namespace
y, err := yaml2.Marshal(v.Secret)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/repo/config_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ func RenderApplicationConfig(
}
}
if repository.URL == "" && repository.Name == "" {
return &ApplicationConfig{}, fmt.Errorf("application repository of the application secret number %d not found", idx)
v.ApplicationSecrets[idx].Secret = nil
continue
}
applicationCloneOptions := cloneOptions
applicationCloneOptions.URL = repository.URL
Expand Down
Binary file modified lizz
Binary file not shown.

0 comments on commit 96c7131

Please sign in to comment.