@@ -53,6 +53,60 @@ var agentRunWorkflowCmd = &cobra.Command{
53
53
},
54
54
}
55
55
56
+ var inventoryCmd = & cobra.Command {
57
+ Use : "inventory" ,
58
+ Short : "Manage inventory with AES encryption" ,
59
+ }
60
+
61
+ var encryptInventoryCmd = & cobra.Command {
62
+ Use : "encrypt" ,
63
+ Run : func (cmd * cobra.Command , args []string ) {
64
+ inventoryFile , _ := cmd .Flags ().GetString ("inventory" )
65
+ encryptionKey , _ := cmd .Flags ().GetString ("encryption-key" )
66
+
67
+ encryptedInventory , err := storm .NewInventory ().Encrypt (inventoryFile , encryptionKey )
68
+ if err != nil {
69
+ fmt .Println (err )
70
+
71
+ os .Exit (1 )
72
+ }
73
+
74
+ fmt .Println (* encryptedInventory )
75
+ },
76
+ }
77
+
78
+ var decryptInventoryCmd = & cobra.Command {
79
+ Use : "decrypt" ,
80
+ Run : func (cmd * cobra.Command , args []string ) {
81
+ encryptedInventory , _ := cmd .Flags ().GetString ("encrypted-inventory" )
82
+ encryptionKey , _ := cmd .Flags ().GetString ("encryption-key" )
83
+ format , _ := cmd .Flags ().GetString ("format" )
84
+
85
+ var byteEncryptedInventory []byte
86
+ var err error
87
+
88
+ if format == "file" {
89
+ byteEncryptedInventory , err = os .ReadFile (encryptedInventory )
90
+ if err != nil {
91
+ fmt .Println (err )
92
+
93
+ os .Exit (1 )
94
+ }
95
+ } else {
96
+ byteEncryptedInventory = []byte (encryptedInventory )
97
+ }
98
+
99
+ decryptedInventory , err := storm .NewInventory ().Decrypt (string (byteEncryptedInventory ), encryptionKey )
100
+ if err != nil {
101
+ fmt .Println (err )
102
+
103
+ os .Exit (1 )
104
+ }
105
+
106
+ fmt .Println (* decryptedInventory )
107
+ },
108
+ }
109
+
56
110
var agentInstallCmd = & cobra.Command {
57
111
Use : "install" ,
58
112
Run : func (cmd * cobra.Command , args []string ) {
@@ -128,6 +182,16 @@ func main() {
128
182
agentRunWorkflowCmd .Flags ().IntP ("format" , "f" , 1 , "available options are; 1 => plain, 2 => struct, 3 => json" )
129
183
agentCmd .AddCommand (agentRunWorkflowCmd )
130
184
185
+ inventoryCmd .AddCommand (encryptInventoryCmd )
186
+ encryptInventoryCmd .Flags ().StringP ("inventory" , "i" , "./inventory.yaml" , "formatio storm inventory" )
187
+
188
+ inventoryCmd .AddCommand (decryptInventoryCmd )
189
+ decryptInventoryCmd .Flags ().StringP ("encrypted-inventory" , "e" , "./inventory.yaml.enc" , "encrypted inventory file" )
190
+ decryptInventoryCmd .Flags ().StringP ("format" , "f" , "file" , "available options are; plain, file" )
191
+
192
+ inventoryCmd .PersistentFlags ().StringP ("encryption-key" , "k" , "" , "encryption key" )
193
+ rootCmd .AddCommand (inventoryCmd )
194
+
131
195
runWorkflowCmd .Flags ().BoolP ("trash-workflow" , "t" , true , "remove workflow file if the workflow is complete" )
132
196
runWorkflowCmd .Flags ().StringP ("directory" , "d" , "." , "directory to run the workflow from" )
133
197
runWorkflowCmd .Flags ().IntP ("format" , "f" , 1 , "available options are; 1 => plain, 2 => struct, 3 => json" )
0 commit comments