Skip to content

Commit

Permalink
Issue argoproj#747 - Declaratively add helm repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Matyushentsev authored and Alexander Matyushentsev committed Dec 3, 2018
1 parent 246392f commit bc58d37
Show file tree
Hide file tree
Showing 22 changed files with 998 additions and 355 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,4 @@ COPY --from=argocd-build /go/src/github.com/argoproj/argo-cd/dist/* /usr/local/b

USER argocd

RUN helm init --client-only

WORKDIR /home/argocd
19 changes: 18 additions & 1 deletion controller/appcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,26 @@ func newFakeController(data *fakeData) *ApplicationController {
mockRepoClientset := mockreposerver.Clientset{}
mockRepoClientset.On("NewRepositoryClient").Return(&fakeCloser{}, &mockRepoClient, nil)

secret := corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-secret",
Namespace: test.FakeArgoCDNamespace,
},
Data: map[string][]byte{
"admin.password": []byte("test"),
"server.secretkey": []byte("test"),
},
}
cm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-cm",
Namespace: test.FakeArgoCDNamespace,
},
Data: nil,
}
ctrl := NewApplicationController(
test.FakeArgoCDNamespace,
fake.NewSimpleClientset(&clust),
fake.NewSimpleClientset(&clust, &cm, &secret),
appclientset.NewSimpleClientset(data.apps...),
&mockRepoClientset,
time.Minute,
Expand Down
5 changes: 5 additions & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ type appStateManager struct {
}

func (m *appStateManager) GetTargetObjs(app *v1alpha1.Application, revision string, overrides []v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, *repository.ManifestResponse, error) {
helmRepos, err := m.db.ListHelmRepos(context.Background())
if err != nil {
return nil, nil, err
}
repo := m.getRepo(app.Spec.Source.RepoURL)
conn, repoClient, err := m.repoClientset.NewRepositoryClient()
if err != nil {
Expand Down Expand Up @@ -97,6 +101,7 @@ func (m *appStateManager) GetTargetObjs(app *v1alpha1.Application, revision stri

manifestInfo, err := repoClient.GenerateManifest(context.Background(), &repository.ManifestRequest{
Repo: repo,
HelmRepos: helmRepos,
Revision: revision,
ComponentParameterOverrides: mfReqOverrides,
AppLabel: app.Name,
Expand Down
4 changes: 2 additions & 2 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestCompareAppStateExtra(t *testing.T) {
pod := test.NewPod()
pod.SetNamespace(test.FakeDestNamespace)
app := newFakeApp()
key := kube.ResourceKey{"", "Pod", test.FakeDestNamespace, app.Name}
key := kube.ResourceKey{Group: "", Kind: "Pod", Namespace: test.FakeDestNamespace, Name: app.Name}
data := fakeData{
manifestResponse: &repository.ManifestResponse{
Manifests: []string{},
Expand Down Expand Up @@ -124,7 +124,7 @@ func TestCompareAppStateExtraHook(t *testing.T) {
pod.SetAnnotations(map[string]string{common.AnnotationKeyHook: "PreSync"})
pod.SetNamespace(test.FakeDestNamespace)
app := newFakeApp()
key := kube.ResourceKey{"", "Pod", test.FakeDestNamespace, app.Name}
key := kube.ResourceKey{Group: "", Kind: "Pod", Namespace: test.FakeDestNamespace, Name: app.Name}
data := fakeData{
manifestResponse: &repository.ManifestResponse{
Manifests: []string{},
Expand Down
795 changes: 554 additions & 241 deletions pkg/apis/application/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pkg/apis/application/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ type TLSClientConfig struct {
CAData []byte `json:"caData,omitempty" protobuf:"bytes,5,opt,name=caData"`
}

type HelmRepository struct {
URL string `json:"url" protobuf:"bytes,1,opt,name=url"`
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
CAData []byte `json:"caData,omitempty" protobuf:"bytes,3,opt,name=caData"`
CertData []byte `json:"certData,omitempty" protobuf:"bytes,4,opt,name=certData"`
KeyData []byte `json:"keyData,omitempty" protobuf:"bytes,5,opt,name=keyData"`
}

// Repository is a Git repository holding application configurations
type Repository struct {
Repo string `json:"repo" protobuf:"bytes,1,opt,name=repo"`
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/application/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,37 @@ func (in *HealthStatus) DeepCopy() *HealthStatus {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmRepository) DeepCopyInto(out *HelmRepository) {
*out = *in
if in.CAData != nil {
in, out := &in.CAData, &out.CAData
*out = make([]byte, len(*in))
copy(*out, *in)
}
if in.CertData != nil {
in, out := &in.CertData, &out.CertData
*out = make([]byte, len(*in))
copy(*out, *in)
}
if in.KeyData != nil {
in, out := &in.KeyData, &out.KeyData
*out = make([]byte, len(*in))
copy(*out, *in)
}
return
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmRepository.
func (in *HelmRepository) DeepCopy() *HelmRepository {
if in == nil {
return nil
}
out := new(HelmRepository)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HookStatus) DeepCopyInto(out *HookStatus) {
*out = *in
Expand Down
6 changes: 5 additions & 1 deletion reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ func generateManifests(appPath string, q *ManifestRequest) (*ManifestResponse, e
env := v1alpha1.KsonnetEnv(q.ApplicationSource)
targetObjs, params, dest, err = ksShow(appPath, env, q.ComponentParameterOverrides)
case v1alpha1.ApplicationSourceTypeHelm:
h := helm.NewHelmApp(appPath)
h := helm.NewHelmApp(appPath, q.HelmRepos)
err := h.Init()
if err != nil {
return nil, err
}
opts := helmOpts(q)
targetObjs, err = h.Template(q.AppLabel, opts, q.ComponentParameterOverrides)
if err != nil {
Expand Down
147 changes: 103 additions & 44 deletions reposerver/repository/repository.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions reposerver/repository/repository.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ message ManifestRequest {
repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComponentParameter componentParameterOverrides = 6;
string namespace = 8;
github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSource applicationSource = 10;
repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.HelmRepository helmRepos = 11;
}

message ManifestResponse {
Expand Down
Loading

0 comments on commit bc58d37

Please sign in to comment.