Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Tweak arguments to what was agreed
Browse files Browse the repository at this point in the history
Also, remove _Weave_ from all user and email references.
  • Loading branch information
2opremio committed Jul 24, 2019
1 parent 9a628c3 commit 09c421b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 77 deletions.
4 changes: 2 additions & 2 deletions chart/flux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ The following tables lists the configurable parameters of the Flux chart and the
| `git.url` | `None` | URL of git repo with Kubernetes manifests
| `git.branch` | `master` | Branch of git repo to use for Kubernetes manifests
| `git.path` | `None` | Path within git repo to locate Kubernetes manifests (relative path)
| `git.user` | `Weave Flux` | Username to use as git committer
| `git.email` | `[email protected]` | Email to use as git committer
| `git.user` | `Flux` | Username to use as git committer
| `git.email` | `[email protected]` | Email to use as git committer
| `git.setAuthor` | `false` | If set, the author of git commits will reflect the user who initiated the commit and will differ from the git committer.
| `git.signingKey` | `None` | If set, commits will be signed with this GPG key
| `git.verifySignatures` | `false` | If set, the signatures of the sync tag and commits will be verified
Expand Down
4 changes: 2 additions & 2 deletions chart/flux/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ git:
# Path within git repo to locate Kubernetes manifests (relative path)
path: ""
# Username to use as git committer
user: "Weave Flux"
user: "Flux"
# Email to use as git committer
email: "[email protected]"
email: "[email protected]"
# If set, commits will be signed with this GPG key.
signingKey: ""
# If set, the signatures of the sync tag and commits will be verified.
Expand Down
86 changes: 19 additions & 67 deletions cmd/fluxctl/install_cmd.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package main

import (
"context"
"fmt"
"time"

"github.com/spf13/cobra"

"github.com/weaveworks/flux/git"
)

type installOpts struct {
gitURL string
gitBranch string
gitFluxPath string
gitPaths []string
gitLabel string
timeout time.Duration
gitUser string
gitEmail string
namespace string
additionalFluxArgs []string
amend bool
}

