self.parse_install_commands

in lib/instance_agent/plugins/codedeploy/install_instruction.rb [20:46]


        def self.parse_install_commands(contents)
          instructions = JSON.parse(contents)['instructions']
          commands = []
          instructions.each do |mapping|
            case mapping['type']
            when "copy"
              commands << CopyCommand.new(mapping["source"], mapping["destination"])
            when "mkdir"
              commands << MakeDirectoryCommand.new(mapping["directory"])
            when "chmod"
              commands << ChangeModeCommand.new(mapping['file'], mapping['mode'])
            when "chown"
              commands << ChangeOwnerCommand.new(mapping['file'], mapping['owner'], mapping['group'])
            when "setfacl"
              commands << ChangeAclCommand.new(mapping['file'], InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::AclInfo.new(mapping['acl']))
            when "semanage"
              if !mapping['context']['role'].nil?
                raise "The deployment failed because the application specification file specifies a role, but roles are not supported. Remove the role from the AppSpec file, and then try again."
              end
              commands << ChangeContextCommand.new(mapping['file'], InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ContextInfo.new(mapping['context']))
            else
              raise "Unknown command: #{mapping}"
            end
          end
          commands
        end