Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Sheikh-Abubaker/cyclops int…
Browse files Browse the repository at this point in the history
…o log-pr
  • Loading branch information
Sheikh-Abubaker committed Nov 9, 2024
2 parents becd137 + cfb9346 commit 7d3ac86
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 73 deletions.
95 changes: 91 additions & 4 deletions cyctl/internal/create/template_auth_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package create

import (
"encoding/json"
"errors"
"fmt"
"log"
"strings"

"github.com/cyclops-ui/cyclops/cyclops-ctrl/api/v1alpha1"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/api/v1alpha1/client"
"github.com/cyclops-ui/cycops-cyctl/internal/kubeconfig"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
v1Spec "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -28,6 +30,74 @@ var (
password string
)

func getTemplateAuthRulesFromPrompt() (string, string, string, string, string, error) {
RepoPrompt := promptui.Prompt{
Label: "repo",
}
repoValue, err := RepoPrompt.Run()
if err != nil {
return "", "", "", "", "", err
}

usernameNamePrompt := promptui.Prompt{
Label: "Username secret name",
Validate: func(input string) error {
if input == "" {
return errors.New("username secret name cannot be empty")
}
return nil
},
}
usernameName, err := usernameNamePrompt.Run()
if err != nil {
return "", "", "", "", "", err
}

usernameKeyPrompt := promptui.Prompt{
Label: "Username secret key",
Validate: func(input string) error {
if input == "" {
return errors.New("the username secret key cannot be empty")
}
return nil
},
}
usernameKey, err := usernameKeyPrompt.Run()
if err != nil {
return "", "", "", "", "", err
}

passwordNamePrompt := promptui.Prompt{
Label: "Password secret name",
Validate: func(input string) error {
if input == "" {
return errors.New("the password secret name cannot be empty")
}
return nil
},
}
passwordName, err := passwordNamePrompt.Run()
if err != nil {
return "", "", "", "", "", err
}

passwordKeyPrompt := promptui.Prompt{
Label: "Password secret key",
Validate: func(input string) error {
if input == "" {
return errors.New("password secret key cannot be empty")
}
return nil
},
}
passwordKey, err := passwordKeyPrompt.Run()
if err != nil {
return "", "", "", "", "", err
}

return usernameName, usernameKey, passwordName, passwordKey, repoValue, nil
}

