Skip to content

Commit

Permalink
Merge branch 'main' into add-helm-manifest-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Trojan295 authored Aug 24, 2021
2 parents 97bc62a + c1001fc commit 2c0b807
Show file tree
Hide file tree
Showing 28 changed files with 372 additions and 157 deletions.
2 changes: 1 addition & 1 deletion cmd/cli/cmd/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var argoHiddenFlags = []string{
func NewCmd() *cobra.Command {
root := &cobra.Command{
Use: "action",
Aliases: []string{"act"},
Aliases: []string{"act", "actions"},
Short: "This command consists of multiple subcommands to interact with target Actions",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import "github.com/spf13/cobra"
// NewCmd returns a cobra.Command for Implementation manifest generation operations.
func NewCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "implementation",
Short: "Generate new Implementation manifests",
Long: "Generate new Implementation manifests for various tools.",
Use: "implementation",
Aliases: []string{"impl", "implementations"},
Short: "Generate new Implementation manifests",
Long: "Generate new Implementation manifests for various tools.",
}

cmd.AddCommand(NewTerraform())
Expand Down
7 changes: 4 additions & 3 deletions cmd/cli/cmd/alpha/manifest-gen/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ var interfaceCfg manifestgen.InterfaceConfig
// NewInterface returns a cobra.Command to bootstrap new Interface manifests.
func NewInterface() *cobra.Command {
cmd := &cobra.Command{
Use: "interface [PATH]",
Short: "Generate new Interface-related manifests",
Long: "Generate new InterfaceGroup, Interface and associated Type manifests",
Use: "interface [PATH]",
Aliases: []string{"iface", "interfaces"},
Short: "Generate new Interface-related manifests",
Long: "Generate new InterfaceGroup, Interface and associated Type manifests",
Example: heredoc.WithCLIName(`
# Generate manifests for the cap.interface.database.postgresql.install Interface
<cli> alpha content interface cap.interface.database.postgresql install`, cli.Name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
// NewImplementations returns a cobra.Command for Hub Implementation related operations.
func NewImplementations() *cobra.Command {
cmd := &cobra.Command{
Use: "implementations",
Aliases: []string{"impl"},
Use: "implementation",
Aliases: []string{"impl", "implementations"},
Short: "This command consists of multiple subcommands to interact with Implementations stored on the Hub server",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
// NewInterfaces returns a cobra.Command for Hub Interfaces related operations.
func NewInterfaces() *cobra.Command {
cmd := &cobra.Command{
Use: "interfaces",
Short: "This command consists of multiple subcommands to interact with Interfaces stored on the Hub server",
Use: "interface",
Aliases: []string{"iface", "interfaces"},
Short: "This command consists of multiple subcommands to interact with Interfaces stored on the Hub server",
}

cmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cmd/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "github.com/spf13/cobra"
func NewCmd() *cobra.Command {
root := &cobra.Command{
Use: "manifest",
Aliases: []string{"mf"},
Aliases: []string{"mf", "manifests"},
Short: "This command consists of multiple subcommands to interact with OCF manifests",
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cmd/typeinstance/type_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
func NewCmd() *cobra.Command {
root := &cobra.Command{
Use: "typeinstance",
Aliases: []string{"ti", "TypeInstance"},
Aliases: []string{"ti", "TypeInstance", "typeinstances"},
Short: "This command consists of multiple subcommands to interact with target TypeInstances",
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/docs/capact_hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ This command consists of multiple subcommands to interact with Hub server.
### SEE ALSO

* [capact](capact.md) - Collective Capability Manager CLI
* [capact hub implementations](capact_hub_implementations.md) - This command consists of multiple subcommands to interact with Implementations stored on the Hub server
* [capact hub interfaces](capact_hub_interfaces.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server
* [capact hub implementation](capact_hub_implementation.md) - This command consists of multiple subcommands to interact with Implementations stored on the Hub server
* [capact hub interface](capact_hub_interface.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: capact hub implementations
title: capact hub implementation
---

## capact hub implementations
## capact hub implementation

This command consists of multiple subcommands to interact with Implementations stored on the Hub server

### Options

```
-h, --help help for implementations
-h, --help help for implementation
```

### Options inherited from parent commands
Expand All @@ -21,5 +21,5 @@ This command consists of multiple subcommands to interact with Implementations s
### SEE ALSO

* [capact hub](capact_hub.md) - This command consists of multiple subcommands to interact with Hub server.
* [capact hub implementations get](capact_hub_implementations_get.md) - Displays one or multiple Implementations available on the Hub server
* [capact hub implementation get](capact_hub_implementation_get.md) - Displays one or multiple Implementations available on the Hub server

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: capact hub implementations get
title: capact hub implementation get
---

## capact hub implementations get
## capact hub implementation get

Displays one or multiple Implementations available on the Hub server

```
capact hub implementations get [flags]
capact hub implementation get [flags]
```

### Examples
Expand Down Expand Up @@ -37,5 +37,5 @@ capact hub implementations get cap.interface.database.postgresql.install -oyaml

### SEE ALSO

* [capact hub implementations](capact_hub_implementations.md) - This command consists of multiple subcommands to interact with Implementations stored on the Hub server
* [capact hub implementation](capact_hub_implementation.md) - This command consists of multiple subcommands to interact with Implementations stored on the Hub server

26 changes: 26 additions & 0 deletions cmd/cli/docs/capact_hub_interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: capact hub interface
---

## capact hub interface

This command consists of multiple subcommands to interact with Interfaces stored on the Hub server

### Options

```
-h, --help help for interface
```

### Options inherited from parent commands

```
-c, --config string Path to the YAML config file
```

### SEE ALSO

* [capact hub](capact_hub.md) - This command consists of multiple subcommands to interact with Hub server.
* [capact hub interface browse](capact_hub_interface_browse.md) - Browse provides the ability to browse through the available OCF Interfaces in interactive mode. Optionally create a Target Action.
* [capact hub interface get](capact_hub_interface_get.md) - Displays one or multiple Interfaces available on the Hub server

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: capact hub interfaces browse
title: capact hub interface browse
---

## capact hub interfaces browse
## capact hub interface browse

Browse provides the ability to browse through the available OCF Interfaces in interactive mode. Optionally create a Target Action.

```
capact hub interfaces browse [flags]
capact hub interface browse [flags]
```

### Examples
Expand All @@ -34,5 +34,5 @@ capact hub interfaces browse [flags]

### SEE ALSO

* [capact hub interfaces](capact_hub_interfaces.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server
* [capact hub interface](capact_hub_interface.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: capact hub interfaces get
title: capact hub interface get
---

## capact hub interfaces get
## capact hub interface get

Displays one or multiple Interfaces available on the Hub server

```
capact hub interfaces get [flags]
capact hub interface get [flags]
```

### Examples
Expand Down Expand Up @@ -37,5 +37,5 @@ capact hub interfaces get cap.interface.database.postgresql.install -ojson

### SEE ALSO

* [capact hub interfaces](capact_hub_interfaces.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server
* [capact hub interface](capact_hub_interface.md) - This command consists of multiple subcommands to interact with Interfaces stored on the Hub server

26 changes: 0 additions & 26 deletions cmd/cli/docs/capact_hub_interfaces.md

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/populator/cmd/register/ocf_manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func runDBPopulate(ctx context.Context, src string) (err error) {
log.Info("Populated new data", zap.Duration("duration (seconds)", end.Sub(start)))
}
return nil
}, retry.Attempts(3), retry.Delay(1*time.Minute))
}, retry.Attempts(6), retry.Delay(30*time.Second))
if err != nil {
return errors.Wrap(err, "while populating manifests")
}
Expand Down
5 changes: 3 additions & 2 deletions deploy/kubernetes/charts/argo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ argo-workflows:
key: secret-key

minio:
forceNewKeys: true

podSecurityContext:
enabled: false
service:
Expand All @@ -35,6 +33,9 @@ minio:
memory: 1Gi
cpu: 500m

volumePermissions:
enabled: true

deployment:
updateStrategy:
type: RollingUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
# image: "{{ .Values.global.containerRegistry.path }}/{{ .Values.image.name }}:{{ .Values.global.containerRegistry.overrideTag | default .Chart.AppVersion }}"
# Use PR image
image: "ghcr.io/capactio/pr/k8s-engine:PR-424"
image: "{{ .Values.global.containerRegistry.path }}/{{ .Values.image.name }}:{{ .Values.global.containerRegistry.overrideTag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: APP_GRAPH_QL_ADDR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ spec:
serviceAccountName: "{{ include "capact.fullname" . }}-test-e2e"
containers:
- name: tests-runner
# image: "{{ .Values.global.containerRegistry.path }}/{{ .Values.integrationTest.image.name }}:{{ .Values.global.containerRegistry.overrideTag | default .Chart.AppVersion }}"
# Use PR image
image: "ghcr.io/capactio/pr/e2e-test:PR-424"
image: "{{ .Values.global.containerRegistry.path }}/{{ .Values.integrationTest.image.name }}:{{ .Values.global.containerRegistry.overrideTag | default .Chart.AppVersion }}"
env:
- name: STATUS_ENDPOINTS
value: "http://capact-engine-graphql.{{.Release.Namespace}}.svc.cluster.local/healthz,http://capact-gateway.{{.Release.Namespace}}.svc.cluster.local/healthz,http://capact-hub-local.{{.Release.Namespace}}.svc.cluster.local/healthz,http://capact-hub-public.{{.Release.Namespace}}.svc.cluster.local/healthz"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd
github.com/Masterminds/goutils v1.1.1
github.com/Masterminds/semver/v3 v3.1.1
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/alecthomas/jsonschema v0.0.0-20210526225647-edb03dcab7bc
Expand Down
85 changes: 84 additions & 1 deletion internal/cli/capact/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

tools "capact.io/capact/internal"
"capact.io/capact/internal/ptr"
util "github.com/Masterminds/goutils"
"k8s.io/utils/strings/slices"
)

Expand Down Expand Up @@ -320,11 +321,93 @@ func (n *Neo4j) InstallUpgrade(ctx context.Context, version string) (*release.Re
func (a *Argo) InstallUpgrade(ctx context.Context, version string) (*release.Release, error) {
upgradeCli := a.upgradeAction(version)

values := tools.MergeMaps(map[string]interface{}{}, a.Overrides)
values := make(map[string]interface{})

installed, err := a.isInstalled()
if err != nil {
return nil, errors.Wrap(err, "while getting Argo Helm release")
}

if !installed && !a.areMinioCredentialsProvided(a.Overrides) {
accessKey, err := util.CryptoRandomAlphaNumeric(10)
if err != nil {
return nil, errors.Wrap(err, "while generating accessKey")
}
secretKey, err := util.CryptoRandomAlphaNumeric(40)
if err != nil {
return nil, errors.Wrap(err, "while generating secretKey")
}

credentials := map[string]interface{}{
"minio": map[string]interface{}{
"accessKey": map[string]interface{}{
"password": accessKey,
},
"secretKey": map[string]interface{}{
"password": secretKey,
},
},
}

values = tools.MergeMaps(values, credentials)
}

values = tools.MergeMaps(values, a.Overrides)

return a.runUpgrade(upgradeCli, values)
}

func (a *Argo) isInstalled() (bool, error) {
getAction := action.NewGet(a.configuration)
_, err := getAction.Run(a.ReleaseName)

if errors.Is(err, driver.ErrReleaseNotFound) {
return false, nil
} else if err != nil {
return false, errors.Wrap(err, "while checking if the Argo release exists")
}

return true, nil
}

func (a *Argo) areMinioCredentialsProvided(values map[string]interface{}) bool {
minio, ok := values["minio"].(map[string]interface{})
if !ok {
// if minio key is not set
return false
}

if existingSecret, ok := minio["existingSecret"]; ok && existingSecret != "" {
// if minio.existingSecret is set
return true
}

accessKey, ok := minio["accessKey"].(map[string]interface{})
if !ok {
// if minio.accessKey is not set
return false
}

if accessKeyPassword, ok := accessKey["password"]; !ok || accessKeyPassword == "" {
// if minio.accessKey.password is not set
return false
}

secretKey, ok := minio["secretKey"].(map[string]interface{})
if !ok {
// if minio.secretKey is not set
return false
}

if secretKeyPassword, ok := secretKey["password"]; !ok || secretKeyPassword == "" {
// if minio.secretKey.password is not set
return false
}

// minio.accessKey.password and minio.secretKey.password is set
return true
}

// InstallUpgrade upgrades or if not available, installs the component
func (i *IngressController) InstallUpgrade(ctx context.Context, version string) (*release.Release, error) {
var err error
Expand Down
Loading

0 comments on commit 2c0b807

Please sign in to comment.