-
Notifications
You must be signed in to change notification settings - Fork 64
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
Enable offline install of labs projects in environment with no internet access #2049
base: main
Are you sure you want to change the base?
Conversation
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we shouldn't remove this file.
cmd := &cobra.Command{} | ||
var offlineInstall bool | ||
|
||
cmd.Flags().BoolVar(&offlineInstall, "offline-install", offlineInstall, `If installing in offline mode, set this flag to true.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can call it just offline
as it part of the install
command anyway
func (r *ReleaseCache) LoadCache(ctx context.Context) (Versions, error) { | ||
cached, err := r.Cache.LoadCache() | ||
return cached.Data, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add offline install flag to the ReleaseCache struct, and then modify Load
to behave differently depending if it's offline install vs. online install.
Then we won't need code like this:
if offlineInstall {
versions, err = github.NewReleaseCache("databrickslabs", f.name, cacheDir).LoadCache(ctx)
} else {
versions, err = github.NewReleaseCache("databrickslabs", f.name, cacheDir).Load(ctx)
}
err = i.downloadLibrary(ctx) | ||
if err != nil { | ||
return fmt.Errorf("lib: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that the library to install exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are assuming that if they are running it in offline, the library code should be available locally. But yes we could add a check to see if it exists and raise an error if its not instead of letting it fail
Changes
This PR makes changes to labs code base to allow for offline install of labs project (like UCX). by passing a flag --offline-install=true, the code will skip checking for project versions, and downloading code from github and instead will look from local installation folder. It is expected that the user will download and copy the code from other machine where it can install labs project and then run installation on the machine which has internet restriction.
Closes #1646
related to databrickslabs/ucx#3418
Tests
Added unit test case and tested.