• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chef's community platform

Supermarket

unit lint ctl-cookbook-testing Inline docs

Supermarket is Chef's community repository for cookbooks, currently hosted at supermarket.chef.io. Supermarket can also run internally, behind-the-firewall.

Umbrella Project: Supermarket

The code is designed to be easy for others to contribute. The goal of the README file is to familiarize you with the project. You can find detailed information about Supermarket at Wiki page.

If you want to contribute to Supermarket, read the contributor's workflow for license information and other helpful tips that aid you in getting started. There are project artifacts such as planning docs, wireframes, recorded demos, and team retrospectives at public Google Drive folder.

If you have questions, feature ideas, or other suggestions, please open a GitHub Issue.

This repository has the code for the Supermarket application and the omnibus definition used to build the deb/rpm packages. Other Supermarket related repositories are:

Development

Configuration

Configure the dotenv keys and secrets. See .env.example for required keys and secrets. docs/CONFIGURING.md page details the not-so-straightforward configuration information required to setup Supermarket working locally.

Local Environment

These instructions are tested and verified on macOS Catalina (10.15).

Dependency Services

As Docker Containers
  1. Install docker

    brew cask install docker

Ensure you have a PostgreSQL version installed on the local filesystem for development libraries to be available for building the pg gem. See the instructions for locally running PostgreSQL below, however omit the steps where the service is running.

  1. Start the docker containers.

    cd src/supermarket
    docker-compose up
As Locally Running Processes
  1. Install Postgres by following any of the below instructions:

    • Install the Postgres App:

      This is probably the simplest way to get Postgres running on your mac. You can then start a Postgres server through the GUI of the app. If you go this route, then you'll have to add /Applications/Postgres.app/Contents/Versions/9.4/bin/ or the equivalent path to obtain the pg gem to build.

    • Through Homebrew:

      brew install postgresql

    When installed through homebrew, Postgres often requires additional configuration, see this blog post for instructions. Ensure to start the Postgresql server by following the command given below.

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
  2. Install Redis. You can install it with Homebrew. Follow the instructions in the install output to start the redis server.

    brew install redis

    Run the redis server using command:

    redis-server --daemonize yes

Development Environment

  1. Ensure you have Xcode installed.

  2. Install a Ruby manager. If you don't already have one, you will need a Ruby manager to install the appropriate Ruby release, such as:

    • RVM
    • Rbenv
    • chruby
    • or any other Ruby version manager that may come along.
  3. Use your ruby manager to install the necessary Ruby release. For instructions on this, please see the manager's documentation.

  4. Ensure you have the Supermarket repo cloned to your machine. If not, clone it.

  5. Navigate to that directory.

    cd <supermarket-repo>
  6. Again, navigate to the src folder.

    cd src/supermarket
  7. Install Bundler gem.

    gem install bundler:2.1.4 --user-install
  8. Install required gems:

    bundle install

    Note: You might encounter the following errors. The possible fixes are also provided here.

  9. Create the database, migrate to it, and then seed the database:

    bundle exec rails db:setup
  10. Add required Postgres extensions.

    psql supermarket_development -c 'create extension plpgsql'
    psql supermarket_development -c 'create extension pg_trgm'

    Note: Ignore if the above 2 commands displays the following error: extension already exists.

  11. Start the server:

    bundle exec foreman start

    Note: If you receive errors, ensure that redis and Postgres are running.

Setting up Auth

Supermarket uses oc-id running on a Chef Infra Server to authenticate users to Supermarket.

IF YOU ARE AN INTERNAL CHEF STAFFER - We will be performing some settings prior to set you up with oc-id. Consult the internal wiki on setting up your Supermarket dev environment (or ask a friendly team member!).

Note: Authentication currently requires a live Chef Infra Server running oc-id. We are working on a solution that would allow a developer to run the authentication locally. Stay tuned.

Create a new application and register it on oc-id (I called my application Application:Supermarket Development). Set the callback URL to http://localhost:3000/auth/chef_oauth2/callback or whatever localhost domain you use.

In your local copy of the Supermarket repo, copy the .env file to .env.development. Open up .env.development and replace these values:

CHEF_OAUTH2_APP_ID=YOUR_CHEF_OAUTH2_APP_ID
CHEF_OAUTH2_SECRET=YOUR_CHEF_OAUTH2_SECRET

