Skip to content

Commit

Permalink
chore: use configmap for helm driver
Browse files Browse the repository at this point in the history
  • Loading branch information
acid-chicken committed May 21, 2024
1 parent 31a147d commit 459e0a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions charts/hariko/templates/PostInstallJob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
- /bin/sh
- -c
- |-
export HELM_DRIVER=configmap
apk add --no-cache bash curl openssl
curl -LSfs https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm repo add misskey-dev https://misskey-dev.github.io/0key.dev/
Expand Down
24 changes: 17 additions & 7 deletions hariko/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -110,14 +113,15 @@ func newCmd() *cobra.Command {
},
},
}, nil)
release, err := deploy(packageName, repositoryName, repositoryURL)
b := new(bytes.Buffer)
release, err := deploy(packageName, repositoryName, repositoryURL, b)
if err != nil {
discord(&discordgo.WebhookParams{
Embeds: []*discordgo.MessageEmbed{
{
Title: "Deployment failed",
Color: ColorFailure,
Description: err.Error(),
Description: err.Error() + "\n```" + b.String() + "```",
},
},
}, st)
Expand All @@ -126,8 +130,9 @@ func newCmd() *cobra.Command {
discord(&discordgo.WebhookParams{
Embeds: []*discordgo.MessageEmbed{
{
Title: "Deployment succeeded",
Color: ColorSuccess,
Title: "Deployment succeeded",
Color: ColorSuccess,
Description: "```" + b.String() + "```",
Fields: []*discordgo.MessageEmbedField{
{
Name: "Name",
Expand Down Expand Up @@ -178,10 +183,8 @@ func Execute() {
}
}

func deploy(packageName string, repositoryName string, repositoryURL string) (*release.Release, error) {
func deploy(packageName string, repositoryName string, repositoryURL string, log io.Writer) (*release.Release, error) {
p := getter.All(settings)
actionConfig := new(action.Configuration)
actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), "", func(_ string, _ ...interface{}) {})
c := repo.Entry{
Name: repositoryName,
URL: repositoryURL,
Expand All @@ -190,6 +193,9 @@ func deploy(packageName string, repositoryName string, repositoryURL string) (*r
if err != nil {
return nil, err
}
if settings.RepositoryCache != "" {
r.CachePath = settings.RepositoryCache
}
index, err := r.DownloadIndexFile()
if err != nil {
return nil, err
Expand All @@ -210,6 +216,10 @@ func deploy(packageName string, repositoryName string, repositoryURL string) (*r
if _, err := repo.LoadIndexFile(index); err != nil {
return nil, err
}
actionConfig := new(action.Configuration)
actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), "configmap", func(format string, v ...interface{}) {
fmt.Fprintf(log, format+"\n", v...)
})
client := action.NewUpgrade(actionConfig)
chartPath, err := client.LocateChart(repositoryName+"/"+packageName, settings)
if err != nil {
Expand Down

0 comments on commit 459e0a4

Please sign in to comment.