@@ -22,7 +22,6 @@ import (
2222 "github.com/docker/infrakit/pkg/spi/group"
2323 "github.com/docker/infrakit/pkg/spi/metadata"
2424 "github.com/docker/infrakit/pkg/types"
25- "github.com/sergi/go-diff/diffmatchpatch"
2625 "github.com/spf13/cobra"
2726)
2827
@@ -237,111 +236,6 @@ func Command(plugins func() discovery.Plugins) *cobra.Command {
237236 },
238237 }
239238
240- ///////////////////////////////////////////////////////////////////////////////////
241- // change
242- change := & cobra.Command {
243- Use : "change" ,
244- Short : "Change returns the plugin configurations known by the manager" ,
245- }
246- vars := change .Flags ().StringSlice ("var" , []string {}, "key=value pairs" )
247- commitChange := change .Flags ().BoolP ("commit" , "c" , false , "Commit changes" )
248-
249- // This is the only interactive command. We want to show the user the proposal, with the diff
250- // and when the user accepts the change, call a commit.
251- change .RunE = func (cmd * cobra.Command , args []string ) error {
252-
253- if len (args ) != 0 {
254- cmd .Usage ()
255- os .Exit (1 )
256- }
257-
258- // get the changes
259- changes , err := changeSet (* vars )
260- if err != nil {
261- return err
262- }
263- current , proposed , cas , err := updatablePlugin .Changes (changes )
264- if err != nil {
265- return err
266- }
267- currentBuff , err := current .MarshalYAML ()
268- if err != nil {
269- return err
270- }
271-
272- proposedBuff , err := proposed .MarshalYAML ()
273- if err != nil {
274- return err
275- }
276-
277- if * commitChange {
278- fmt .Printf ("Committing changes, hash=%s\n " , cas )
279- } else {
280- fmt .Printf ("Proposed changes, hash=%s\n " , cas )
281- }
282-
283- // Render the delta
284- dmp := diffmatchpatch .New ()
285- diffs := dmp .DiffMain (string (currentBuff ), string (proposedBuff ), false )
286- fmt .Println (dmp .DiffPrettyText (diffs ))
287-
288- if * commitChange {
289- return updatablePlugin .Commit (proposed , cas )
290- }
291-
292- return nil
293- }
294- change .Flags ().AddFlagSet (templateFlags )
295-
296- ///////////////////////////////////////////////////////////////////////////////////
297- // change-list
298- changeList := & cobra.Command {
299- Use : "ls" ,
300- Short : "Lists all the changeable paths" ,
301- RunE : func (cmd * cobra.Command , args []string ) error {
302-
303- if len (args ) != 0 {
304- cmd .Usage ()
305- os .Exit (1 )
306- }
307-
308- all , err := types .ListAll (updatablePlugin , types .PathFromString ("." ))
309- if err != nil {
310- return err
311- }
312-
313- types .SortPaths (all )
314- for _ , p := range all {
315- fmt .Println (p .String ())
316- }
317- return nil
318- },
319- }
320- ///////////////////////////////////////////////////////////////////////////////////
321- // change-cat
322- changeGet := & cobra.Command {
323- Use : "cat" ,
324- Short : "Cat returns the current value at given path" ,
325- RunE : func (cmd * cobra.Command , args []string ) error {
326-
327- if len (args ) != 1 {
328- cmd .Usage ()
329- os .Exit (1 )
330- }
331-
332- path := types .PathFromString (args [0 ])
333- any , err := updatablePlugin .Get (path )
334- if err != nil {
335- return err
336- }
337-
338- fmt .Println (any .String ())
339-
340- return nil
341- },
342- }
343- change .AddCommand (changeList , changeGet )
344-
345239 cmd .AddCommand (commit , inspect , leader )
346240
347241 return cmd
0 commit comments