Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
chore: review changes
Browse files Browse the repository at this point in the history
Incorporated changes from review. Changed the mirror name to be and
composite key comprising namespace, auth secret name and git url.
  • Loading branch information
richardcase committed Jan 21, 2020
1 parent c393509 commit 4d5424c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
clientset "github.com/fluxcd/helm-operator/pkg/client/clientset/versioned"
ifinformers "github.com/fluxcd/helm-operator/pkg/client/informers/externalversions"
"github.com/fluxcd/helm-operator/pkg/helm"
v2 "github.com/fluxcd/helm-operator/pkg/helm/v2"
v3 "github.com/fluxcd/helm-operator/pkg/helm/v3"
"github.com/fluxcd/helm-operator/pkg/helm/v2"
"github.com/fluxcd/helm-operator/pkg/helm/v3"
daemonhttp "github.com/fluxcd/helm-operator/pkg/http/daemon"
"github.com/fluxcd/helm-operator/pkg/operator"
"github.com/fluxcd/helm-operator/pkg/release"
Expand Down
11 changes: 5 additions & 6 deletions pkg/apis/helm.fluxcd.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/ghodss/yaml"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/fluxcd/helm-operator/pkg/helm"
Expand All @@ -19,7 +18,7 @@ import (
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// FluxHelmRelease represents custom resource associated with a Helm Chart
// HelmRelease represents custom resource associated with a Helm Chart
type HelmRelease struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Expand Down Expand Up @@ -113,10 +112,10 @@ type ChartSource struct {
}

type GitChartSource struct {
GitURL string `json:"git"`
Ref string `json:"ref"`
Path string `json:"path"`
SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
GitURL string `json:"git"`
Ref string `json:"ref"`
Path string `json:"path"`
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
// Do not run 'dep' update (assume requirements.yaml is already fulfilled)
// +optional
SkipDepUpdate bool `json:"skipDepUpdate,omitempty"`
Expand Down
18 changes: 10 additions & 8 deletions pkg/chartsync/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,11 @@ func (c *GitChartSync) sync(hr *v1.HelmRelease, mirrorName string, repo *git.Rep
// `false` otherwise).
func (c *GitChartSync) maybeMirror(mirrorName string, source *v1.GitChartSource, namespace string) bool {
gitURL := source.GitURL
if source.SecretRef != nil {
ammendURL, err := c.addAuthForHTTPS(gitURL, source.SecretRef, namespace)
if err != nil {
c.logger.Log("error", GitAuthError{err}.Error(), "err", err)
return false
}
gitURL = ammendURL
var err error

if gitURL, err = c.addAuthForHTTPS(gitURL, source.SecretRef, namespace); err != nil {
c.logger.Log("error", GitAuthError{err}.Error())
return false
}

ok := c.mirrors.Mirror(
Expand Down Expand Up @@ -334,7 +332,11 @@ func (c *GitChartSync) helmReleasesForMirror(mirror string) ([]*v1.HelmRelease,
// per namespace, per auth.
func mirrorName(hr *v1.HelmRelease) string {
if hr != nil && hr.Spec.GitChartSource != nil {
return hr.Spec.GitURL
secretName := "noauth"
if hr.Spec.GitChartSource.SecretRef != nil {
secretName = hr.Spec.GitChartSource.SecretRef.Name
}
return fmt.Sprintf("%s/%s/%s", hr.GetNamespace(), secretName, hr.Spec.GitURL)
}
return ""
}
Expand Down

0 comments on commit 4d5424c

Please sign in to comment.