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

Add override to support YAML inputs for apps #921

Merged
merged 4 commits into from
Oct 27, 2023

Conversation

taiga-db
Copy link
Contributor

@taiga-db taiga-db commented Oct 25, 2023

Changes

Take @andrefurlan-db 's original commit to add apps support to the CLI and add the yaml file-support as an override (the apps routes are already apart of the Go SDK and are available for use in the CLI)

NOTE: this feature is still private preview. CLI usage will be internal only

Tests

@@ -0,0 +1,61 @@
package apps
Copy link
Contributor Author

@taiga-db taiga-db Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tldr: support:

databricks app create --manifest @/manifest.yaml --resources @/resources.yaml
databricks app create --json '{"manifest".:{......'

throws an error if neither manifest nor json arguments are supplied

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: also supports inline yaml string (like the --json flag does)

@taiga-db taiga-db marked this pull request as ready for review October 26, 2023 19:59
cmd/workspace/apps/apps.go Outdated Show resolved Hide resolved
cmd/workspace/apps/overrides.go Outdated Show resolved Hide resolved
cmd/workspace/apps/overrides.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
libs/flags/yaml_flag.go Outdated Show resolved Hide resolved
libs/flags/yaml_flag.go Show resolved Hide resolved
// TODO: Command.MarkFlagFilename()
func (y *YamlFlag) Set(v string) error {
// Load request from file
buf, err := os.ReadFile(v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the flag is actually a file flag. The JSON flag accepts both raw JSON or a JSON file name, but the latter requires a prefix of @ to indicate it is a file name (similar to how curl does this).

Up to you how you want to deal with this. I prefer symmetry with the behavior of the JSON flag, or otherwise you can rename this to YamlFileFlag, store the filename, and read the file on demand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in our case, the flags are --manifest and --resource would --@manifest be preferred if we are dealing exclusively with files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean an @ prefix on the value that's set.

Also see:

func (j *JsonFlag) Set(v string) error {
// Load request from file if it starts with '@' (like curl).
if v[0] != '@' {
j.raw = []byte(v)
return nil
}
buf, err := os.ReadFile(v[1:])
if err != nil {
return fmt.Errorf("read %s: %w", v, err)
}
j.raw = buf
return nil
}

Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @taiga-db !

@pietern pietern changed the title Add an override to support yaml file input in apps Add override to support YAML inputs for apps Oct 27, 2023
@pietern pietern enabled auto-merge October 27, 2023 15:32
auto-merge was automatically disabled October 27, 2023 17:39

Head branch was pushed to by a user without write access

@taiga-db
Copy link
Contributor Author

note: had to force-push new commits so I can retroactively sign them

@taiga-db
Copy link
Contributor Author

jenkins merge

@pietern pietern added this pull request to the merge queue Oct 27, 2023
Merged via the queue into databricks:main with commit e408b70 Oct 27, 2023
4 checks passed
@taiga-db taiga-db deleted the tm-lha-override branch October 27, 2023 19:56
@shreyas-goenka shreyas-goenka mentioned this pull request Nov 2, 2023
shreyas-goenka added a commit that referenced this pull request Nov 2, 2023
CLI:
 * Fix URL for bundle template documentation ([#903](#903)).
 * Library to convert config.Value to Go struct ([#904](#904)).
 * Loading an empty file yields a nil ([#906](#906)).
 * Fix pattern validation for input properties ([#912](#912)).
 * Simplified code generation logic for handling path and request body parameters and JSON input ([#905](#905)).
 * Add support for multiline descriptions when using template enums ([#916](#916)).
 * Move bundle configuration filename code ([#917](#917)).
 * Add configuration normalization code ([#915](#915)).
 * Add welcome message to bundle templates ([#907](#907)).
 * Consolidate bundle configuration loader function ([#918](#918)).
 * Upload terraform state even if apply fails ([#923](#923)).
 * Use UserName instead of Id to check if identity used is a service principal ([#924](#924)).
 * `make snapshot` to build file in `.databricks/databricks` ([#927](#927)).
 * Persist deployment metadata in WSFS ([#845](#845)).
 * Run make fmt from fmt job ([#929](#929)).
 * Add override to support YAML inputs for apps ([#921](#921)).
 * Add GitHub issue templates ([#925](#925)).
 * Remove resolution of repo names against the Databricks Github account ([#940](#940)).
 * Fix metadata computation for empty bundle ([#939](#939)).

Bundles:
 * **FILL THIS IN MANUALLY BY MOVING RELEVANT ITEMS FROM ABOVE LIST**

Internal:
 * **FILL THIS IN MANUALLY BY MOVING RELEVANT ITEMS FROM ABOVE LIST**

API Changes:
 * Added `databricks apps` command group.
 * Added `databricks account network-policy` command group.

OpenAPI commit 5903bb39137fd76ac384b2044e425f9c56840e00 (2023-10-23)
Dependency updates:
 * Bump google.golang.org/grpc from 1.58.2 to 1.58.3 ([#920](#920)).
 * Bump the Go SDK in the CLI ([#919](#919)).
 * Bump Terraform provider to v1.29.0 ([#926](#926)).
 * Bump github.com/google/uuid from 1.3.1 to 1.4.0 ([#932](#932)).
github-merge-queue bot pushed a commit that referenced this pull request Nov 2, 2023
CLI:
* Added GitHub issue templates for CLI and DABs issues
([#925](#925)).
* Added override to support YAML inputs for apps
([#921](#921)).
* Simplified code generation logic for handling path and request body
parameters and JSON input
([#905](#905)).


Bundles:
* Fixed URL for bundle template documentation in init command help docs
([#903](#903)).
* Fixed pattern validation for input parameters in a bundle template
([#912](#912)).
* Fixed multiline description rendering for enum input parameters in
bundle templates ([#916](#916)).
* Changed production mode check for whether identity used is a service
principal to use UserName
([#924](#924)).
* Changed bundle deploy to upload partial terraform state even if
deployment fails ([#923](#923)).
* Added support for welcome messages to bundle templates
([#907](#907)).
* Added support for uploading bundle deployment metadata to WSFS
([#845](#845)).


Internal:
* Loading an empty yaml file yields a nil
([#906](#906)).
* Library to convert config.Value to Go struct
([#904](#904)).
* Remove default resolution of repo names against the Databricks Github
account([#940](#940)).
* Run make fmt from fmt job
([#929](#929)).
* `make snapshot` to build file in `.databricks/databricks`
([#927](#927)).
* Add configuration normalization code
([#915](#915)).

API Changes:
 * Added `databricks apps` command group.
 * Added `databricks account network-policy` command group.

Dependency updates:
* Bump Terraform provider from v1.28.0 to v1.29.0
([#926](#926)).
* Bump the Go SDK in the CLI from v0.23 to v0.24
([#919](#919)).
* Bump google.golang.org/grpc from 1.58.2 to 1.58.3
([#920](#920)).
* Bump github.com/google/uuid from 1.3.1 to 1.4.0
([#932](#932)).

OpenAPI commit 5903bb39137fd76ac384b2044e425f9c56840e00 (2023-10-23)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants