anchor.diff:  
   -module(chef_sked).
   
  --include_lib("chef_objects/include/chef_types.hrl").
  --include_lib("chef_objects/include/chef_osc_defaults.hrl").
   -include_lib("chef_certgen/include/chef_certgen.hrl").
  +-include("chef_wm.hrl").
   
   -export([create_client/4,
            create_default_environment/0]).
  
positive.code:     end;
  %% @doc Create a client with the specified `PublicKey'.
  create_client(Name, IsValidator, IsAdmin, PublicKey) ->
      Id = chef_object:make_org_prefix_id(?OSC_ORG_ID, Name),
      Client = #chef_client{id = Id,
                            %% stub authz ID
                            authz_id = Id,
                            org_id = ?OSC_ORG_ID,
                            name = Name,
                            validator = IsValidator =:= true,
                            admin = IsAdmin =:= true,
                            public_key = PublicKey,
                            pubkey_version = key_version(PublicKey)},
      Ctx = chef_db:make_context(make_req_id()),
      chef_db:create_client(Ctx, Client, ?CHEF_SKED_AUTHZ_ID).
  
  %% @doc Create the _default environment
  create_default_environment() ->
      Name = <<"_default">>,
      Json = <<"{\"name\":\"_default\",\"description\":\"The default Chef environment\","
               "\"cookbook_versions\":{},\"json_class\":\"Chef::Environment\","
               "\"chef_type\":\"environment\","
               "\"default_attributes\":{},"
               "\"override_attributes\":{}}">>,
      Data = chef_db_compression:compress(chef_environment, Json),
      Id = chef_object:make_org_prefix_id(?OSC_ORG_ID, Name),
      Env = #chef_environment{id = Id,
                              authz_id = Id,
                              org_id = ?OSC_ORG_ID,
                              name = Name,
                              serialized_object = Data},
      Ctx = chef_db:make_context(make_req_id()),
      chef_db:create_environment(Ctx, Env, ?CHEF_SKED_AUTHZ_ID).
  
  %% Determine the "pubkey_version" of a key or certificate in PEM
  %% format. Certificates are version 1. Public keys in either PKCS1 or
  %% SPKI format are version 0. The PKCS1 format is deprecated, but
  %% supported for read. We will only generate certs or SPKI packaged
  %% keys.
  key_version(<<"-----BEGIN CERTIFICATE", _Bin/binary>>) ->
      %% cert
      1;
  key_version(<<"-----BEGIN PUBLIC KEY", _Bin/binary>>) ->
      %% SPKI
      0;
  key_version(<<"-----BEGIN RSA PUBLIC KEY", _Bin/binary>>) ->
      %% PKCS1
      0.
  
  %% Create a binary string used as the request identifier.
  make_req_id() ->
  
negative.code: %% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92-*-
  %% ex: ts=4 sw=4 et
  %% @author Seth Falcon <seth@opscode.com>
  %% @author Seth Chisamore <schisamo@opscode.com>
  %% @doc A utility module for manipulating OSC Chef objects from the
  %% console.  Sked is Swedish for spoon. Does not work for OPC/OHC.
  %%
  