This repository was archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for FHRs with simplest image format
This commit adds support for interpreting `FluxHelmRelease`s with a single image, provided in the field `Spec.Values.Image` -- i.e., the simplest of many different ways of providing image refs to a chart. The manifest update mechanism is stubbed out for now.
- Loading branch information
Showing
7 changed files
with
159 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package resource | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/weaveworks/flux" | ||
ifv1 "github.com/weaveworks/flux/apis/helm.integrations.flux.weave.works/v1alpha2" | ||
"github.com/weaveworks/flux/image" | ||
"github.com/weaveworks/flux/resource" | ||
apiv1 "k8s.io/api/core/v1" | ||
) | ||
|
||
type FluxHelmRelease struct { | ||
baseObject | ||
Spec ifv1.FluxHelmReleaseSpec | ||
} | ||
|
||
func (fhr FluxHelmRelease) Containers() []resource.Container { | ||
containers, err := fhr.createFluxFHRContainers() | ||
if err != nil { | ||
// log ? | ||
} | ||
return containers | ||
} | ||
|
||
// CreateK8sContainers creates a list of k8s containers as | ||
func CreateK8sFHRContainers(spec ifv1.FluxHelmReleaseSpec) []apiv1.Container { | ||
containers := []apiv1.Container{} | ||
|
||
values := spec.Values | ||
if len(values) == 0 { | ||
return containers | ||
} | ||
|
||
imgInfo, ok := values["image"] | ||
|
||
// image info appears on the top level, so is associated directly with the chart | ||
if ok { | ||
imgInfoStr, ok := imgInfo.(string) | ||
if !ok { | ||
return containers | ||
} | ||
|
||
cont := apiv1.Container{Name: spec.ChartGitPath, Image: imgInfoStr} | ||
containers = append(containers, cont) | ||
|
||
return containers | ||
} | ||
|
||
return []apiv1.Container{} | ||
} | ||
|
||
func TryFHRUpdate(def []byte, resourceID flux.ResourceID, container string, newImage image.Ref, out io.Writer) error { | ||
fmt.Println("FAKE Updating image tag info for FHR special") | ||
fmt.Println("=========================================") | ||
fmt.Println("\t\t*** in tryFHRUpdate") | ||
fmt.Printf("\t\t*** container: %s\n", container) | ||
fmt.Printf("\t\t*** newImage: %+v\n", newImage) | ||
|
||
fmt.Println("Updating image tag info for FHR special") | ||
fmt.Println("=========================================") | ||
|
||
return nil | ||
} | ||
|
||
// assumes only one image in the Spec.Values | ||
func (fhr FluxHelmRelease) createFluxFHRContainers() ([]resource.Container, error) { | ||
values := fhr.Spec.Values | ||
containers := []resource.Container{} | ||
|
||
if len(values) == 0 { | ||
return containers, nil | ||
} | ||
|
||
imgInfo, ok := values["image"] | ||
|
||
// image info appears on the top level, so is associated directly with the chart | ||
if ok { | ||
imgInfoStr := imgInfo.(string) | ||
imageRef, err := image.ParseRef(imgInfoStr) | ||
if err != nil { | ||
return containers, err | ||
} | ||
containers = append(containers, resource.Container{Name: fhr.Spec.ChartGitPath, Image: imageRef}) | ||
return containers, nil | ||
} | ||
|
||
return []resource.Container{}, nil | ||
} |
This file contains 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 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 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 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 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