...

Source file src/github.com/redhat-developer/odo/pkg/dev/common/attributes.go

Documentation: github.com/redhat-developer/odo/pkg/dev/common

     1  package common
     2  
     3  import (
     4  	"path/filepath"
     5  	"strings"
     6  
     7  	"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
     8  )
     9  
    10  const _devPushPathAttributePrefix = "dev.odo.push.path:"
    11  
    12  // GetSyncFilesFromAttributes gets the target files and folders along with their respective remote destination from the devfile.
    13  // It uses the "dev.odo.push.path:" attribute prefix, if any, in the specified command.
    14  func GetSyncFilesFromAttributes(command v1alpha2.Command) map[string]string {
    15  	syncMap := make(map[string]string)
    16  	for key, value := range command.Attributes.Strings(nil) {
    17  		if strings.HasPrefix(key, _devPushPathAttributePrefix) {
    18  			localValue := strings.ReplaceAll(key, _devPushPathAttributePrefix, "")
    19  			syncMap[filepath.Clean(localValue)] = filepath.ToSlash(filepath.Clean(value))
    20  		}
    21  	}
    22  	return syncMap
    23  }
    24  

View as plain text