Skip to content

Commit

Permalink
bump to version 1.0.0; rephrasing and minor updates of the documentat…
Browse files Browse the repository at this point in the history
…ion and some function names
  • Loading branch information
tuunit committed May 29, 2023
1 parent 8a2b29a commit 1412b4f
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 29 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright © 2023 The Helm Compose Authors

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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Helm Compose is a tool for managing multiple releases of one or many different H
Install a specific version (recommended). Click [here](https://github.com/seacrew/helm-compose/releases/latest) for the latest version.

```
helm plugin install https://github.com/seacrew/helm-compose --version 1.0.0-beta.2
helm plugin install https://github.com/seacrew/helm-compose --version 1.0.0
```

Install the latest version.
Expand Down
2 changes: 1 addition & 1 deletion cmd/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var downCmd = &cobra.Command{
return err
}

config, err := config.ParseConfigFile(composeFile)
config, err := config.ParseComposeFile(composeFile)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var getCmd = &cobra.Command{
Use: "get [REVISION]",
Use: "get [revision]",
Short: "This command retrieves the decoded content from the revision id you specify.",
Long: ``,
Args: cobra.ExactArgs(1),
Expand All @@ -36,7 +36,7 @@ var getCmd = &cobra.Command{
return err
}

config, err := config.ParseConfigFile(composeFile)
config, err := config.ParseComposeFile(composeFile)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var listCmd = &cobra.Command{
return err
}

config, err := config.ParseConfigFile(composeFile)
config, err := config.ParseComposeFile(composeFile)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var upCmd = &cobra.Command{
return err
}

config, err := config.ParseConfigFile(composeFile)
config, err := config.ParseComposeFile(composeFile)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Get a previous revision of your `helm-compose.yaml`
The following command will return the previous `helm-compose.yaml` content on stdout.

```
helm compose get [REVISION] [flags]
helm compose get [revision] [flags]
```

## Options
Expand Down
1 change: 0 additions & 1 deletion docs/compose-file-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ releases:
| Option | Type | Description | Required | Default |
| ---------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |
| name | string | | false | |
| chart | string | Name of the chart to be used. | true | |
| chartVersion | string | Version of the chart to be used. | false | latest |
| forceUpdate | bool | Force resource updates through a replacement strategy | false | false |
Expand Down
14 changes: 9 additions & 5 deletions docs/key-features-and-use-cases.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Key Features and Use Cases

The main idea behind `helm-compose` is to control / configure all helm related options as code by providing a compose file structure to configure everything you need to setup your helm based infrastructure.

## Repository handling

Automatic installation of all necessary repositories you define as a dependency in your `helm-compose.yaml` before triggering the installation of your releases.
Configuration based installation of all necessary repositories you define as a dependency in your `helm-compose.yaml` before triggering the installation of your releases.

```yaml
apiVersion: 1.0
Expand All @@ -13,11 +15,11 @@ repositories:
## Multi release handling
The main feature of `helm-compose` is the ability to define a multitude of releases inside a single file. `helm-compose` supports single kubernetes-cluster and multi-cluster setups.
The main feature of `helm-compose` is the ability to define a multitude of releases inside a single file. `helm-compose` supports single kubernetes-cluster and multi-cluster configuration.

### Single cluster

Define as many releases as you would like for one or more namespaces. Release name have to be unique.
Define as many releases as you would like for one or more namespaces.

```yaml
apiVersion: 1.0
Expand All @@ -37,7 +39,7 @@ repositories:

### Multi cluster

You can either use the `kubeconfig` paramter to point to a different path and/or use `kubecontext` to select a specific context inside your kubeconfig.
You can either use the `kubeconfig` options to point to a different path and use the `kubecontext` to select a specific context inside your kubeconfig.

```yaml
apiVersion: 1.0
Expand All @@ -59,7 +61,9 @@ repositories:

### Environment variables

`helm-compose` allows to parse environment variables inside your values block. Syntax: `${MY_ENV_VARIABLE}`.
`helm-compose` is able to inject environment variables inside your values block to deal with secrets that shouldn't be committed to your source control.

Syntax: `${MY_ENV_VARIABLE}`.

```bash
export WORDPRESS_ADMIN_PASSWORD="xxx"
Expand Down
14 changes: 13 additions & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Install a specific version (recommended). Click [here](https://github.com/seacrew/helm-compose/releases/latest) for the latest version.

```
helm plugin install https://github.com/seacrew/helm-compose --version 1.0.0-beta.2
helm plugin install https://github.com/seacrew/helm-compose --version 1.0.0
```

Install latest version.
Expand Down Expand Up @@ -59,4 +59,16 @@ repositories:
bitnami: https://charts.bitnami.com/bitnami
```
All `helm-compose` commands accept the `-f` flag to pass your compose file location. Otherwise `helm-compose` will automatically look for a list of file names inside your current directory:

- helm-compose.yaml
- helm-compose.yml
- helmcompose.yaml
- helm-compose.yml
- helmcompose.yaml
- helmcompose.yml
- helmcompose
- compose.yaml
- compose.yml

Check out the [helm compose examples](https://github.com/seacrew/helm-compose/tree/main/examples).
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.27.2 // indirect
k8s.io/api v0.27.2
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
Expand Down
30 changes: 19 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func findComposeConfig() []string {
return files
}

func ParseConfigFile(filename string) (*Config, error) {
func ParseComposeFile(filename string) (*Config, error) {
var files []string
if filename == "" {
files = findComposeConfig()
Expand All @@ -73,48 +73,56 @@ func ParseConfigFile(filename string) (*Config, error) {
data = append(data, b...)
}

return parseConfig(data)
return parseComposeData(data)
} else if _, err := os.Stat(filename); err != nil {
return nil, fmt.Errorf("provided configuration file not found")
return nil, fmt.Errorf("provided compose file not found")
} else {
files = []string{filename}
}

if len(files) == 0 {
return nil, fmt.Errorf("no configuration file found")
return nil, fmt.Errorf("no compose file found")
}

if len(files) > 1 {
return nil, fmt.Errorf("expects only one configuration file but found multiple: %v", files)
return nil, fmt.Errorf("expected only one compose file but found multiple: %v", files)
}

file, err := os.ReadFile(files[0])
if err != nil {
return nil, err
}

return parseConfig(file)
return parseComposeData(file)
}

func parseConfig(data []byte) (*Config, error) {
func parseComposeData(data []byte) (*Config, error) {
config := Config{}
err := yaml.Unmarshal(data, &config)
if err != nil {
return nil, err
}

if err := ValidateCompose(&config); err != nil {
return nil, err
}

return &config, nil
}

func ValidateCompose(config *Config) error {
if config.Version == "" {
return nil, fmt.Errorf("missing apiVersion in config")
return fmt.Errorf("missing apiVersion in config")
}

version, err := semver.NewVersion(config.Version)
if err != nil {
return nil, fmt.Errorf("failed to parse apiVersion: %s", config.Version)
return fmt.Errorf("failed to parse apiVersion: %s", config.Version)
}

if semver.MustParse("1.0").GreaterThan(version) {
return nil, fmt.Errorf("helm compose requires at least apiVersion 1.0 but got %s", config.Version)
return fmt.Errorf("helm compose requires at least apiVersion 1.0 but got %s", config.Version)
}

return &config, nil
return nil
}
2 changes: 1 addition & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestParseSimpleConfig(t *testing.T) {
config, err := ParseConfigFile("../../examples/simple-compose.yaml")
config, err := ParseComposeFile("../../examples/simple-compose.yaml")

if err != nil {
log.Fatal(err)
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func Load(config *cfg.Config) (*cfg.Config, error) {
return nil, err
}

if err := cfg.ValidateCompose(prevConfig); err != nil {
return nil, fmt.Errorf("couldn't load previous revision %s", err.Error())
}

return prevConfig, nil
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: compose
version: 1.0.0-beta.2
version: 1.0.0
usage: Compose is a helm plugin to define and manage multiple helm releases as single entity.
command: $HELM_PLUGIN_DIR/bin/compose
hooks:
Expand Down

0 comments on commit 1412b4f

Please sign in to comment.