Skip to content

Instantly share code, notes, and snippets.

@namit-chandwani
Created August 23, 2021 10:58
Show Gist options
  • Save namit-chandwani/3a28a544fd4d48e2703e4f0ca08d318b to your computer and use it in GitHub Desktop.
Save namit-chandwani/3a28a544fd4d48e2703e4f0ca08d318b to your computer and use it in GitHub Desktop.
GSoC'21 Work Product Submission

Google Summer of Code 2021: Work Product Submission

image

Table of contents

Student Developer Info

Name: Namit Chandwani (@namit-chandwani)
Organisation: JBoss Community
Project: Develop a Golang-based framework (Charmil) to enhance Knative’s functionalities

Project Overview

Charmil logo

  • Charmil offers an ecosystem for developing production-ready command-line tools based on the Cobra Framework.

  • It includes an SDK that enables the construction of command-line interface (CLI) applications that all conform to a similarly organized design by giving a level of flexibility to add and/or remove a plugin CLI or a subset of commands from a plugin CLI to a primary 'host' CLI.

  • This allows developers to create several fragmented CLIs in separate repositories and then integrate them into a single host CLI.

Components of Charmil

  • Charmil SDK:

    • This is the component responsible for constructing modular, multi-repo Golang CLIs with Cobra while providing a variety of high-level solutions for typical challenges like configuration, authentication, and internationalization.

    • These multi-repo CLIs can then be embedded into host CLIs at compile time.

  • Charmil Validator:

    • Charmil Validator provides many rules that developers may use to test and regulate various elements of cobra commands.

    • The following rules are provided as of now:

      • LengthRule: To control lengths of strings in different attributes of a cobra command.
      • MustExistRule: To ensure that a cobra command contains the specified attributes.
      • UseMatchesRule: To compare the Use attribute of a cobra command with the regular expression specified by the user.
      • ExampleMatchesRule: To ensure that a cobra command is well-documented and includes appropriate examples.
      • PunctuationRule: To verify a cobra command for punctuation errors in accordance with industry standards.
  • Charmil Starter Template:

    • The Charmil Starter Template allows users to quickly create plugins and host commands that make use of the features offered by Charmil.

    • This template includes all of the tools and solutions needed to create a command-line utility.

  • Charmil Generator CLI:

    • Charmil offers its own command-line interface (CLI) that allows developers to construct their new Charmil project with additional support for other templates, allowing them to focus on more essential aspects of their project.

    • This is the easiest way to incorporate Charmil into a project.

    • As of now, the Charmil Generator CLI offers 3 commands:

      • init: Initializes a project boilerplate by using the Charmil Starter Template.
      • add: Adds a new command into the CLI.
      • crud: Helps developers generate CRUD commands for their CLI.
  • Charmil Command Registry [To be added soon]:

    • The Charmil Command Registry will allow developers to create an external index of command-line tools that can be dynamically installed and integrated into their host CLI.

Communication and Work Management

  • The entire project is hosted on the Charmil repository under the Aerogear organization on Github.
  • Before implementing any new feature, we used Github Discussions to discuss our approach with the mentors and other contributors.
  • In the Aerogear discord server, a dedicated channel was created for this project to settle any doubts, ideas, and comments for speedier coordination.
  • Some live coding/discussion sessions were conducted on the Aerogear discord server with the mentors and other contributors.

Primary features/components I worked on

Charmil Generator CLI

  • Charmil CRUD generator command:
    • With the help of the charmil crud command, developers can eliminate a lot of boilerplate in CLIs containing multiple services that perform standard CRUD operations.
    • Using a set of pre-defined templates, this command generates CRUD command packages in the directory specified by the crudpath flag as well as its corresponding language file in the directory specified by the localepath flag.
    • These generated files can then be modified by developers to fit their own needs.

Charmil Core

  • Config Management Package:
    • The Charmil Config package offers a convenient mechanism for both host and plugin developers to manage configurations in their CLI applications.
    • Helps in maintaining all available configurations in a single, centralized local config file.
    • Provides the host CLI developers with a set of methods to read/write configurations from/to a local config file.
    • Provides the plugin developers with functionality to load/save their CLI configurations from/to the host CLI local config file with ease.

Other Contributions

  • Some refactors on Starter templates
  • Feature Flags (Idea discontinued)
  • Making the RHOAS CLI repo use Charmil Validator
  • Provide POC on how Charmil can be used to integrate case study repositories

Future Scope of the project

  • Implementing the Charmil Command Registry component
  • Investigating shared authentication between host and plugin CLIs

Things I learned while contributing

  • Learning new technologies on a regular basis: In the past, I would solely work on technologies that I was previously familiar with and base all of my projects on them. During GSoC, I learned that we should select technologies/languages/dependencies that properly match our use case, not just those that we're familiar with.
  • Working with huge codebases: I wasn't used to working with large codebases before, and it took me a while to get used to it.
  • Debugging large codes, identifying the cause, and fixing it. Also got to learn about some debugging tools.
  • Developer Workflow: Got familiar with the iterative process of first Picking an issueHaving discussions around itImplementing itCreating a PRAsking for ReviewsApplying suggestions based on reviewsGetting it merged.
  • Adapting with contributors across different timezones.
  • Understanding, reviewing, and modifying others contributors' code.
  • Implementing error handling wherever possible in code, to assist users in determining the source of any issue.
  • Writing clean and well-documented code: Prior to GSoC, I had never given much thought to code quality. But after working with my mentors, I realized that it is the most significant and vital characteristic of any excellent codebase.

Acknowledgements

I would like to express my heartfelt gratitude to:

  • All my mentors: Wojciech Trocki (@wtrocki), Dimitri Saridakis (@dimakis), Jack Delahunt (@jackdelahunt), JJ Kiely (@jjkiely), Ramakrishna Pattnaik (@rkpattnaik780) and Maksym Vavilov (@makslion), for always believing in me and devoting time to provide impeccable guidance and motivation while contributing.
  • Ankit Hans (@ankithans) for being an amazing collaborator throughout this journey.
  • The entire JBoss Community for their welcoming support and assistance.

Important Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment