This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
matchable_plugin_override.go
87 lines (68 loc) · 3.26 KB
/
matchable_plugin_override.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package update
import (
"context"
"fmt"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
sconfig "github.com/flyteorg/flytectl/cmd/config/subcommand"
pluginoverride "github.com/flyteorg/flytectl/cmd/config/subcommand/plugin_override"
cmdCore "github.com/flyteorg/flytectl/cmd/core"
)
const (
pluginOverrideShort = "Update matchable resources of plugin overrides"
pluginOverrideLong = `
Update plugin overrides for given project and domain combination or additionally with workflow name.
Updating to the plugin override is only available from a generated file. See the get section for generating this file.
This will completely overwrite any existing plugins overrides on custom project, domain, and workflow combination.
It is preferable to do get and generate a plugin override file if there is an existing override already set and then update it to have new values.
Refer to get plugin-override section on how to generate this file
It takes input for plugin overrides from the config file po.yaml,
Example: content of po.yaml:
.. code-block:: yaml
domain: development
project: flytesnacks
overrides:
- task_type: python_task # Task type for which to apply plugin implementation overrides
plugin_id: # Plugin id(s) to be used in place of the default for the task type.
- plugin_override1
- plugin_override2
missing_plugin_behavior: 1 # Behavior when no specified plugin_id has an associated handler. 0 : FAIL , 1: DEFAULT
::
flytectl update plugin-override --attrFile po.yaml
Update plugin override for project, domain, and workflow combination. This will take precedence over any other
plugin overrides defined at project domain level.
For workflow 'core.control_flow.merge_sort.merge_sort' in flytesnacks project, development domain, it is:
.. code-block:: yaml
domain: development
project: flytesnacks
workflow: core.control_flow.merge_sort.merge_sort
overrides:
- task_type: python_task # Task type for which to apply plugin implementation overrides
plugin_id: # Plugin id(s) to be used in place of the default for the task type.
- plugin_override1
- plugin_override2
missing_plugin_behavior: 1 # Behavior when no specified plugin_id has an associated handler. 0 : FAIL , 1: DEFAULT
::
flytectl update plugin-override --attrFile po.yaml
Usage
`
)
func updatePluginOverridesFunc(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) error {
updateConfig := pluginoverride.DefaultUpdateConfig
if len(updateConfig.AttrFile) == 0 {
return fmt.Errorf("attrFile is mandatory while calling update for plugin override")
}
pluginOverrideFileConfig := pluginoverride.FileConfig{}
if err := sconfig.ReadConfigFromFile(&pluginOverrideFileConfig, updateConfig.AttrFile); err != nil {
return err
}
// Get project domain workflow name from the read file.
project := pluginOverrideFileConfig.Project
domain := pluginOverrideFileConfig.Domain
workflowName := pluginOverrideFileConfig.Workflow
if err := DecorateAndUpdateMatchableAttr(ctx, cmdCtx, project, domain, workflowName,
admin.MatchableResource_PLUGIN_OVERRIDE, pluginOverrideFileConfig,
updateConfig.DryRun, updateConfig.Force); err != nil {
return err
}
return nil
}