with these values:

CHEF_OAUTH2_APP_ID=[Application ID of the oc-id application you just registered]
CHEF_OAUTH2_SECRET=[Secret of the oc-id application you just registered]

Restart your foreman server.

Now, when you click Sign In, you will be taken to your supermarket account with your Chef account!

Note: If you receive an omniauth csrf detected error, try clearing your browser's cache.

SPDX license linking for cookbooks

If a cookbook that has licenseId, which is also mentioned in SPDX license listed at https://github.com/spdx/license-list-data/blob/master/json/licenses.json, you need to update with respective license URL.

When a new cookbook is uploaded, license url information is fetched from the above link and is updated.

For an existing implementation of supermarket, there is a provision running with some ctl commands, for updating the information for cookbooks already there in system.

Following commands are available to update the license URLs for cookbooks:

Update licenses URLs for all the cookbooks in the system

spdx-all

Update for a single cookbook

spdx-latest <cookbook_name>

Update for a particular version of a cookbook

spdx-on-version <cookbook_name> <cookbook_version>

Connecting your GitHub Account

There are a couple of features that depend on GitHub integration (some quality metrics in Fieri) with your development environment. Follow these steps to create an application with your Github account:

  1. Log into your Github account.
  2. Click on your username in the upper right-hand corner. Your Profile page appears.
  3. Click the Edit Profile button in the upper right corner of the Profile page.
  4. Click Applications from the vertical menu on the left-hand side.
  5. Click the Register new Application button from the section labeled Developer applications at the top of the screen.
  6. Specify the name of your application (For example, Chef-Supermarket-Testing), then set the homepage URL as http://localhost:3000 (or whatever localhost domain that you use).
  7. Set the Authorization callback URL to http://localhost:3000 (or your localhost domain of choice).
  8. Click the Register application button.
  9. Open the .env.development file in your local copy of the Supermarket repo.
  10. Replace these values:
GITHUB_KEY=YOUR_GITHUB_KEY
GITHUB_SECRET=YOUR_GITHUB_SECRET

with:

