fix do not watch remote files in dev mode
@@ -125,7 +125,7 @@ func (o *runCmdOptions) validateArgs(_ *cobra.Command, args []string) error {
}
for _, fileName := range args {
- if !strings.HasPrefix(fileName, "http://") && !strings.HasPrefix(fileName, "https://") {
+ if !isRemoteHTTPFile(fileName) {
if _, err := os.Stat(fileName); err != nil && os.IsNotExist(err) {
return errors.Wrap(err, "file "+fileName+" does not exist")
} else if err != nil {
@@ -265,6 +265,7 @@ func (o *runCmdOptions) waitForIntegrationReady(integration *v1alpha1.Integratio
func (o *runCmdOptions) syncIntegration(c client.Client, sources []string) error {
for _, s := range sources {
+ if !isRemoteHTTPFile(s) {
changes, err := sync.File(o.Context, s)
if err != nil {
return err
@@ -282,6 +283,9 @@ func (o *runCmdOptions) syncIntegration(c client.Client, sources []string) error
}
}
}()
+ } else {
+ fmt.Printf("WARNING: the following URL will not be watched for changes: %s\n", s)
+ }
}
return nil
@@ -457,7 +461,7 @@ func (*runCmdOptions) loadData(fileName string, compress bool) (string, error) {
var content []byte
var err error
- if !strings.HasPrefix(fileName, "http://") && !strings.HasPrefix(fileName, "https://") {
+ if !isRemoteHTTPFile(fileName) {
content, err = ioutil.ReadFile(fileName)
if err != nil {
return "", err
@@ -523,3 +527,7 @@ func (*runCmdOptions) configureTrait(integration *v1alpha1.Integration, config s
integration.Spec.Traits[traitID] = spec
return nil
}
+
+func isRemoteHTTPFile(fileName string) bool {
+ return strings.HasPrefix(fileName, "http://") || strings.HasPrefix(fileName, "https://")
+}
