Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade uses new helm repo #1069

Merged
merged 38 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b98c9ee
Use the new helm chart and basic auth
foot Nov 3, 2021
c9fa7b0
formatting
foot Nov 11, 2021
ddc08c8
Merge branch 'main' into upgrade-uses-new-helm-repo
sarataha Nov 12, 2021
a035576
Refactor
sarataha Nov 12, 2021
dd1211f
Change error message
sarataha Nov 12, 2021
d3406f0
Update tests
sarataha Nov 12, 2021
274b5dc
Fix test
sarataha Nov 12, 2021
12055cc
linting
sarataha Nov 14, 2021
f7663eb
Update PR info
sarataha Nov 14, 2021
9b10a92
Update path
sarataha Nov 15, 2021
bac577a
get cluster name
sarataha Nov 15, 2021
959bf39
refactor kubeclient
sarataha Nov 15, 2021
6db7f97
linting
sarataha Nov 15, 2021
2baa028
Add review changes
sarataha Nov 16, 2021
06c8ff8
Add review changes
sarataha Nov 16, 2021
b59e1fc
fix tests
sarataha Nov 16, 2021
afc1509
Update helm release values
sarataha Nov 16, 2021
6d36cfc
Merge branch 'main' into upgrade-uses-new-helm-repo
sarataha Nov 16, 2021
5a4326c
Add --set flag to set values
sarataha Nov 16, 2021
fd5092e
Add stravals package
sarataha Nov 16, 2021
05325ca
Add tests
sarataha Nov 16, 2021
c813002
Update test
sarataha Nov 16, 2021
fa46fdb
use jsonmap
sarataha Nov 16, 2021
14dd223
Fix no such flag
sarataha Nov 16, 2021
53d8175
Remove old comments
sarataha Nov 16, 2021
19be5a9
add a comment
sarataha Nov 16, 2021
cd41ddd
Use interface{} to avoid test errors
sarataha Nov 16, 2021
3b0b4d2
Remove unused flags
sarataha Nov 17, 2021
03fe7fd
Small fixes after manual testing
foot Nov 18, 2021
643e416
update example usage
foot Nov 18, 2021
fb7ee23
revert file changes
foot Nov 18, 2021
afcd76c
small cleanup
foot Nov 18, 2021
e8aae6e
Merge remote-tracking branch 'origin/main' into upgrade-uses-new-helm…
foot Nov 18, 2021
8a08174
print out pr
foot Nov 18, 2021
b6a6cf8
Merge remote-tracking branch 'origin/main' into upgrade-uses-new-helm…
foot Nov 18, 2021
e583169
linting
foot Nov 19, 2021
7b299f7
mock pr
foot Nov 19, 2021
dc9060a
Merge remote-tracking branch 'origin/main' into upgrade-uses-new-helm…
foot Nov 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 32 additions & 2 deletions cmd/gitops/upgrade/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (

"github.com/spf13/cobra"
wego "github.com/weaveworks/weave-gitops/api/v1alpha1"
"github.com/weaveworks/weave-gitops/cmd/internal"
"github.com/weaveworks/weave-gitops/pkg/flux"
"github.com/weaveworks/weave-gitops/pkg/osys"
"github.com/weaveworks/weave-gitops/pkg/runner"
"github.com/weaveworks/weave-gitops/pkg/services"
"github.com/weaveworks/weave-gitops/pkg/services/auth"
"github.com/weaveworks/weave-gitops/pkg/upgrade"
)

Expand All @@ -23,7 +29,8 @@ var Cmd = &cobra.Command{
}

func init() {
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.RepoOrgAndName, "repo", "", "The repository to open a pull request against. E.g: acme/my-config-repo (default: git current working directory)")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.AppConfigURL, "app-config-url", "", "URL of external repository that will hold automation manifests")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.ProfileVersion, "profile-version", "", "Profile version to set the helm release version to")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.Remote, "remote", "origin", "The remote to push the branch to")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.BaseBranch, "base", "main", "The base branch to open the pull request against")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.HeadBranch, "branch", "tier-upgrade-enterprise", "The branch to create the pull request from")
Expand All @@ -33,21 +40,44 @@ func init() {
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.Out, "out", "", "Optional location to create the profile installation folder in. This should be relative to the current working directory. (default: current)")
Cmd.PersistentFlags().StringVar(&upgradeCmdFlags.ProfileBranch, "profile-branch", "main", "The branch to use on the repository in which the profile is.")
Cmd.PersistentFlags().BoolVar(&upgradeCmdFlags.DryRun, "dry-run", false, "Output the generated profile without creating a pull request")
Cmd.PersistentFlags().StringArrayVar(&upgradeCmdFlags.Values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")

cobra.CheckErr(Cmd.MarkPersistentFlagRequired("app-config-url"))
}

func upgradeCmdRunE() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
namespace, err := cmd.Parent().Flags().GetString("namespace")

if err != nil {
return fmt.Errorf("couldn't read namespace flag: %v", err)
}

// FIXME: maybe a better way to do this?
upgradeCmdFlags.Namespace = namespace

log := internal.NewCLILogger(os.Stdout)
fluxClient := flux.New(osys.New(), &runner.CLIRunner{})
factory := services.NewFactory(fluxClient, log)

providerClient := internal.NewGitProviderClient(os.Stdout, os.LookupEnv, auth.NewAuthCLIHandler, log)

gitClient, gitProvider, err := factory.GetGitClients(ctx, providerClient, services.GitConfigParams{
URL: upgradeCmdFlags.AppConfigURL,
Namespace: upgradeCmdFlags.Namespace,
DryRun: upgradeCmdFlags.DryRun,
})
if err != nil {
return fmt.Errorf("failed to get git clients: %w", err)
}

return upgrade.Upgrade(
context.Background(),
ctx,
gitClient,
gitProvider,
upgradeCmdFlags,
log,
os.Stdout,
)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ require (
github.com/google/go-github/v32 v32.1.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts v1.1.1
github.com/helm/helm v2.17.0+incompatible // indirect
github.com/jandelgado/gcov2lcov v1.0.5
github.com/jarcoal/httpmock v1.0.8
github.com/jenkins-x/go-scm v1.10.10
github.com/lithammer/dedent v1.1.0
github.com/mattn/go-isatty v0.0.13
github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
github.com/helm/helm v2.17.0+incompatible h1:0iy95yMXrfWpwaoOA9XRP+cTvitTrq+LcJV9DvR5n1Y=
github.com/helm/helm v2.17.0+incompatible/go.mod h1:ahXhuvluW4YnSL6W6hDVetZsVK8Pv4BP8OwKli7aMqo=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
Expand Down
3 changes: 3 additions & 0 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const WegoClusterOSWorkloadDir = "system"
// WegoClusterUserWorloadDir is where user workload manifests will live in the GitOps repo
const WegoClusterUserWorloadDir = "user"

// WegoEnterpriseDir is where GitOps enterprise manifests will live in the GitOps repo
const WegoEnterpriseDir = "enterprise"

// Git is an interface for basic Git operations on a single branch of a
// remote repository.
//counterfeiter:generate . Git
Expand Down
1 change: 1 addition & 0 deletions pkg/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kube
import (
"context"
"fmt"

"github.com/weaveworks/weave-gitops/pkg/logger"

wego "github.com/weaveworks/weave-gitops/api/v1alpha1"
Expand Down