GITHUB_KEY=[Your new application's client ID]
GITHUB_SECRET=[Your new application's client secret]
  1. Next, create a Github Access token. You can also do this from the Applications section of your Profile page.

  2. Navigate to the Personal access tokens section.

  3. Click the Generate new token button.

  4. When prompted, enter your Github password.

  5. Enter the Token description. For example, testing-supermarket.

  6. Leave the scopes at the defaults.

  7. Click the Generate token button.

  8. Copy the token generated and secure it safe!.

  9. Open up your .env.development file again.

  10. Replace this value:

GITHUB_ACCESS_TOKEN=YOUR_GITHUB_ACCESS_TOKEN

with:

GITHUB_ACCESS_TOKEN=[Token you just generated through Github]

Connecting your GitHub Enterprise Account

There are a couple of features that depend on GitHub Enterprise integration (some quality metrics in Fieri) with your development environment. Follow these steps to create an application with your Github account::

  1. Log into your Github Enterprise account.
  2. Click on your username in the upper right-hand corner.
  3. Click User settings in the vertical menu on the right corner. Your public Profile page appears.
  4. Click Developer settings in the vertical menu on the left-hand side.
  5. Click the section labeled Developer settings with text OAuth App at the top of the screen.
  6. Click new OAuth App. You can now register to a new OAuth application page.
  7. Specify the name of your application. (For example, testing-supermarket-app), then set the homepage URL as http://localhost:3000 (or whatever localhost domain that you use).
  8. Set the Authorization callback URL to http://localhost:3000/auth/github/callback (or your localhost domain of choice).
  9. Click the **"Register application button.
  10. Open up the .env.development file in your local copy of the Supermarket repo.
  11. Replace these values:
GITHUB_KEY=YOUR_GITHUB_KEY
GITHUB_SECRET=YOUR_GITHUB_SECRET
GITHUB_ENTERPRISE_URL=YOUR_GITHUB_ENTERPRISE_URL
GITHUB_CLIENT_OPTION_SITE=YOUR_GITHUB_ENTERPRISE_SITE
GITHUB_CLIENT_OPTION_AUTHORIZE_URL=YOUR_GITHUB_ENTERPRISE_AUTHORIZE_URL
GITHUB_CLIENT_OPTION_ACCESS_TOKEN_URL=YOUR_GITHUB_ENTERPRISE_ACCESS_TOKEN_URL

with:

GITHUB_KEY=[Your new application's client ID]
GITHUB_SECRET=[Your new application's client secret]
GITHUB_ENTERPRISE_URL=[Your GitHub Enterprise URL]
GITHUB_CLIENT_OPTION_SITE=YOURGITHUBENTERPRISEURL/api/v3
GITHUB_CLIENT_OPTION_AUTHORIZE_URL=YOURGITHUBENTERPRISEURL/login/oauth/authorize
GITHUB_CLIENT_OPTION_ACCESS_TOKEN_URL=YOURGITHUBENTERPRISEURL/login/oauth/access_token
  1. Next, create a GitHub Access token. You also do this from the Developer settings section.

  2. Click Personal access tokens. The Personal access tokens page appears.

  3. Navigate to the Personal access tokens section.

  4. Click the Generate new token button.

  5. When prompted, enter your GitHub password.

  6. Enter the Token description. For example, testing-supermarket.

  7. Leave the scopes at the defaults.

  8. Click the Generate token button.

  9. Copy the token generated and secure it safe!.

  10. Open up your .env.development file again.

  11. Replace this value:

GITHUB_ACCESS_TOKEN=YOUR_GITHUB_ACCESS_TOKEN

with:

GITHUB_ACCESS_TOKEN=[Token you just generated through Github]

Tests

Requirements for tests: PhantomJS 1.8, Node.

Run the entire test suite (rspec, rubocop and mocha) with:

bundle exec rake spec:all

Acceptance Tests

Acceptance tests are run with Capybara. Run rake spec:features to run the specs in spec/features. The default rake spec also runs these.

When writing feature specs, the Rack::Test driver is used by default. If the Poltergeist driver is required to be used (for example, an acceptance test that uses AJAX), add the use_poltergeist: true metadata to the spec.

Some specs run using PhantomJS, which must be installed for the test suite to pass.

JavaScript Tests

The JavaScript specs are run with Karma and use the Mocha test framework and the Chai Assertion Library.

The specs live in spec/javascripts. Run rake spec:javascripts to run the specs, and rake spec:javascripts:watch to run them continuously and watch for changes.

Node.js is required to run the JavaScript tests.

Background Jobs

Read about Supermarket's background jobs in the wiki.

Feature Flags

Supermarket uses a .env file to configure itself. Inside this file are key/value pairs. These key/value pairs will be exported as environment variables when the app runs, and Supermarket looks for these keys as environment variables when it needs to read a value that's configurable.

One of these keys is called FEATURES and it controls a number of features that can be turned on and off. Here are the available features that can be toggled:

  • tools
  • fieri
  • announcement
  • github
  • no_crawl

More Repositories

1

chef

Chef Infra, a powerful automation platform that transforms infrastructure into code automating how infrastructure is configured, deployed and managed across any environment, at any scale
Ruby
7,596
star
2

bento

Packer templates for building minimal Vagrant baseboxes for multiple platforms
HCL
4,220
star
3

omnibus

Easily create full-stack installers for your project across a variety of platforms.
Ruby
1,269
star
4

ohai

Ohai profiles your system and emits JSON
Ruby
672
star
5

chef-zero

Simple, easy-run, fast-start in-memory Chef server for testing and solo purposes
Ruby
534
star
6

chef-vault

Securely manage passwords, certs, and other secrets in Chef
Ruby
407
star
7

knife-ec2

Chef knife plug-in for AWS EC2
Ruby
403
star
8

chef-server

Chef Infra Server is a hub for configuration data; storing cookbooks, node policies and metadata of managed nodes.
Erlang
279
star
9

automate

Chef Automate provides a full suite of enterprise capabilities for maintaining continuous visibility into application, infrastructure, and security automation.
Go
227
star
10

knife-vsphere

Chef knife plug-in for VMware vSphere
Ruby
202
star
11

knife-windows

Plugin for Chef's knife tool for working with Windows nodes
Ruby
151
star
12

omnibus-software

Open Source Software for use in Omnibus built packages
Ruby
133
star
13

chef-workstation

Chef Workstation gives you everything you need to get started with Chef, so you can automate how you audit, configure, and manage applications end environments.
Go
133
star
14

mixlib-shellout

mixin library for subprocess management, output collection
Ruby
132
star
15

chef-web-docs

All The Documentation
HTML
127
star
16

mixlib-cli

A mixin for creating command line applications - gives an easy DSL for argument specification and processing
Ruby
123
star
17

knife-openstack

Chef Infra knife plug-in for OpenStack
Ruby
120
star
18

cookstyle

A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Ruby
109
star
19

os_release

A repo containing the /etc/os-release file from various Linux distros
81
star
20

chef-oss-practices

Documentation and Practices for Open Source Development at Chef
Ruby
81
star
21

knife-azure

Chef knife plug-in for Microsoft Azure
Ruby
72
star
22

artifactory-client

A simple, lightweight Ruby client for interacting with the Artifactory API.
Ruby
68
star
23

knife-google

Chef knife plug-in for Google Compute
Ruby
67
star
24

win32-service

A Ruby library that allows users to inspect, control or create services on MS Windows
Ruby
65
star
25

mixer

Mix in functions from other modules
Erlang
64
star
26

concrete

Concrete enhances your rebar based Erlang project by providing a common Makefile wrapper, a dialyzer make target that caches PLT analysis of your project's dependencies, and a mechanism to specify development only dependencies.
Erlang
56
star
27

mixlib-config

A simple class based Config mechanism, similar to the one found in Chef
Ruby
51
star
28

sqerl

General purpose RDBMS abstraction layer
Erlang
42
star
29

vscode-chef

Chef Infra Extension for Visual Studio Code
TypeScript
39
star
30

cheffish

Resources and tools for testing and interacting with Chef and Chef Server.
Ruby
39
star
31

knife-tidy

Report on stale Chef Server nodes/cookbooks, clean those up and additionally clean data integrity issues from a knife-ec-backup object based backup!
Ruby
37
star
32

homebrew-chef

A homebrew tap for ChefDK, Workstation, and InSpec
Ruby
36
star
33

mixlib-log

A simple class based Log mechanism, similar to Merb and Chef, that you can mix in to your project.
Ruby
34
star
34

effortless

Automated best practices for Chef Infra and Chef InSpec
Shell
33
star
35

chef-load

chef-load - a tool for simulating load on a Chef Infra Server and/or a Chef Automate server
Roff
32
star
36

knife-ec-backup

Backup and restore Chef Infra Server in a repository-compatible format
Ruby
31
star
37

mini_s3

Minimal AWS S3 client for Erlang
Erlang
28
star
38

okta_aws

Tool for accessing the AWS API for an account you normally access via okta
Python
27
star
39

dep-selector

Fast Dependency Solver for Ruby using Gecode
Ruby
25
star
40

omnitruck

Web service to automate the release of Omnibus artifacts
Ruby
25
star
41

win32-process

A Ruby library that adds or redefines several methods for the Process module
Ruby
25
star
42

kitchen-vcenter

A test-kitchen driver for vCenter REST API
Ruby
25
star
43

omnibus-ctl

Provides service control for omnibus packages
Ruby
23
star
44

mixlib-authentication

AuthN signing and verification. Appears in both the client and server
Ruby
22
star
45

knife-cloud

Library for Chef knife cloud plugins
Ruby
18
star
46

win32-taskscheduler

A Ruby interface for the task scheduler on MS Windows
Ruby
17
star
47

mixlib-versioning

General purpose Ruby library that allows you to parse, compare, and manipulate version strings in multiple formats.
Ruby
17
star
48

win32-eventlog

The win32-eventlog library provides a Ruby interface for reading from and writing to the Windows Event Log
Ruby
17
star
49

chefstyle

Version Pinned RuboCop with Chef approved Cop list for linting software - NOT FOR COOKBOOKS
Ruby
15
star
50

chef-cli

The 'chef' command line tool included in Chef Workstation
Ruby
14
star
51

win32-file

Extra methods, and redefined methods, for the File class on MS Windows
Ruby
14
star
52

anka-buildkite-plugin

Run Buildkite steps inside Veertu Anka Virtual Machines
Shell
14
star
53

appbundler

Generate locked binstubs for ruby applications
Ruby
14
star
54

stats_hero

General purpose stats collection
Erlang
13
star
55

wmi-lite

Lightweight, low-dependency wrapper for basic WMI functionality on Windows.
Ruby
13
star
56

knife-vrealize

Plugin for Chef's knife tool to interact with VMware vRealize products
Ruby
13
star
57

chef-apply

The ad-hoc execution tool for the Chef ecosystem.
Ruby
13
star
58

ffi-libarchive

A Ruby FFI binding to libarchive.
Ruby
13
star
59

mixlib-install

A library for interacting with Chef Software Inc's software distribution systems.
Ruby
12
star
60

chef_authn

Erlang API request authentication signing and verification for Chef
Erlang
11
star
61

ffi-yajl

Ruby FFI gem wrapper around yajl2 library
Ruby
11
star
62

corefoundation

FFI based Ruby bindings for the CoreFoundation frameworks
Ruby
11
star
63

fixie

Low level manipulation tool for chef in sql
Ruby
10
star
64

dep-selector-libgecode

Bundled Gecode Libraries for dep-selector
Ruby
10
star
65

win32-certstore

Ruby library for accessing the certificate store on Windows
Ruby
10
star
66

chef-workstation-app

The Chef Workstation desktop application.
TypeScript
10
star
67

win32-security

A Ruby interface for security aspects of MS Windows
Ruby
9
star
68

knife-vcenter

Chef knife plug-in for VMware REST API
Ruby
9
star
69

architecture-center

Ruby
9
star
70

win32-dir

A series of constants, and extra or redefined methods, for the Dir class on Windows
Ruby
8
star
71

chef_backup

A library to backup an Chef server
Ruby
8
star
72

chef-vault-testfixtures

provides an RSpec shared context for testing Chef cookbooks that use chef-vault
Ruby
7
star
73

opscoderl_httpc

Opscode helper application for being an HTTP client
Erlang
7
star
74

license-acceptance

Chef Software libraries for accepting usage license
Ruby
7
star
75

rubydistros

Dockerfiles for Ruby on various Linux distros
Dockerfile
7
star
76

win32-mmap

A Ruby interface for memory mapped files on MS Windows
Ruby
7
star
77

chef-analyze

A CLI to analyze artifacts from a Chef Infra Server
Go
6
star
78

win32-event

A Ruby interface to Event objects on MS Windows
Ruby
6
star
79

license_scout

Discovers license information of the dependencies of a project.
Ruby
6
star
80

.github

.github files that are inherited by all org repos unless specifically included in a repo
6
star
81

cookbook-omnifetch

Fetch Chef Cookbooks from Various Sources to a Local Cache
Ruby
6
star
82

win32-ipc

A Ruby abstract base class for synchronization objects on MS Windows
Ruby
5
star
83

github-workflows

Github Actions Workflows
5
star
84

appbundle-updater

A little help when you want to update an appbundled project inside of a Chef/ChefDK omnibus package
Ruby
5
star
85

ci-studio-common

Shared helpers for use inside CIs (like Travis) and a Habitat Studio
Go
5
star
86

omnibus-toolchain

Omnibus packaging for Omnibus toolchain
Ruby
5
star
87

chef-web-core

Shared resources for Chef web properties
Ruby
5
star
88

gatherlogs-reporter

Inspec profiles for examining gatherlog output from chef-products for support.
Ruby
5
star
89

chocolatey-packages

PowerShell
4
star
90

compliance-workshop-environment

Ruby
4
star
91

inspec-extra-resources

Ruby
4
star
92

folsom_graphite

Send data from folsom automatically to graphite
Erlang
4
star
93

chef-powershell-shim

.NET 4.0/COM wrapper around PowerShell host
Ruby
4
star
94

cookstylist

Cookstyle GitHub app
Ruby
4
star
95

automate-liveness-agent

Agent that sends "keep alive" messages to Chef Automate
Ruby
4
star
96

community_cookbook_releaser

A simple script to aid in version bumps and changelog generation for Chef managed community cookbooks
Ruby
4
star
97

habitat_exporter

Go
4
star
98

mixlib-archive

A very simple gem to create and extract archives.
Ruby
4
star
99

win32-mutex

A Ruby interface for mutexes on MS Windows
Ruby
3
star
100

chef_dictionary

A dictionary file of words in the Chef ecosystem
Ruby
3
star