# class Chef::Knife::EnvironmentFromFile

### Public Instance Methods

environments_path() click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 39
    def environments_path
      @environments_path ||= "environments"
    end

find_all_environments() click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 43
    def find_all_environments
      loader.find_all_objects("./#{environments_path}/")
    end

load_all_environments() click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 47
    def load_all_environments
      environments = find_all_environments
      if environments.empty?
        ui.fatal("Unable to find any environment files in '#{environments_path}'")
        exit(1)
      end
      environments.each do |env|
        load_environment(env)
      end
    end

load_environment(env) click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 58
    def load_environment(env)
      updated = loader.load_from("environments", env)
      updated.save
      output(format_for_display(updated)) if config[:print_after]
      ui.info("Updated Environment #{updated.name}")
    end

loader() click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 35
    def loader
      @loader ||= Knife::Core::ObjectLoader.new(Chef::Environment, ui)
    end

run() click to toggle source

    # File lib/chef/knife/environment_from_file.rb, line 66
    def run
      if config[:all] == true
        load_all_environments
      else
        if @name_args[0].nil?
          show_usage
          ui.fatal("You must specify a file to load")
          exit 1
        end

        @name_args.each do |arg|
          load_environment(arg)
        end
      end
    end