Skip to content

Commit

Permalink
Quickstart refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
N-o-Z committed Jul 18, 2023
1 parent d18948b commit ec65f50
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 54 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,4 @@ jobs:
tags: |
${{ steps.login-ecr.outputs.registry }}/lakefs:${{ steps.version.outputs.tag }}
treeverse/lakefs:${{ steps.version.outputs.tag }}
treeverse/lakefs:latest
- name: Build and push lakefs quickstart
uses: docker/build-push-action@v3
with:
context: .
target: lakefs-plugins
push: true
platforms: linux/amd64,linux/arm64,darwin/amd64,darwin/arm64
build-args: |
VERSION=${{ steps.version.outputs.tag }}
QUICKSTART=true
tags: treeverse/lakefs:quickstart
treeverse/lakefs:latest
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ RUN apk add netcat-openbsd

WORKDIR /app
COPY ./scripts/wait-for ./

ARG QUICKSTART=false
ENV PATH=/app:$PATH QUICKSTART=${QUICKSTART}

ENV PATH /app:$PATH
COPY --from=build /build/lakefs /build/lakectl ./
COPY --from=build-delta-diff-plugin /delta-diff/target/release/delta_diff ./

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ You can spin up a standalone sandbox instance of lakeFS using Docker:
docker run --pull always \
--name lakefs \
-p 8000:8000 \
treeverse/lakefs:quickstart \
run --local-settings
treeverse/lakefs:latest \
run --quickstart
```

Once you've got lakeFS running, open [http://127.0.0.1:8000/](http://127.0.0.1:8000/) in your web browser.
Expand Down
42 changes: 34 additions & 8 deletions cmd/lakefs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/treeverse/lakefs/pkg/block"
"github.com/treeverse/lakefs/pkg/config"
"github.com/treeverse/lakefs/pkg/kv/local"
"github.com/treeverse/lakefs/pkg/logging"
"github.com/treeverse/lakefs/pkg/version"
)
Expand Down Expand Up @@ -41,26 +43,50 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.lakefs.yaml)")
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.PersistentFlags().Bool(config.UseLocalConfiguration, false, "Use lakeFS local default configuration")
rootCmd.PersistentFlags().Bool(config.QuickStartConfiguration, false, "Use lakeFS quickstart configuration")
}

func useLocal() bool {
res, err := rootCmd.PersistentFlags().GetBool(config.UseLocalConfiguration)
func validateQuickstartEnv(cfg *config.Config) {
if cfg.Database.Type != local.DriverName || cfg.Blockstore.Type != block.BlockstoreTypeLocal {
fmt.Printf("quickstart mode can only run with local settings\n")
os.Exit(1)
}
accessKey := "AKIAIOSFOLQUICKSTART"
secretKey := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

Check failure on line 55 in cmd/lakefs/cmd/root.go

View workflow job for this annotation

GitHub Actions / Run Linters and Checkers

G101: Potential hardcoded credentials (gosec)
cfg.Installation.UserName = "quickstart"
cfg.Installation.AccessKeyID = config.SecureString(accessKey)
cfg.Installation.SecretAccessKey = config.SecureString(secretKey)
fmt.Printf("Access Key ID : %s \n", accessKey)
fmt.Printf("Secret Access Key: %s \n", secretKey)
}

func useConfig(cfg string) bool {
res, err := rootCmd.PersistentFlags().GetBool(cfg)
if err != nil {
fmt.Printf("%s: %s\n", config.UseLocalConfiguration, err)
fmt.Printf("%s: %s\n", cfg, err)
os.Exit(1)
}
if res {
printLocalWarning(os.Stderr, "local parameters configuration")
printLocalWarning(os.Stderr, fmt.Sprintf("%s parameters configuration", cfg))
}
return res
}

func newConfig() (*config.Config, error) {
if useLocal() {
return config.NewLocalConfig()
}
quickStart := useConfig(config.QuickStartConfiguration)

return config.NewConfig()
if useConfig(config.UseLocalConfiguration) || quickStart {
cfg, err := config.NewLocalConfig()
if err != nil {
return nil, err
}
if quickStart {
validateQuickstartEnv(cfg)
}
return cfg, err
} else {
return config.NewConfig()
}
}

func loadConfig() *config.Config {
Expand Down
2 changes: 1 addition & 1 deletion cmd/lakefs/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func printWelcome(w io.Writer) {
const localWarningBanner = `
WARNING!
Using %s. This is suitable only for testing! It is NOT SUPPORTED for production.
Using %s. This is suitable only for testing! It is NOT SUPPORTED for production.
`

func printLocalWarning(w io.Writer, msg string) {
Expand Down
24 changes: 9 additions & 15 deletions docs/quickstart/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,25 @@ Launch the lakeFS container:
```bash
docker run --name lakefs --pull always \
--rm --publish 8000:8000 \
treeverse/lakefs:quickstart \
run --local-settings
treeverse/lakefs:latest \
run --quickstart
```

After a few moments you should see the lakeFS container ready to use:
Quickstart mode includes initial setup and lakeFS is ready for use!
The lakeFS quickstart credentials are:

```
[…]
│ If you're running lakeFS locally for the first time,
│ complete the setup process at http://127.0.0.1:8000/setup
[…]
│ Access Key ID : "AKIAIOSFOLQUICKSTART"
│ Secret Access Key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
```

You're now ready to dive into lakeFS!

1. Open lakeFS's web interface at [http://127.0.0.1:8000/](http://127.0.0.1:8000/), enter your email address, and then click **Setup**.

2. Make a note of the Access Key ID and Secret Access Key and click on **Go To Login**.
1. Open lakeFS's web interface at [http://127.0.0.1:8000/](http://127.0.0.1:8000/), enter your email address, and then click **Go to Login**.

3. Login with the credentials that you've just created.
2. Login with the quickstart credentials.

4. You'll notice that there aren't any repositories created yet. Click the **Create Sample Repository** button.
3. You'll notice that there aren't any repositories created yet. Click the **Create Sample Repository** button.

<img width="75%" src="/assets/img/quickstart/empty-repo-list.png" alt="Empty lakeFS Repository list" class="quickstart"/>

Expand Down
10 changes: 5 additions & 5 deletions pkg/auth/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ func inDockerMetadata() string {

func getInstrumentationMetadata() string {
lakefsAccessKeyID := os.Getenv("LAKEFS_ACCESS_KEY_ID")
if strings.HasSuffix(lakefsAccessKeyID, "LKFSSAMPLES") {
switch {
case strings.HasSuffix(lakefsAccessKeyID, "LKFSSAMPLES"):
return InstrumentationSamplesRepo
}
quickstart, _ := strconv.ParseBool(os.Getenv("QUICKSTART"))
if quickstart {
case strings.HasSuffix(lakefsAccessKeyID, "QUICKSTART"):
return InstrumentationQuickstart
default:
return InstrumentationRun
}
return InstrumentationRun
}

func (m *KVMetadataManager) GetMetadata(ctx context.Context) (map[string]string, error) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/auth/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func TestInstrumentation(t *testing.T) {
auth.DockeEnvExists = ""
validateInstrumentation(t, ctx, mgr, auth.InstrumentationRun, false, true)

// Add quickstart env var with right value
require.NoError(t, os.Setenv("QUICKSTART", "true"))
validateInstrumentation(t, ctx, mgr, auth.InstrumentationQuickstart, false, true)

// Add sample repo env var
require.NoError(t, os.Setenv("LAKEFS_ACCESS_KEY_ID", "LKFSSAMPLES"))
validateInstrumentation(t, ctx, mgr, auth.InstrumentationSamplesRepo, false, true)

// Add quickstart env var with right value
require.NoError(t, os.Setenv("LAKEFS_ACCESS_KEY_ID", "QUICKSTART"))
validateInstrumentation(t, ctx, mgr, auth.InstrumentationQuickstart, false, true)

// Add K8s env var
require.NoError(t, os.Setenv("KUBERNETES_SERVICE_HOST", ""))
validateInstrumentation(t, ctx, mgr, auth.InstrumentationSamplesRepo, true, true)
validateInstrumentation(t, ctx, mgr, auth.InstrumentationQuickstart, true, true)
}
5 changes: 4 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ var (

// UseLocalConfiguration set to true will add defaults that enable a lakeFS run
// without any other configuration like DB or blockstore.
const UseLocalConfiguration = "local-settings"
const (
UseLocalConfiguration = "local-settings"
QuickStartConfiguration = "quickstart"
)

type OIDC struct {
// configure how users are handled on the lakeFS side:
Expand Down

0 comments on commit ec65f50

Please sign in to comment.