-
Notifications
You must be signed in to change notification settings - Fork 205
Allow specifying SSH key for the Git repository where to fetch private Helm charts #2863
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6bcec75
Allow specifying SSH key for the Git repository where used to fetch p…
nghialv aac3d9d
Update pkg/config/piped.go
nghialv a9c370c
Fix error
nghialv 0ef87ed
Fix
nghialv b78b32d
Add type field to HelmChartRepository config
nghialv d2f46d9
Fix error
nghialv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,11 @@ func (s *PipedSpec) Validate() error { | |
| if s.SyncInterval < 0 { | ||
| return errors.New("syncInterval must be greater than or equal to 0") | ||
| } | ||
| for _, r := range s.ChartRepositories { | ||
| if err := r.Validate(); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| if s.SecretManagement != nil { | ||
| if err := s.SecretManagement.Validate(); err != nil { | ||
| return err | ||
|
|
@@ -245,7 +250,19 @@ type PipedRepository struct { | |
| Branch string `json:"branch"` | ||
| } | ||
|
|
||
| type HelmChartRepositoryType string | ||
|
|
||
| const ( | ||
| HTTPHelmChartRepository HelmChartRepositoryType = "HTTP" | ||
| GITHelmChartRepository HelmChartRepositoryType = "GIT" | ||
| ) | ||
|
|
||
| type HelmChartRepository struct { | ||
| // The repository type. Currently, HTTP and GIT are supported. | ||
| // Default is HTTP. | ||
| Type HelmChartRepositoryType `json:"type" default:"HTTP"` | ||
|
|
||
| // Configuration for HTTP type. | ||
| // The name of the Helm chart repository. | ||
| Name string `json:"name"` | ||
| // The address to the Helm chart repository. | ||
|
|
@@ -256,6 +273,62 @@ type HelmChartRepository struct { | |
| Password string `json:"password"` | ||
| // Whether to skip TLS certificate checks for the repository or not. | ||
| Insecure bool `json:"insecure"` | ||
|
|
||
| // Configuration for GIT type. | ||
| // Remote address of the Git repository used to clone Helm charts. | ||
| // e.g. [email protected]:org/repo.git | ||
| GitRemote string `json:"gitRemote"` | ||
| // The path to the private ssh key file used while cloning Helm charts from above Git repository. | ||
| SSHKeyFile string `json:"sshKeyFile"` | ||
| } | ||
|
|
||
| func (r *HelmChartRepository) IsHTTPRepository() bool { | ||
| return r.Type == HTTPHelmChartRepository | ||
| } | ||
|
|
||
| func (r *HelmChartRepository) IsGitRepository() bool { | ||
| return r.Type == GITHelmChartRepository | ||
| } | ||
|
|
||
| func (r *HelmChartRepository) Validate() error { | ||
| if r.IsHTTPRepository() { | ||
| if r.Name == "" { | ||
| return errors.New("name must be set") | ||
| } | ||
| if r.Address == "" { | ||
| return errors.New("address must be set") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| if r.IsGitRepository() { | ||
| if r.GitRemote == "" { | ||
| return errors.New("gitRemote must be set") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| return fmt.Errorf("either %s repository or %s repository must be configured", HTTPHelmChartRepository, GITHelmChartRepository) | ||
| } | ||
|
|
||
| func (s *PipedSpec) HTTPHelmChartRepositories() []HelmChartRepository { | ||
| repos := make([]HelmChartRepository, 0, len(s.ChartRepositories)) | ||
| for _, r := range s.ChartRepositories { | ||
| if r.IsHTTPRepository() { | ||
| repos = append(repos, r) | ||
| } | ||
| } | ||
| return repos | ||
| } | ||
|
|
||
| func (s *PipedSpec) GitHelmChartRepositories() []HelmChartRepository { | ||
| repos := make([]HelmChartRepository, 0, len(s.ChartRepositories)) | ||
| for _, r := range s.ChartRepositories { | ||
| if r.IsGitRepository() { | ||
| repos = append(repos, r) | ||
| } | ||
| } | ||
| return repos | ||
| } | ||
|
|
||
| type PipedCloudProvider struct { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits, users may insert HTTP, http or Http as well. Or we may need to check for the type field in the validation function at L293.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we should allow that. Like,
KubernetesAppnotK8sApporkubernetesApp.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think we should distinguish between lowercase and uppercase.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, in that case, we may need to add validate
r.Typeto the validate function at line L293, and the current error message (at L311) returnGitinstead ofGIThttps://github.com/pipe-cd/pipe/pull/2863/files#diff-49258a851400c4bc54c40491b440d7edf1dd45eda52c9eccd3f5371af15e8409R311
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that should be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
Fixed it.