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

API version bump to v1 and group domain change #7

Merged
merged 5 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
jobs:
build:
working_directory: /home/circleci/go/src/github.com/weaveworks/flux
working_directory: /home/circleci/go/src/github.com/fluxcd/helm-operator
machine:
image: ubuntu-1604:201903-01
environment:
Expand All @@ -20,6 +20,7 @@ jobs:
sudo rm -rf /usr/local/go
sudo mv go /usr/local
mkdir -p "$HOME/go/bin"
rm -rf go${GO_VERSION}.linux-amd64.tar.gz
go version
- run:
name: Update packages
Expand Down Expand Up @@ -68,13 +69,6 @@ jobs:
name: Maybe push prerelease images
command: |
if [ -z "${CIRCLE_TAG}" -a "${CIRCLE_BRANCH}" == "master" ]; then
# Push to weaveworks org
echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin

docker tag "docker.io/fluxcd/helm-operator:$(docker/image-tag)" "docker.io/weaveworks/helm-operator-prerelease:$(docker/image-tag)"
docker push "docker.io/weaveworks/helm-operator-prerelease:$(docker/image-tag)"

# Push to fluxcd org
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin

docker tag "docker.io/fluxcd/helm-operator:$(docker/image-tag)" "docker.io/fluxcd/helm-operator-prerelease:$(docker/image-tag)"
Expand All @@ -84,12 +78,6 @@ jobs:
name: Maybe push release image
command: |
if echo "${CIRCLE_TAG}" | grep -Eq "^[0-9]+(\.[0-9]+)*(-[a-z]+)?$"; then
# Push to weaveworks org
echo "$DOCKER_REGISTRY_PASSWORD" | docker login --username "$DOCKER_REGISTRY_USER" --password-stdin
docker tag "docker.io/fluxcd/helm-operator:${CIRCLE_TAG}" "docker.io/weaveworks/helm-operator:${CIRCLE_TAG}"
docker push "docker.io/weaveworks/helm-operator:${CIRCLE_TAG}"

# Push to fluxcd org
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin
docker push "docker.io/fluxcd/helm-operator:${CIRCLE_TAG}"
fi
Expand Down
4 changes: 2 additions & 2 deletions chart/helm-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Install podinfo by referring to its Helm repository:

