Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config file #75

Merged
merged 17 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Please delete options that are not relevant.
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Updated packages

### Checklist:
### Checklist

- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have run tests that prove my fix is effective or that my feature works
- [ ] I have updated the CHANGELOG.md file accordingly
- [ ] I have updated the CHANGELOG.md file accordingly
4 changes: 4 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"no-duplicate-heading": {
"siblings_only": true
},
"line-length": {
"line_length": 80,
"tables": false
}
}
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 80
}
14 changes: 4 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/src/main.go",
// Comment out if you need to setup environment variables for the module
// Comment out if you do not need to setup environment variables for the module
"envFile": "${workspaceFolder}/.env",
// "args": [
// "--BRUTE_FORCE_MAX_LOGIN_ATTEMPTS=10",
// ]
"args": []
},
{
"name": "Parallels Desktop PdFile Debug",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/src/main.go",
// Comment out if you need to setup environment variables for the module
// Comment out if you do not need to setup environment variables for the module
"envFile": "${workspaceFolder}/.env",
"args": [
"catalog",
"pull",
"--file=${workspaceFolder}/test-pull.local.pdfile"
]
"args": []
}
]
}
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.5] - 2024-01-16

### Added

- added the ability to have a config file for the apiclient, this will help
users to configure the api with more ease and also will allow them to share
that same configuration. It will either look for a config file in the current
directory with the following rules, `config.json`, `config.yaml`, `config.yml`
you can also add the `.local` before the extension to make it a local config
you can also specify the path to the config file using the `--config` flag

### Fixed

- fixed a bug where if the JWT token was invalid or empty the client would reset
the connection without a proper error handling
- fixed a bug if the user would setup the current instance to also be part of the
orchestrator and the API key would change, then the orchestrator would not be
able to authenticate

### Changed

- The system will now use the config class to read all of the configuration, this
will allow us to have a more consistent way of reading the configuration and where
to search for those values, this allows for example for a parameter to be set in
either a environment variable, a config file or a command line flag, the order
of precedence is the following, command line flag, environment variable, config
file
- updated documentation to reflect the changes in the configuration

## [0.4.4] - 2024-01-12

### Added
Expand Down
6 changes: 3 additions & 3 deletions .github/CODE_OF_CONDUCT.md → CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
maxime.gris@gmail.com.
[carlos lapao](carlos.lapao@parallels.com).
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -124,5 +124,5 @@ enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
71 changes: 45 additions & 26 deletions CONTRIBUTING.MD
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
## Contributing
# Contributing

[fork]: https://github.com/Parallels/pd-api-service/fork
[pr]: https://github.com/Parallels/pd-api-service/compare
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
Hi there! We're thrilled that you'd like to contribute to this project. Your help
is essential for keeping it great.

We accept pull requests for bug fixes and features where we've discussed the approach in an issue and given the go-ahead for a community member to work on it. We'd also love to hear about ideas for new features as issues.
We accept pull requests for bug fixes and features where we've discussed the
approach in an issue and given the go-ahead for a community member to work on
it. We'd also love to hear about ideas for new features as issues.

We track issues on our project board [here](https://github.com/orgs/Parallels/projects/6/views/1).

Please do:

* Check existing issues to verify that the [bug][bug issues] or [feature request][feature request issues] has not already been submitted.
* Check existing issues to verify that the [bug][bug issues] or
[feature request][feature request issues] has not already been submitted.
* Open an issue if things aren't working as expected.
* Open an issue to propose a significant change.
* Open a pull request to fix a bug.
* Open a pull request to fix documentation about a command.

Please avoid:

* Opening pull requests for issues marked `needs-design`, `needs-investigation`, or `blocked`.
* Opening pull requests for issues marked `needs-design`, `needs-investigation`,
or `blocked`.

Contributions to this project are released to the public under the [project's open source license](LICENSE).
Contributions to this project are released to the public under the
[project's open source license](LICENSE).

Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
Please note that this project is released with a
[Contributor Code of Conduct][code-of-conduct]. By participating in this project
you agree to abide by its terms.

## Prerequisites for running and testing code

These are one time installations required to be able to test your changes locally as part of the pull request (PR) submission process.
These are one time installations required to be able to test your changes locally
as part of the pull request (PR) submission process.

1. Install [Go](https://golang.org/dl/) for Mac
2. Install [VS Code](https://code.visualstudio.com/download) for Mac
3. Install [Parallels Desktop](https://www.parallels.com/uk/products/desktop/pro/) for Mac
3. Install [Parallels Desktop](https://www.parallels.com/uk/products/desktop/pro/)
for Mac
4. Install [Hashicorp Packer](https://www.packer.io/downloads) for Mac
5. Install [Vagrant](https://www.vagrantup.com/downloads.html) for Mac
6. Install the dependencies. From the repository root run:
Expand All @@ -45,9 +55,14 @@ go mod tidy

## Dev loop & Testing changes

The API is written in go to start it in debug mode you can go to Visual Studio Code `Run and Debug` and select the Parallels Desktop Api. This will start the service in debug mode and you can then use the swagger documentation to test the endpoints.
The API is written in go to start it in debug mode you can go to Visual Studio
Code `Run and Debug` and select the Parallels Desktop Api. This will start the
service in debug mode and you can then use the swagger documentation to test
the endpoints.

**Attention** There are some environment variables that might need to be set so you will need to create a .env file in the root of the repository and add the following variables:
**Attention** There are some environment variables that might need to be set
so you will need to create a .env file in the root of the repository and add the
following variables:

```bash
ROOT_PASSWORD=<root_password>
Expand All @@ -70,23 +85,27 @@ go test ./src/...
## Submitting a pull request

1. [Fork][fork] and clone the repository
1. Configure and install the dependencies (in the repository src folder): `go mod download`
1. Create a new branch: `git checkout -b my-branch-name`
1. Make your change, add tests, and make sure the tests and linter still pass
1. Push to your fork and [submit a pull request][pr]

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Format your code with [prettier](https://prettier.io/).
- Write tests.
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
2. Configure and install the dependencies (in the repository src folder):
`go mod download`
3. Create a new branch: `git checkout -b my-branch-name`
4. Make your change, add tests, and make sure the tests and linter still pass
5. Push to your fork and [submit a pull request][pr]

Here are a few things you can do that will increase the likelihood of your pull
request being accepted:

* Format your code with [prettier](https://prettier.io/).
* Write tests.
* Keep your change as focused as possible. If there are multiple changes you
would like to make that are not dependent upon each other, consider submitting
them as separate pull requests.
* Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
* [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
* [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
* [GitHub Help](https://help.github.com)

[bug issues]: https://github.com/Parallels/pd-api-service/labels/bug
[feature request issues]: https://github.com/Parallels/pd-api-service/labels/enhancement
[feature request issues]: https://github.com/Parallels/pd-api-service/labels/enhancement
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Carlos Lapao
Copyright (c) 2023 Carlos Lapao

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
Loading
Loading