func newInstall() *installOpts {
Expand All @@ -28,74 +22,32 @@ func newInstall() *installOpts {
func (opts *installOpts) Command() *cobra.Command {
cmd := &cobra.Command{
Use: "install",
Short: "Bootstrap Flux, installing it in the cluster and initializing its manifests in the Git repository",
RunE: opts.RunE,
Short: "Print and tweak Kubernetes manifests needed to install Flux in a Cluster",
Example: `# Install Flux and make it use Git repository [email protected]:<your username>/flux-get-started
fluxctl install --git-url '[email protected]:<your username>/flux-get-started' | kubectl -f -`,
RunE: opts.RunE,
}
cmd.Flags().StringVarP(&opts.gitURL, "git-url", "r", "",
cmd.Flags().StringVarP(&opts.gitURL, "git-url", "", "",
"URL of the Git repository to be used by Flux, e.g. [email protected]:<your username>/flux-get-started")
cmd.Flags().StringVarP(&opts.gitBranch, "git-branch", "b", "master",
cmd.Flags().StringVarP(&opts.gitBranch, "git-branch", "", "master",
"Git branch to be used by Flux")
cmd.Flags().StringVarP(&opts.gitLabel, "git-label", "l", "flux",
"Git label to keep track of FLux's sync progress; overrides both --git-sync-tag and --git-notes-ref")
cmd.Flags().StringVarP(&opts.gitFluxPath, "git-flux-subdir", "p", "flux/",
"Directory within the Git repository where to commit the Flux manifests")
cmd.Flags().DurationVarP(&opts.timeout, "timeout", "t", 10*time.Second,
"Timeout duration for I/O operations")
cmd.Flags().StringVarP(&opts.namespace, "namespace", "n", "flux",
cmd.Flags().StringVarP(&opts.gitLabel, "git-label", "", "flux",
"Git label to keep track of Flux's sync progress; overrides both --git-sync-tag and --git-notes-ref")
cmd.Flags().StringVarP(&opts.gitUser, "git-user", "", "Flux",
"Username to use as git committer")
cmd.Flags().StringVarP(&opts.gitEmail, "git-email", "", "[email protected]",
"Email to use as git committer")
cmd.Flags().StringVarP(&opts.namespace, "namespace", "", "flux",
"Cluster namespace where to install flux")
cmd.Flags().BoolVarP(&opts.amend, "amend", "a", false,
"Stop for amending the Flux manifests before pushing them to the Git repository")
cmd.Flags().StringSliceVarP(&opts.additionalFluxArgs, "extra-flux-args", "e", []string{},
cmd.Flags().StringSliceVarP(&opts.additionalFluxArgs, "extra-flux-args", "", []string{},
"Additional arguments for Flux as CSVs, e.g. --extra-flux-arg='--manifest-generation=true,--sync-garbage-collection=true'")
return cmd
}

func (opts *installOpts) RunE(cmd *cobra.Command, args []string) error {
//0. Read and patch embedded deploy/* manifests with what was passed to ops

// TODO. BTW, it's probably easier to embed chart/flux/* and use `helm template` as a library instead

//1. Clone repository. In the future we could optionally create the repository automatically for the most
// popular git providers (e.g. GitHub OAuth).

if opts.gitURL == "" {
fmt.Errorf("no Git repository was provided, please provide a repository through --git-url")
}

remote := git.Remote{opts.gitURL}
pollInterval := 0 * time.Second // there is no need for polling, We will fetch the repo once, manually
repo := git.NewRepo(remote, git.Branch(opts.gitBranch), git.Timeout(opts.timeout), git.PollInterval(pollInterval))
checkoutConfig := git.Config{
Branch: opts.gitBranch,
}
ctx := context.Background()
cloneCtx, cloneCtxCancel := context.WithTimeout(ctx, opts.timeout)
defer cloneCtxCancel()
checkout, err := repo.Clone(cloneCtx, checkoutConfig)
if err != nil {
return fmt.Errorf("cannot clone repository %s: %s", opts.gitURL)
}
cleanCheckout := true
defer func() {
if cleanCheckout {
checkout.Clean()
}
}()

// 2. Write manifests from (0) to the repository's clone working directory

// 3. If --amend was passed, stop to let the user edit the manifests, by prompting a shell

// 4. `kubectl apply` the changes to the cluster

// 5. commit the local changes and push to the remote repository

// 6. Make sure that the ssh key is added to the repo. At this point we should probably just print the ssh
// key and telling the user to add it manually. In the future we can do this programatically for the most popular
// Git providers.
//0. Read and patch embedded templates manifests with what was passed to as options

// 7. Confirm that Flux is running (for instance by checking that its own manifests have been synced, this can be
// done by checking that the sync annotations have been added)
//1. Print them

return nil
}
4 changes: 2 additions & 2 deletions cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func main() {
gitURL = fs.String("git-url", "", "URL of git repo with Kubernetes manifests; e.g., [email protected]:weaveworks/flux-get-started")
gitBranch = fs.String("git-branch", "master", "branch of git repo to use for Kubernetes manifests")
gitPath = fs.StringSlice("git-path", []string{}, "relative paths within the git repo to locate Kubernetes manifests")
gitUser = fs.String("git-user", "Weave Flux", "username to use as git committer")
gitEmail = fs.String("git-email", "[email protected]", "email to use as git committer")
gitUser = fs.String("git-user", "Flux", "username to use as git committer")
gitEmail = fs.String("git-email", "[email protected]", "email to use as git committer")
gitSetAuthor = fs.Bool("git-set-author", false, "if set, the author of git commits will reflect the user who initiated the commit and will differ from the git committer.")
gitLabel = fs.String("git-label", "", "label to keep track of sync progress; overrides both --git-sync-tag and --git-notes-ref")
gitSecret = fs.Bool("git-secret", false, `if set, git-secret will be run on every git checkout. A gpg key must be imported using --git-gpg-key-import or by mounting a keyring containing it directly`)
Expand Down
4 changes: 2 additions & 2 deletions site/daemon.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ fluxd requires setup and offers customization though a multitude of flags.
| --git-ci-skip | false | when set, fluxd will append `\n\n[ci skip]` to its commit messages
| --git-ci-skip-message | `""` | if provided, fluxd will append this to commit messages (overrides --git-ci-skip`)
| --git-path | | path within git repo to locate Kubernetes manifests (relative path)
| --git-user | `Weave Flux` | username to use as git committer
| --git-email | `[email protected]` | email to use as git committer
| --git-user | `Flux` | username to use as git committer
| --git-email | `[email protected]` | email to use as git committer
| --git-set-author | false | if set, the author of git commits will reflect the user who initiated the commit and will differ from the git committer
| --git-gpg-key-import | | if set, fluxd will attempt to import the gpg key(s) found on the given path
| --git-signing-key | | if set, commits made by fluxd to the user git repo will be signed with the provided GPG key. See [Git commit signing](git-commit-signing.md) to learn how to use this feature
Expand Down
4 changes: 2 additions & 2 deletions site/fluxctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ started with several flags that impact the commit information:

| flag | purpose | default
| -------------- | -------------------------- | ---
| git-user | committer name | `Weave Flux`
| git-email | committer email | `[email protected]`
| git-user | committer name | `Flux`
| git-email | committer email | `[email protected]`
| git-set-author | override the commit author | false

Actions triggered by a user through the CLI `fluxctl`
Expand Down

0 comments on commit 09c421b

Please sign in to comment.