```sh
cat <<EOF | kubectl apply -f -
apiVersion: flux.weave.works/v1beta1
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: podinfo
Expand Down Expand Up @@ -119,7 +119,7 @@ helm -i helm-operator fluxcd/helm-operator \
You can refer to a chart from your private Git with:

```yaml
apiVersion: flux.weave.works/v1beta1
apiVersion: helm.fluxcd.io
kind: HelmRelease
metadata:
name: some-app
Expand Down
8 changes: 4 additions & 4 deletions chart/helm-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: helmreleases.flux.weave.works
name: helmreleases.helm.fluxcd.io
labels:
app: {{ template "helm-operator.name" . }}
chart: {{ template "helm-operator.chart" . }}
Expand All @@ -12,7 +12,7 @@ metadata:
annotations:
"helm.sh/resource-policy": keep
spec:
group: flux.weave.works
group: helm.fluxcd.io
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
names:
kind: HelmRelease
listKind: HelmReleaseList
Expand All @@ -22,9 +22,9 @@ spec:
scope: Namespaced
subresources:
status: {}
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
validation:
Expand Down
10 changes: 5 additions & 5 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func main() {
// setup shared informer for HelmReleases
nsOpt := ifinformers.WithNamespace(*namespace)
ifInformerFactory := ifinformers.NewSharedInformerFactoryWithOptions(ifClient, *chartsSyncInterval, nsOpt)
fhrInformer := ifInformerFactory.Flux().V1beta1().HelmReleases()
hrInformer := ifInformerFactory.Helm().V1().HelmReleases()

// setup workqueue for HelmReleases
queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "ChartRelease")
Expand All @@ -195,7 +195,7 @@ func main() {
rel := release.New(log.With(logger, "component", "release"), helmClient)
chartSync := chartsync.New(
log.With(logger, "component", "chartsync"),
chartsync.Clients{KubeClient: *kubeClient, IfClient: *ifClient, FhrLister: fhrInformer.Lister()},
chartsync.Clients{KubeClient: *kubeClient, IfClient: *ifClient, HrLister: hrInformer.Lister()},
rel,
queue,
chartsync.Config{LogDiffs: *logReleaseDiffs, UpdateDeps: *updateDependencies, GitTimeout: *gitTimeout, GitPollInterval: *gitPollInterval},
Expand All @@ -206,12 +206,12 @@ func main() {
// NB: the operator needs to do its magic with the informer
// _before_ starting it or else the cache sync seems to hang at
// random
opr := operator.New(log.With(logger, "component", "operator"), *logReleaseDiffs, kubeClient, fhrInformer, queue, chartSync)
opr := operator.New(log.With(logger, "component", "operator"), *logReleaseDiffs, kubeClient, hrInformer, queue, chartSync)
go ifInformerFactory.Start(shutdown)

// wait for the caches to be synced before starting _any_ workers
mainLogger.Log("info", "waiting for informer caches to sync")
if ok := cache.WaitForCacheSync(shutdown, fhrInformer.Informer().HasSynced); !ok {
if ok := cache.WaitForCacheSync(shutdown, hrInformer.Informer().HasSynced); !ok {
mainLogger.Log("error", "failed to wait for caches to sync")
os.Exit(1)
}
Expand All @@ -225,7 +225,7 @@ func main() {

// the status updater, to keep track of the release status for
// every HelmRelease
statusUpdater := status.New(ifClient, fhrInformer.Lister(), helmClient)
statusUpdater := status.New(ifClient, hrInformer.Lister(), helmClient)
go statusUpdater.Loop(shutdown, log.With(logger, "component", "statusupdater"))

// start HTTP server
Expand Down
8 changes: 4 additions & 4 deletions deploy/flux-helm-release-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: helmreleases.flux.weave.works
name: helmreleases.helm.fluxcd.io
spec:
group: flux.weave.works
group: helm.fluxcd.io
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
names:
kind: HelmRelease
listKind: HelmReleaseList
Expand All @@ -14,9 +14,9 @@ spec:
scope: Namespaced
subresources:
status: {}
version: v1beta1
version: v1
versions:
- name: v1beta1
- name: v1
served: true
storage: true
validation:
Expand Down
6 changes: 3 additions & 3 deletions docs/references/helmrelease-custom-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource definition](https://github.com/fluxcd/flux/blob/master/deploy-helm/flux
look like this:

```yaml
apiVersion: flux.weave.works/v1beta1
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: rabbit
Expand Down Expand Up @@ -103,7 +103,7 @@ values.yaml`, but inlined into the `HelmRelease` manifest. For
example,

```yaml
apiVersion: flux.weave.works/v1beta1
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
# metadata: ...
spec:
Expand Down Expand Up @@ -211,7 +211,7 @@ detects a change in values and/or the chart.
### Configuration

```yaml
apiVersion: flux.weave.works/v1beta1
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
# metadata: ...
spec:
Expand Down
2 changes: 1 addition & 1 deletion hack/custom-boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2018 Weaveworks Ltd.
Copyright 2018-2019 The Flux CD contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh
# :magic:
${CODEGEN_PKG}/generate-groups.sh all \
github.com/fluxcd/helm-operator/pkg/client github.com/fluxcd/helm-operator/pkg/apis \
"flux.weave.works:v1beta1 helm.integrations.flux.weave.works:v1alpha2" \
"helm.fluxcd.io:v1" \
--output-base "${TEMP_DIR}" \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt"

Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/flux.weave.works/register.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/apis/flux.weave.works/v1beta1/doc.go

This file was deleted.

5 changes: 5 additions & 0 deletions pkg/apis/helm.fluxcd.io/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package helm

const (
GroupName = "helm.fluxcd.io"
)
5 changes: 5 additions & 0 deletions pkg/apis/helm.fluxcd.io/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// +k8s:deepcopy-gen=package,register
// +groupName=helm.fluxcd.io
// Package v1 is the v1 version of the API. The prior
// version was flux.weave.works/v1beta1.
package v1
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package v1beta1
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

fluxintegrations "github.com/fluxcd/helm-operator/pkg/apis/flux.weave.works"
"github.com/fluxcd/helm-operator/pkg/apis/helm.fluxcd.io"
)

const Version = "v1"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: fluxintegrations.GroupName, Version: "v1beta1"}
var SchemeGroupVersion = schema.GroupVersion{Group: helm.GroupName, Version: Version}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package v1beta1
package v1

import (
"fmt"
"strings"

"github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/helm/pkg/chartutil"

Expand All @@ -27,46 +27,46 @@ type HelmRelease struct {
// ResourceID returns an ID made from the identifying parts of the
// resource, as a convenience for Flux, which uses them
// everywhere.
func (fhr HelmRelease) ResourceID() resource.ID {
return resource.MakeID(fhr.Namespace, "HelmRelease", fhr.Name)
func (hr HelmRelease) ResourceID() resource.ID {
return resource.MakeID(hr.Namespace, "HelmRelease", hr.Name)
}

// ReleaseName returns the configured release name, or constructs and
// returns one based on the namespace and name of the HelmRelease.
// When the HelmRelease's metadata.namespace and spec.targetNamespace
// differ, both are used in the generated name.
// This name is used for naming and operating on the release in Helm.
func (fhr HelmRelease) ReleaseName() string {
if fhr.Spec.ReleaseName == "" {
namespace := fhr.GetDefaultedNamespace()
targetNamespace := fhr.GetTargetNamespace()
func (hr HelmRelease) ReleaseName() string {
if hr.Spec.ReleaseName == "" {
namespace := hr.GetDefaultedNamespace()
targetNamespace := hr.GetTargetNamespace()

if namespace != targetNamespace {
// prefix the releaseName with the administering HelmRelease namespace as well
return fmt.Sprintf("%s-%s-%s", namespace, targetNamespace, fhr.Name)
return fmt.Sprintf("%s-%s-%s", namespace, targetNamespace, hr.Name)
}
return fmt.Sprintf("%s-%s", targetNamespace, fhr.Name)
return fmt.Sprintf("%s-%s", targetNamespace, hr.Name)
}

return fhr.Spec.ReleaseName
return hr.Spec.ReleaseName
}

// GetDefaultedNamespace returns the HelmRelease's namespace
// defaulting to the "default" if not set.
func (fhr HelmRelease) GetDefaultedNamespace() string {
if fhr.GetNamespace() == "" {
func (hr HelmRelease) GetDefaultedNamespace() string {
if hr.GetNamespace() == "" {
return "default"
}
return fhr.Namespace
return hr.Namespace
}

// GetTargetNamespace returns the configured release targetNamespace
// defaulting to the namespace of the HelmRelease if not set.
func (fhr HelmRelease) GetTargetNamespace() string {
if fhr.Spec.TargetNamespace == "" {
return fhr.GetDefaultedNamespace()
func (hr HelmRelease) GetTargetNamespace() string {
if hr.Spec.TargetNamespace == "" {
return hr.GetDefaultedNamespace()
}
return fhr.Spec.TargetNamespace
return hr.Spec.TargetNamespace
}

// ValuesFromSource represents a source of values.
Expand Down Expand Up @@ -184,21 +184,21 @@ type HelmReleaseSpec struct {
}

// GetTimeout returns the install or upgrade timeout (defaults to 300s)
func (r HelmRelease) GetTimeout() int64 {
if r.Spec.Timeout == nil {
func (hr HelmRelease) GetTimeout() int64 {
if hr.Spec.Timeout == nil {
return 300
}
return *r.Spec.Timeout
return *hr.Spec.Timeout
}

// GetValuesFromSources maintains backwards compatibility with
// ValueFileSecrets by merging them into the ValuesFrom array.
func (r HelmRelease) GetValuesFromSources() []ValuesFromSource {
valuesFrom := r.Spec.ValuesFrom
func (hr HelmRelease) GetValuesFromSources() []ValuesFromSource {
valuesFrom := hr.Spec.ValuesFrom
// Maintain backwards compatibility with ValueFileSecrets
if r.Spec.ValueFileSecrets != nil {
if hr.Spec.ValueFileSecrets != nil {
var secretKeyRefs []ValuesFromSource
for _, ref := range r.Spec.ValueFileSecrets {
for _, ref := range hr.Spec.ValueFileSecrets {
s := &v1.SecretKeySelector{LocalObjectReference: ref}
secretKeyRefs = append(secretKeyRefs, ValuesFromSource{SecretKeyRef: s})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1beta1
package v1

import (
"testing"
Expand Down
Loading