diff --git a/go.mod b/go.mod index c19418a..cfd3724 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gofrs/uuid v4.3.0+incompatible github.com/gorilla/websocket v1.5.0 github.com/iancoleman/strcase v0.2.0 - github.com/koyeb/koyeb-api-client-go v0.0.0-20250106150959-2940e5613765 + github.com/koyeb/koyeb-api-client-go v0.0.0-20250117143439-03648cc5a823 github.com/logrusorgru/aurora v2.0.3+incompatible github.com/manifoldco/promptui v0.9.0 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index d5e8c0d..9875844 100644 --- a/go.sum +++ b/go.sum @@ -172,6 +172,8 @@ github.com/koyeb/koyeb-api-client-go v0.0.0-20241206143543-39fbd0d0bf5e h1:/pSED github.com/koyeb/koyeb-api-client-go v0.0.0-20241206143543-39fbd0d0bf5e/go.mod h1:+oQfFj2WL3gi9Pb+UHbob4D7xaT52mPfKyH1UvWa4PQ= github.com/koyeb/koyeb-api-client-go v0.0.0-20250106150959-2940e5613765 h1:OaJezhu0iuR0XN6y5Sxc6uARWyPx1WG1ZjBgVgG7jvw= github.com/koyeb/koyeb-api-client-go v0.0.0-20250106150959-2940e5613765/go.mod h1:+oQfFj2WL3gi9Pb+UHbob4D7xaT52mPfKyH1UvWa4PQ= +github.com/koyeb/koyeb-api-client-go v0.0.0-20250117143439-03648cc5a823 h1:icM+7zADUhhsv1DSXVHdT3UusXWOsZ25aolFPmhgPiU= +github.com/koyeb/koyeb-api-client-go v0.0.0-20250117143439-03648cc5a823/go.mod h1:+oQfFj2WL3gi9Pb+UHbob4D7xaT52mPfKyH1UvWa4PQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= diff --git a/pkg/koyeb/flags_list/file_mounts.go b/pkg/koyeb/flags_list/file_mounts.go index 8c2dfe1..bca2efc 100644 --- a/pkg/koyeb/flags_list/file_mounts.go +++ b/pkg/koyeb/flags_list/file_mounts.go @@ -17,9 +17,9 @@ type FlagFile struct { content string } -func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], error) { - return func(values []string) ([]Flag[koyeb.File], error) { - ret := make([]Flag[koyeb.File], 0, len(values)) +func GetNewConfigFilestListFromFlags() func(values []string) ([]Flag[koyeb.ConfigFile], error) { + return func(values []string) ([]Flag[koyeb.ConfigFile], error) { + ret := make([]Flag[koyeb.ConfigFile], 0, len(values)) for _, value := range values { hc := &FlagFile{BaseFlag: BaseFlag{cliValue: value}} @@ -29,13 +29,13 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro if len(components) > 1 { return nil, &kerrors.CLIError{ What: "Error while configuring the service", - Why: fmt.Sprintf("unable to parse the file flag value \"%s\"", hc.cliValue), + Why: fmt.Sprintf("unable to parse the config-file flag value \"%s\"", hc.cliValue), Additional: []string{ - "To remove a mounted file from the service, prefix the path with '!', e.g. '!path'", + "To remove a mounted config file from the service, prefix the path with '!', e.g. '!path'", "The source should not be specified to remove it from the service", }, Orig: nil, - Solution: "Fix the file flag value and try again", + Solution: "Fix the config-file flag value and try again", } } hc.markedForDeletion = true @@ -44,13 +44,13 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro if len(components) != 2 && len(components) != 3 { return nil, &kerrors.CLIError{ What: "Error while configuring the service", - Why: fmt.Sprintf("unable to parse the file flag value \"%s\"", hc.cliValue), + Why: fmt.Sprintf("unable to parse the confi-file flag value \"%s\"", hc.cliValue), Additional: []string{ - "File flag value must be specified as SOURCE:PATH[:PERMISSIONS]", - "To remove a mounted file from the service, prefix the path with '!', e.g. '!path'", + "Config file flag value must be specified as SOURCE:PATH[:PERMISSIONS]", + "To remove a mounted config file from the service, prefix the path with '!', e.g. '!path'", }, Orig: nil, - Solution: "Fix the file flag value and try again", + Solution: "Fix the config-file flag value and try again", } } hc.path = components[1] @@ -60,11 +60,11 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro What: "Error while configuring the service", Why: fmt.Sprintf(" Unable to locate file at \"%s\"", path), Additional: []string{ - "File flag value must be specified as SOURCE:PATH[:PERMISSIONS]", - "To remove a mounted file from the service, prefix the path with '!', e.g. '!path'", + "Config file flag value must be specified as SOURCE:PATH[:PERMISSIONS]", + "To remove a mounted config file from the service, prefix the path with '!', e.g. '!path'", }, Orig: nil, - Solution: "Fix the file flag value and try again", + Solution: "Fix the config-file flag value and try again", } } data, err := os.ReadFile(path) @@ -73,11 +73,11 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro What: "Error while configuring the service", Why: fmt.Sprintf("unable to read the file \"%s\"", path), Additional: []string{ - "File flag value must be specified as SOURCE:PATH[:PERMISSIONS]", - "To remove a file mount from the service, prefix it with '!', e.g. '!path'", + "Config file flag value must be specified as SOURCE:PATH[:PERMISSIONS]", + "To remove a config file mount from the service, prefix it with '!', e.g. '!path'", }, Orig: nil, - Solution: "Fix the file flag value and try again", + Solution: "Fix the config-file flag value and try again", } } hc.content = string(data) @@ -92,10 +92,10 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro Why: fmt.Sprintf("unable to parse the permissions \"%s\"", permissions), Additional: []string{ "File mount permission must be specified as SOURCE:PATH:PERMISSIONS and in format like 0644", - "To remove a file mount from the service, prefix it with '!', e.g. '!path'", + "To remove a config file mount from the service, prefix it with '!', e.g. '!path'", }, Orig: nil, - Solution: "Fix the permissions in file flag value and try again", + Solution: "Fix the permissions in config-file flag value and try again", } } hc.permissions = permissions @@ -106,18 +106,18 @@ func GetNewFilestListFromFlags() func(values []string) ([]Flag[koyeb.File], erro } } -func (f *FlagFile) IsEqualTo(hc koyeb.File) bool { +func (f *FlagFile) IsEqualTo(hc koyeb.ConfigFile) bool { return hc.GetPath() == f.path } -func (f *FlagFile) UpdateItem(hc *koyeb.File) { +func (f *FlagFile) UpdateItem(hc *koyeb.ConfigFile) { hc.Content = &f.content hc.Path = &f.path hc.Permissions = &f.permissions } -func (f *FlagFile) CreateNewItem() *koyeb.File{ - item := koyeb.NewFileWithDefaults() +func (f *FlagFile) CreateNewItem() *koyeb.ConfigFile{ + item := koyeb.NewConfigFileWithDefaults() f.UpdateItem(item) return item } diff --git a/pkg/koyeb/services.go b/pkg/koyeb/services.go index 42f21d0..b38c6bc 100644 --- a/pkg/koyeb/services.go +++ b/pkg/koyeb/services.go @@ -378,10 +378,11 @@ func (h *ServiceHandler) addServiceDefinitionFlagsForAllSources(flags *pflag.Fla "To delete a volume, use !VOLUME, for example --volume '!myvolume'\n", ) flags.StringSlice( - "file", + "config-file", nil, - "Mount a copy of local file as a file in the service container using the format LOCAL_FILE:PATH:[PERMISSIONS] for example --file /etc/data.yaml:/etc/data.yaml:0644\n"+ - "To delete a file mount, use !PATH, for example --file !/etc/data.yaml\n", + "Mount a copy of local file as a file in the service container using the format LOCAL_FILE:PATH:[PERMISSIONS]\n"+ + "for example --config-file /etc/data.yaml:/etc/data.yaml:0644\n"+ + "To delete a file mount, use !PATH, for example --config-file !/etc/data.yaml\n", ) // Configure aliases: for example, allow user to use --port instead of --ports @@ -556,11 +557,11 @@ func (h *ServiceHandler) parseServiceDefinitionFlags(ctx *CLIContext, flags *pfl } definition.SetVolumes(volumes) - files, err := h.parseFiles(ctx, flags, definition.Files) + files, err := h.parseConfigFiles(ctx, flags, definition.ConfigFiles) if err != nil { return err } - definition.SetFiles(files) + definition.SetConfigFiles(files) return nil } @@ -1754,9 +1755,9 @@ func (h *ServiceHandler) parseVolumes(ctx *CLIContext, flags *pflag.FlagSet, cur return parseListFlags("volumes", flags_list.GetNewVolumeListFromFlags(wrappedResolveVolumeId), flags, currentVolumes) } -// Parse --file -func (h *ServiceHandler) parseFiles(ctx *CLIContext, flags *pflag.FlagSet, currentFiles []koyeb.File) ([]koyeb.File, error) { - return parseListFlags("file", flags_list.GetNewFilestListFromFlags(), flags, currentFiles) +// Parse --config-file +func (h *ServiceHandler) parseConfigFiles(ctx *CLIContext, flags *pflag.FlagSet, currentFiles []koyeb.ConfigFile) ([]koyeb.ConfigFile, error) { + return parseListFlags("config-file", flags_list.GetNewConfigFilestListFromFlags(), flags, currentFiles) } // DeploymentStrategy is a type alias for koyeb.DeploymentStrategyType which implements the pflag.Value interface.