jlewi / hydros

hydros automates hydrating and committing configuration
Apache License 2.0
4 stars 0 forks source link

hydros build image gives error https scheme is not supported #81

Open jlewi opened 5 months ago

jlewi commented 5 months ago

Here's the yaml

kind: Image
apiVersion: hydros.dev/v1alpha1
metadata:
  name: frontend
  namespace: foyle
  labels:
    env: dev
spec:
  image: us-west1-docker.pkg.dev/foyle-public/images/frontend
  source:
    - uri: https://github.com/jlewi/foyle.git
      mappings:
        - src: "/frontend/**/*"
  builder:
    gcb:
      project: foyle-public
      bucket : builds-foyle-public
      machineType: 'E2_HIGHCPU_8'
      dockerfile: /frontend/Dockerfile

Here's the stacktrace

Scheme https is not supported
github.com/jlewi/hydros/pkg/tarutil.copyLocalPath
    /Users/jlewi/git_hydros/pkg/tarutil/builder.go:96
github.com/jlewi/hydros/pkg/tarutil.Build
    /Users/jlewi/git_hydros/pkg/tarutil/builder.go:77
github.com/jlewi/hydros/pkg/images.(*Controller).Reconcile
    /Users/jlewi/git_hydros/pkg/images/controller.go:170
github.com/jlewi/hydros/pkg/images.ReconcileFile
    /Users/jlewi/git_hydros/pkg/images/controller.go:485
github.com/jlewi/hydros/cmd/commands.NewBuildCmd.func1
    /Users/jlewi/git_hydros/cmd/commands/build.go:20
github.com/spf13/cobra.(*Command).execute
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944
github.com/spf13/cobra.(*Command).ExecuteC
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068
github.com/spf13/cobra.(*Command).Execute
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
main.main
    /Users/jlewi/git_hydros/cmd/main.go:151
runtime.main
    /opt/homebrew/Cellar/go/1.21.0/libexec/src/runtime/proc.go:267
runtime.goexit
    /opt/homebrew/Cellar/go/1.21.0/libexec/src/runtime/asm_arm64.s:1197
Failed to create tarball gs://builds-foyle-public/foyle-public/images/frontend.462efa18251584f9404a960132d62aa76ba1056a.tgz
github.com/jlewi/hydros/pkg/images.(*Controller).Reconcile
    /Users/jlewi/git_hydros/pkg/images/controller.go:171
github.com/jlewi/hydros/pkg/images.ReconcileFile
    /Users/jlewi/git_hydros/pkg/images/controller.go:485
github.com/jlewi/hydros/cmd/commands.NewBuildCmd.func1
    /Users/jlewi/git_hydros/cmd/commands/build.go:20
github.com/spf13/cobra.(*Command).execute
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944
github.com/spf13/cobra.(*Command).ExecuteC
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068
github.com/spf13/cobra.(*Command).Execute
    /Users/jlewi/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
main.main
    /Users/jlewi/git_hydros/cmd/main.go:151
runtime.main
    /opt/homebrew/Cellar/go/1.21.0/libexec/src/runtime/proc.go:267
runtime.goexit
    /opt/homebrew/Cellar/go/1.21.0/libexec/src/runtime/asm_arm64.s:1197
jlewi commented 5 months ago

So we call tarutil.build https://github.com/jlewi/hydros/blob/2d35fa0424852e34d4916568a9aaa5b46ddc75e4/pkg/images/controller.go#L170

This should end up calling copyLocalPath here https://github.com/jlewi/hydros/blob/2d35fa0424852e34d4916568a9aaa5b46ddc75e4/pkg/tarutil/builder.go#L77

The only scheme that is supported is file https://github.com/jlewi/hydros/blob/2d35fa0424852e34d4916568a9aaa5b46ddc75e4/pkg/tarutil/builder.go#L95

So why would this ever work with a git or https scheme?

Its because when we do build we automatically replace the remotes here https://github.com/jlewi/hydros/blob/2d35fa0424852e34d4916568a9aaa5b46ddc75e4/pkg/images/controller.go#L137

So if there is a problem replacing the remote then we don't get a file URI.

At the very least we should probably surface a more actionable error message somewhere for the user.