-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call the web when layers have been pushed (#2139)
* Call the web when layers have been pushed * Creates an http client that decorates requests with user agent and authentication. * Adds a monobeam client * Adds a web client * Adds a manifest function to the command * Looks up the manifest from the image and fills in the necessary variables to send to web on version push * Fix fast push tests * Add back progress bars * Fix lint issues * Add more tests * Add web/monobeam client tests * Use correct var name for environment * Use any instead of interface{} * Change command variable name to dockerCommand * Fix parsing open API Schema correctly * And add test verifying these are two separate variables * Use strings Cut on env vars --------- Signed-off-by: Will Sackfield <[email protected]>
- Loading branch information
Showing
43 changed files
with
1,440 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
package docker | ||
package command | ||
|
||
type Command interface { | ||
Push(string) error | ||
LoadLoginToken(string) (string, error) | ||
LoadUserInformation(string) (*UserInfo, error) | ||
CreateTarFile(string, string, string, string) (string, error) | ||
CreateAptTarFile(string, string, ...string) (string, error) | ||
} | ||
|
||
type CredentialHelperInput struct { | ||
Username string | ||
Secret string | ||
ServerURL string | ||
Inspect(string) (*Manifest, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package command | ||
|
||
import "github.com/replicate/cog/pkg/global" | ||
|
||
type Config struct { | ||
Labels map[string]string `json:"Labels"` | ||
Env []string `json:"Env"` | ||
} | ||
|
||
type Manifest struct { | ||
Config Config `json:"Config"` | ||
} | ||
|
||
const UvPythonInstallDirEnvVarName = "UV_PYTHON_INSTALL_DIR" | ||
const R8TorchVersionEnvVarName = "R8_TORCH_VERSION" | ||
const R8CudaVersionEnvVarName = "R8_CUDA_VERSION" | ||
const R8CudnnVersionEnvVarName = "R8_CUDNN_VERSION" | ||
const R8PythonVersionEnvVarName = "R8_PYTHON_VERSION" | ||
|
||
var CogConfigLabelKey = global.LabelNamespace + "config" | ||
var CogVersionLabelKey = global.LabelNamespace + "version" | ||
var CogOpenAPISchemaLabelKey = global.LabelNamespace + "openapi_schema" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package command | ||
|
||
type UserInfo struct { | ||
Token string | ||
Username string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package docker | ||
|
||
type CredentialHelperInput struct { | ||
Username string | ||
Secret string | ||
ServerURL string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package docker | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDockerPush(t *testing.T) { | ||
t.Setenv(DockerCommandEnvVarName, "echo") | ||
|
||
command := NewDockerCommand() | ||
err := command.Push("test") | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package docker | ||
|
||
import "os" | ||
|
||
const DockerCommandEnvVarName = "R8_DOCKER_COMMAND" | ||
|
||
func DockerCommandFromEnvironment() string { | ||
command := os.Getenv(DockerCommandEnvVarName) | ||
if command == "" { | ||
command = "docker" | ||
} | ||
return command | ||
} |
Oops, something went wrong.