func validateSecretKeySelector(username, password string) (string, string, string, string, error) {
usernameName, usernameKey := splitNameKey(username)
passwordName, passwordKey := splitNameKey(password)
Expand All @@ -50,10 +120,27 @@ func splitNameKey(input string) (string, string) {

// createTemplateAuthRule allows you to create TemplateAuthRule Custom Resource.
func createTemplateAuthRule(clientset *client.CyclopsV1Alpha1Client, templateAuthRuleName string) {
usernameName, usernameKey, passwordName, passwordKey, err := validateSecretKeySelector(username, password)
if err != nil {
fmt.Println(err)
return
var (
usernameName string
passwordName string
usernameKey string
passwordKey string
)

if username == "" && password == "" && repo == "" {
var err error
usernameName, usernameKey, passwordName, passwordKey, repo, err = getTemplateAuthRulesFromPrompt()
if err != nil {
log.Fatal(err)
return
}
} else {
var err error
usernameName, usernameKey, passwordName, passwordKey, err = validateSecretKeySelector(username, password)
if err != nil {
log.Fatal(err)
return
}
}

var localObjectNameRef, localObjectPasswordRef v1Spec.LocalObjectReference
Expand Down
4 changes: 2 additions & 2 deletions install/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: cyclops-chart
description: Cyclops Helm chart
type: application
version: "0.9.0"
appVersion: "v0.14.3"
version: "0.11.0"
appVersion: "v0.15.2"
home: https://cyclops-ui.com/
keywords:
- Devops
Expand Down
122 changes: 61 additions & 61 deletions install/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,64 @@ ctrl:
ui:
replicas: 1

templateStore:
- name: demo
repo: https://github.com/cyclops-ui/templates
path: demo
version: main
iconURL: https://github.com/cyclops-ui/cyclops/blob/main/cyclops-ui/src/static/img/default-template-icon.png?raw=true
sourceType: git
- name: app-template
repo: https://github.com/cyclops-ui/templates
path: app-template
version: main
iconURL: https://github.com/cyclops-ui/cyclops/blob/main/cyclops-ui/src/static/img/default-template-icon.png?raw=true
sourceType: git
- name: jenkins
repo: https://github.com/bitnami/charts
path: bitnami/jenkins
version: main
iconURL: https://bitnami.com/assets/stacks/jenkins/img/jenkins-stack-220x234.png
sourceType: git
- name: mariadb
repo: https://github.com/bitnami/charts
path: bitnami/mariadb
version: main
iconURL: https://bitnami.com/assets/stacks/mariadb/img/mariadb-stack-220x234.png
sourceType: git
- name: metabase
repo: https://github.com/cyclops-ui/templates
path: metabase
version: main
iconURL: https://www.metabase.com/images/logo.svg
sourceType: git
- name: mysql
repo: https://github.com/bitnami/charts
path: bitnami/mysql
version: main
iconURL: https://bitnami.com/assets/stacks/mysql/img/mysql-stack-220x234.png
sourceType: git
- name: postgresql
repo: https://github.com/bitnami/charts
path: bitnami/postgresql
version: main
iconURL: https://bitnami.com/assets/stacks/postgresql/img/postgresql-stack-220x234.png
sourceType: git
- name: prometheus
repo: https://github.com/bitnami/charts
path: bitnami/prometheus
version: main
iconURL: https://bitnami.com/assets/stacks/prometheus/img/prometheus-stack-220x234.png
sourceType: git
- name: rabbitmq
repo: https://github.com/bitnami/charts
path: bitnami/rabbitmq
version: main
iconURL: https://bitnami.com/assets/stacks/rabbitmq/img/rabbitmq-stack-220x234.png
sourceType: git
- name: redis
repo: https://github.com/bitnami/charts
path: bitnami/redis
version: main
iconURL: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
sourceType: git
#templateStore:
# - name: demo
# repo: https://github.com/cyclops-ui/templates
# path: demo
# version: main
# iconURL: https://github.com/cyclops-ui/cyclops/blob/main/cyclops-ui/src/static/img/default-template-icon.png?raw=true
# sourceType: git
# - name: app-template
# repo: https://github.com/cyclops-ui/templates
# path: app-template
# version: main
# iconURL: https://github.com/cyclops-ui/cyclops/blob/main/cyclops-ui/src/static/img/default-template-icon.png?raw=true
# sourceType: git
# - name: jenkins
# repo: https://github.com/bitnami/charts
# path: bitnami/jenkins
# version: main
# iconURL: https://bitnami.com/assets/stacks/jenkins/img/jenkins-stack-220x234.png
# sourceType: git
# - name: mariadb
# repo: https://github.com/bitnami/charts
# path: bitnami/mariadb
# version: main
# iconURL: https://bitnami.com/assets/stacks/mariadb/img/mariadb-stack-220x234.png
# sourceType: git
# - name: metabase
# repo: https://github.com/cyclops-ui/templates
# path: metabase
# version: main
# iconURL: https://www.metabase.com/images/logo.svg
# sourceType: git
# - name: mysql
# repo: https://github.com/bitnami/charts
# path: bitnami/mysql
# version: main
# iconURL: https://bitnami.com/assets/stacks/mysql/img/mysql-stack-220x234.png
# sourceType: git
# - name: postgresql
# repo: https://github.com/bitnami/charts
# path: bitnami/postgresql
# version: main
# iconURL: https://bitnami.com/assets/stacks/postgresql/img/postgresql-stack-220x234.png
# sourceType: git
# - name: prometheus
# repo: https://github.com/bitnami/charts
# path: bitnami/prometheus
# version: main
# iconURL: https://bitnami.com/assets/stacks/prometheus/img/prometheus-stack-220x234.png
# sourceType: git
# - name: rabbitmq
# repo: https://github.com/bitnami/charts
# path: bitnami/rabbitmq
# version: main
# iconURL: https://bitnami.com/assets/stacks/rabbitmq/img/rabbitmq-stack-220x234.png
# sourceType: git
# - name: redis
# repo: https://github.com/bitnami/charts
# path: bitnami/redis
# version: main
# iconURL: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
# sourceType: git
20 changes: 14 additions & 6 deletions web/docs/installation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
Following are environment variables you can use to configure your instance of Cyclops. You can set those environment
variables directly on the `cyclops-ui` Kubernetes deployment.

### Cyclops controller

| Name | Description | Default value |
|:------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------|
| PORT | Specify a port to expose the controller API | 8080 |
| DISABLE_TELEMETRY | By default, Cyclops controller emits usage metrics. If this env variable is set to `true`, the usage metrics are not exposed. You can read more about usage metrics [here](https://cyclops-ui.com/docs/usage_metrics/) | false |
| WATCH_NAMESPACE | Kubernetes namespace used for all Cyclops custom resources like `Modules`, `TemplateStores` and `TemplateAuthRules`. Cyclops is aware only of the custom resources in this namespace. Cyclops controller will not react to changes on Modules on other namespaces | cyclops |
| MODULE_TARGET_NAMESPACE | By default, Cyclops can manage resources created from Modules in the whole cluster. If this environment variable is set, Cyclops can manage Module child resources only in the namespace specified in the variable | - (empty means cluster scope) |
| WATCH_NAMESPACE_HELM | By default, Cyclops can list, get and upgrade Helm releases in the whole cluster. If this environment variable is set, Cyclops can manage releases and their resources only in the namespace specified in the variable | - (empty means cluster scope) |

### Cyclops UI

| Name | Description | Default value |
| :--------------------------------- | :------------------------------------------------------------------------ | :-------------------- |
| REACT_APP_CYCLOPS_CTRL_HOST | Content | http://localhost:8080 |
| REACT_APP_DEFAULT_TEMPLATE_REPO | Default template repo (E.g. https://github.com/cyclops-ui/templates) | - |
| REACT_APP_DEFAULT_TEMPLATE_PATH | Default template path (E.g. `demo`) | - |
| REACT_APP_DEFAULT_TEMPLATE_VERSION | Default template version<br/>Can be a commit hash, a tag or a branch name | - |
| Name | Description | Default value |
|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------|
| REACT_APP_CYCLOPS_CTRL_HOST | Host of your Cyclops controller | http://cyclops-ctrl.cyclops:8080 |
| REACT_APP_ENABLE_STREAMING | Configures whether the Cyclops UI will subscribe to resource status SSE stream from cyclops controller. If `false`, resource status is polled each 15 seconds | true |
Loading

0 comments on commit 7d3ac86

Please sign in to comment.