Crate oci_cfg

source ·
Expand description

This is a small library to manage an Oracle Cloud Infrastructure (OCI) config file. The library checks, whether a file already exists, before it writes the config into the sub-directory within the user’s home directory. It also checks the permissions before adding content.

More information about the config file itself can be found in the official documentation under: https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm

§Example

use oci_cfg::{profile, credentials, content};
 
fn main() {
   profile(
    "ocid1.user.oc1..aaaaaaaaxxxxxx",
    "ocid1.fingerprint.oc1..aaaaaaaaxxxxxx",
    "path/to/private/key",
    "ocid1.tenancy.oc1..aaaaaaaaxxxxxx",
    "IAD"
   );
   credentials(
    "ocid1.user.oc1..aaaaaaaaxxxxxx",
    "ocid1.fingerprint.oc1..aaaaaaaaxxxxxx",
    "path/to/private/key",
    "passphrase"
   );
   content();
}

Modules§

  • The file module contains helper functions to create, read the content and check the permissions of the config file. It stores the API configuration in a file located in a hidden sub-directory of a user’s home.
  • The log module provides options for logging configurations. It contains the ‘LogLevel’ and ‘LogOutput’ enums, and the ‘Logging’ struct. The ‘LogLevel’ enum represents different levels for logging.The ‘LogOutput’ enum represents optional destinations for logging. The ‘Logging’ struct contains the configuration options for controlling logging.
  • The region modules provides functions to convert region codes into the corresponding identifier. Regions are represented as an enum and a given code is translated to a string that represents the home region in the tenancy profile. The home region is the region where the user’s tenancy is located, it is used to set the default region for the user’s resources.

Structs§

  • represents an admin profile with the user’s OCID, fingerprint, path to the private key and the passphrase.
  • represents a tenancy profile with the user’s OCID, fingerprint, path to the private key, OCID of the tenancy and the region.

Functions§

  • reads and returns the content of a config file as a string.
  • adds user credentials to the config file to authenticate the user and to provide access to a defined tenancy.
  • writes an account profile to the config file, the values are used as defaults for admin users.