Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Update dashboard config fields
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Wilson <brandon@coil.com>
  • Loading branch information
wilsonianb authored and alexellis committed Dec 14, 2020
1 parent f169262 commit 5b51d3b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
17 changes: 9 additions & 8 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,28 +362,29 @@ func process(plan types.Plan, prefs InstallPreferences, additionalPaths []string
}
}

fmt.Println("Creating stack.yml")

planErr := stack.Apply(plan)
if planErr != nil {
log.Println(planErr)
}

var pubCert string
if !prefs.SkipSealedSecrets {
sealedSecretsErr := installSealedSecrets()
if sealedSecretsErr != nil {
log.Println(sealedSecretsErr)
return sealedSecretsErr
}

pubCert := exportSealedSecretPubCert()
pubCert = exportSealedSecretPubCert()
writeErr := ioutil.WriteFile("tmp/pubcert.pem", []byte(pubCert), 0700)
if writeErr != nil {
log.Println(writeErr)
return writeErr
}
}

fmt.Println("Creating stack.yml")

planErr := stack.Apply(plan, pubCert)
if planErr != nil {
log.Println(planErr)
}

cloneErr := cloneCloudComponents(plan.OpenFaaSCloudVersion, additionalPaths)
if cloneErr != nil {
return cloneErr
Expand Down
1 change: 1 addition & 0 deletions example.init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ scm: github
## Populate from GitHub App
github:
app_id: "24304"
public_link: "https://github.com/apps/o6s-io"

## GitLab
### Public URL for your GitLab instance with a trailing slash
Expand Down
25 changes: 22 additions & 3 deletions pkg/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"html/template"
"io/ioutil"
"os"
"strings"

"github.com/openfaas/ofc-bootstrap/pkg/types"
)
Expand Down Expand Up @@ -50,8 +51,16 @@ type awsConfig struct {
ECRRegion string
}

type dashboardConfig struct {
RootDomain string
Scheme string
GitHubAppUrl string
GitLabInstance string
PublicKey string
}

// Apply creates `templates/gateway_config.yml` to be referenced by stack.yml
func Apply(plan types.Plan) error {
func Apply(plan types.Plan, pubCert string) error {
scheme := "http"
if plan.TLS {
scheme += "s"
Expand Down Expand Up @@ -98,8 +107,18 @@ func Apply(plan types.Plan) error {
}
}

dashboardConfigErr := generateTemplate("dashboard_config", plan, gatewayConfig{
RootDomain: plan.RootDomain, Scheme: scheme,
var gitHubAppUrl, gitLabInstance string
if plan.SCM == types.GitHubSCM {
gitHubAppUrl = plan.Github.PublicLink
} else if plan.SCM == types.GitLabSCM {
gitLabInstance = plan.Gitlab.GitLabInstance
}
dashboardConfigErr := generateTemplate("dashboard_config", plan, dashboardConfig{
RootDomain: plan.RootDomain,
Scheme: scheme,
GitHubAppUrl: gitHubAppUrl,
GitLabInstance: gitLabInstance,
PublicKey: strings.ReplaceAll(pubCert, "\n", "\n "),
})
if dashboardConfigErr != nil {
return dashboardConfigErr
Expand Down
1 change: 1 addition & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type KeyValueNamespaceTuple struct {
type Github struct {
AppID string `yaml:"app_id,omitempty"`
PrivateKeyFile string `yaml:"private_key_filename,omitempty"`
PublicLink string `yaml:"public_link,omitempty"`
}

type Gitlab struct {
Expand Down
1 change: 0 additions & 1 deletion scripts/export-sealed-secret-pubcert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ then
chmod +x /tmp/kubeseal
fi

/tmp/kubeseal --version
/tmp/kubeseal --fetch-cert --controller-name=ofc-sealedsecrets-sealed-secrets > tmp/pub-cert.pem && \
cat tmp/pub-cert.pem
8 changes: 8 additions & 0 deletions templates/dashboard_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ environment:
query_pretty_url: 'true'
# Cookie root domain is needed to remove OAuth tokens when using OAuth, it doesnt matter if its set when not using OAuth
cookie_root_domain: '.system.{{.RootDomain}}'
# Public URL for your GitHub app
# see https://github.com/settings/apps/
github_app_url: {{.GitHubAppUrl}}
# Public URL for your GitLab instance
gitlab_url: {{.GitLabInstance}}
# SealedSecrets public key
public_key: |
{{.PublicKey}}

0 comments on commit 5b51d3b

Please sign in to comment.