From 1733c7d11f83c1a053148f9627cbb9865b6198cb Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 17 Oct 2022 15:50:23 +0200 Subject: [PATCH] Initial bricks init add to .gitignore --- cmd/init/init.go | 15 +++++++++++++++ project/config.go | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/cmd/init/init.go b/cmd/init/init.go index ea67238d..054b6d9c 100644 --- a/cmd/init/init.go +++ b/cmd/init/init.go @@ -111,6 +111,21 @@ var initCmd = &cobra.Command{ if err != nil { return err } + + // Create .gitignore if absent + gitIgnoreFile, err := os.OpenFile(fmt.Sprintf("%s/%s", wd, project.GitIgnoreFile), + os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) + if err != nil { + return err + } + defer gitIgnoreFile.Close() + + // Append .databricks to the end of .gitignore file + _, err = gitIgnoreFile.WriteString("\n/.databricks/") + if err != nil { + return err + } + d, err := templates.ReadDir(".") if err != nil { return err diff --git a/project/config.go b/project/config.go index f718df31..4dd82de0 100644 --- a/project/config.go +++ b/project/config.go @@ -24,6 +24,13 @@ const ( // ConfigFile is the name of project configuration file const ConfigFile = "databricks.yml" +// Cache Dir is the name of the directory with all the state overrides, +// cached artifacts and per-user state +const CacheDir = ".databricks" + +// Name of the file with regexes that are not to be checked into git +const GitIgnoreFile = ".gitignore" + type Assertions struct { Groups []string `json:"groups,omitempty"` Secrets []string `json:"secrets,omitempty"`