Skip to content

Commit f8b0c3a

Browse files
authored
Merge pull request #216 from fluxcd/local-run
2 parents 8492473 + 7873fe2 commit f8b0c3a

File tree

2 files changed

+126
-1
lines changed

2 files changed

+126
-1
lines changed

CONTRIBUTING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contributing
2+
3+
Helm Controller is [Apache 2.0 licensed](LICENSE) and accepts contributions
4+
via GitHub pull requests. This document outlines some of the conventions on
5+
to make it easier to get your contribution accepted.
6+
7+
We gratefully welcome improvements to issues and documentation as well as to
8+
code.
9+
10+
## Certificate of Origin
11+
12+
By contributing to this project you agree to the Developer Certificate of
13+
Origin (DCO). This document was created by the Linux Kernel community and is a
14+
simple statement that you, as a contributor, have the legal right to make the
15+
contribution.
16+
17+
We require all commits to be signed. By signing off with your signature, you
18+
certify that you wrote the patch or otherwise have the right to contribute the
19+
material by the rules of the [DCO](DCO):
20+
21+
`Signed-off-by: Jane Doe <jane.doe@example.com>`
22+
23+
The signature must contain your real name
24+
(sorry, no pseudonyms or anonymous contributions)
25+
If your `user.name` and `user.email` are configured in your Git config,
26+
you can sign your commit automatically with `git commit -s`.
27+
28+
## Communications
29+
30+
The project uses Slack: To join the conversation, simply join the
31+
[CNCF](https://slack.cncf.io/) Slack workspace and use the
32+
[#flux](https://cloud-native.slack.com/messages/flux/) channel.
33+
34+
The developers use a mailing list to discuss development as well.
35+
Simply subscribe to [flux-dev on cncf.io](https://lists.cncf.io/g/cncf-flux-dev)
36+
to join the conversation (this will also add an invitation to your
37+
Google calendar for our [Flux
38+
meeting](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/edit#)).
39+
40+
### How to run the test suite
41+
42+
Prerequisites:
43+
* go >= 1.13
44+
* kubebuilder >= 2.3
45+
* kustomize >= 3.1
46+
47+
You can run the unit tests by simply doing
48+
49+
```bash
50+
make test
51+
```
52+
53+
### How to run the controller locally
54+
55+
Install flux on your test cluster:
56+
57+
```sh
58+
flux install
59+
```
60+
61+
Scale the in-cluster controller to zero:
62+
63+
```sh
64+
kubectl -n flux-system scale deployment/helm-controller --replicas=0
65+
```
66+
67+
Port forward to source-controller artifacts server:
68+
69+
```sh
70+
kubectl -n flux-system port-forward svc/source-controller 8080:80
71+
```
72+
73+
Export the local address as `SOURCE_CONTROLLER_LOCALHOST`:
74+
75+
```sh
76+
export SOURCE_CONTROLLER_LOCALHOST=localhost:8080
77+
```
78+
79+
Run the controller locally:
80+
81+
```sh
82+
make run
83+
```
84+
85+
## Acceptance policy
86+
87+
These things will make a PR more likely to be accepted:
88+
89+
- a well-described requirement
90+
- tests for new code
91+
- tests for old code!
92+
- new code and tests follow the conventions in old code and tests
93+
- a good commit message (see below)
94+
- all code must abide [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
95+
- names should abide [What's in a name](https://talks.golang.org/2014/names.slide#1)
96+
- code must build on both Linux and Darwin, via plain `go build`
97+
- code should have appropriate test coverage and tests should be written
98+
to work with `go test`
99+
100+
In general, we will merge a PR once one maintainer has endorsed it.
101+
For substantial changes, more people may become involved, and you might
102+
get asked to resubmit the PR or divide the changes into more than one PR.
103+
104+
### Format of the Commit Message
105+
106+
For Helm Controller we prefer the following rules for good commit messages:
107+
108+
- Limit the subject to 50 characters and write as the continuation
109+
of the sentence "If applied, this commit will ..."
110+
- Explain what and why in the body, if more than a trivial change;
111+
wrap it at 72 characters.
112+
113+
The [following article](https://chris.beams.io/posts/git-commit/#seven-rules)
114+
has some more helpful advice on documenting your work.

controllers/helmrelease_controller_chart.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"io/ioutil"
2424
"net/http"
25+
"net/url"
2526
"os"
2627
"strings"
2728

@@ -98,7 +99,17 @@ func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1.HelmChart) (*char
9899
defer f.Close()
99100
defer os.Remove(f.Name())
100101

101-
res, err := http.Get(source.GetArtifact().URL)
102+
artifactURL := source.GetArtifact().URL
103+
if hostname := os.Getenv("SOURCE_CONTROLLER_LOCALHOST"); hostname != "" {
104+
u, err := url.Parse(artifactURL)
105+
if err != nil {
106+
return nil, err
107+
}
108+
u.Host = hostname
109+
artifactURL = u.String()
110+
}
111+
112+
res, err := http.Get(artifactURL)
102113
if err != nil {
103114
return nil, err
104115
}

0 commit comments

Comments
 (0)