Skip to content

Commit

Permalink
Merge pull request #20 from replicatedhq/pull-with-console
Browse files Browse the repository at this point in the history
Adding admin console when pulling a replicated app
  • Loading branch information
marccampbell authored Aug 28, 2019
2 parents 3348c11 + c0194c9 commit 0860857
Show file tree
Hide file tree
Showing 27 changed files with 1,498 additions and 1,309 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ The `upload` command will upload a directory with an upstream, base and overlays
kubectl kots upload ~/mysql
```

### `kots configure`
The `configure` command will start a local browser-based configuration screen for Replicated apps.
### `kots download`
The `download` command will download an application YAML from a kotsadm server. This is especially useful when paired with `upload` (above) to iterate on and make changes to an application.

### `kots watch`
```
kubectl kots download [--namespace=] [app-slug]
```

The app-slug argument is optional. If there is more than 1 application in the specified namespace, kots will prompt for which one to download.
11 changes: 6 additions & 5 deletions cmd/kots/cli/download.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"os"
"path/filepath"

"github.com/pkg/errors"
Expand All @@ -23,17 +22,18 @@ func DownloadCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
v := viper.GetViper()

if len(args) == 0 {
cmd.Help()
os.Exit(1)
appSlug := ""
if len(args) > 0 {
appSlug = args[0]
}

downloadOptions := download.DownloadOptions{
Namespace: v.GetString("namespace"),
Kubeconfig: v.GetString("kubeconfig"),
Overwrite: v.GetBool("overwrite"),
}

if err := download.Download(args[0], ExpandDir(v.GetString("dest")), downloadOptions); err != nil {
if err := download.Download(appSlug, ExpandDir(v.GetString("dest")), downloadOptions); err != nil {
return errors.Cause(err)
}

Expand All @@ -44,6 +44,7 @@ func DownloadCmd() *cobra.Command {
cmd.Flags().String("kubeconfig", filepath.Join(homeDir(), ".kube", "config"), "the kubeconfig to use")
cmd.Flags().String("namespace", "default", "the namespace to download from")
cmd.Flags().String("dest", homeDir(), "the directory to store the application in")
cmd.Flags().Bool("overwrite", false, "overwrite any local files, if present")

return cmd
}
54 changes: 0 additions & 54 deletions cmd/kots/cli/install-license.go

This file was deleted.

5 changes: 3 additions & 2 deletions cmd/kots/cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ func InstallCmd() *cobra.Command {
Downstreams: []string{
"local", // this is the auto-generated operator downstream
},
LocalPath: ExpandDir(v.GetString("local-path")),
LicenseFile: ExpandDir(v.GetString("license-file")),
LocalPath: ExpandDir(v.GetString("local-path")),
LicenseFile: ExpandDir(v.GetString("license-file")),
ExcludeAdminConsole: true,
}

canPull, err := pull.CanPullUpstream(args[0], pullOptions)
Expand Down
17 changes: 9 additions & 8 deletions cmd/kots/cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ func PullCmd() *cobra.Command {
}

pullOptions := pull.PullOptions{
HelmRepoURI: v.GetString("repo"),
RootDir: ExpandDir(v.GetString("rootdir")),
Overwrite: v.GetBool("overwrite"),
Namespace: v.GetString("namespace"),
Downstreams: v.GetStringSlice("downstream"),
LocalPath: ExpandDir(v.GetString("local-path")),
LicenseFile: ExpandDir(v.GetString("license-file")),
ExcludeKotsKinds: v.GetBool("exclude-kots-kinds"),
HelmRepoURI: v.GetString("repo"),
RootDir: ExpandDir(v.GetString("rootdir")),
Overwrite: v.GetBool("overwrite"),
Namespace: v.GetString("namespace"),
Downstreams: v.GetStringSlice("downstream"),
LocalPath: ExpandDir(v.GetString("local-path")),
LicenseFile: ExpandDir(v.GetString("license-file")),
ExcludeKotsKinds: v.GetBool("exclude-kots-kinds"),
ExcludeAdminConsole: false,
}
if err := pull.Pull(args[0], pullOptions); err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion cmd/kots/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func RootCmd() *cobra.Command {

cmd.AddCommand(PullCmd())
cmd.AddCommand(InstallCmd())
cmd.AddCommand(InstallLicenseCmd())
cmd.AddCommand(UploadCmd())
cmd.AddCommand(DownloadCmd())
cmd.AddCommand(AdminConsoleCmd())
Expand Down
1 change: 1 addition & 0 deletions ffi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func PullFromLicense(licenseData string, downstream string, outputFile string) i
LicenseFile: licenseFile.Name(),
ExcludeKotsKinds: true,
RootDir: tmpRoot,
ExcludeAdminConsole: true,
}

if err := pull.Pull("replicated://sentry-enterprise", pullOptions); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
type DownloadOptions struct {
Namespace string
Kubeconfig string
Overwrite bool
}

func Download(appSlug string, path string, downloadOptions DownloadOptions) error {
Expand Down Expand Up @@ -60,6 +61,17 @@ func Download(appSlug string, path string, downloadOptions DownloadOptions) erro
return errors.Wrap(err, "failed to write archive")
}

// Delete the destination, if needed and requested
if _, err := os.Stat(path); err == nil {
if downloadOptions.Overwrite {
if err := os.RemoveAll(path); err != nil {
return errors.Wrap(err, "failed to delete existing download")
}
} else {
return errors.Errorf("directory already exists at %s", path)
}
}

tarGz := archiver.TarGz{
Tar: &archiver.Tar{
ImplicitTopLevelFolder: false,
Expand Down
Loading

0 comments on commit 0860857

Please sign in to comment.