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

adding ability to check the runtime of seedfarmer in in seedfarmer.yaml #474

Merged
merged 1 commit into from
Jan 8, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch

### Changes
- updating pydantic support from 1.X.X to 2.5.3
- adding seedfarmer verions check support with `seedfarmer.yaml`

### Fixes
- update `manifests/examples/` to point to an updated release branch
Expand Down
4 changes: 3 additions & 1 deletion docs/source/project_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ It is important to have the ```seedfarmer.yaml``` at the root of your project.
project: <your project name>
description: <your project description>
projectPolicyPath: <relativepath/policyname.yaml>
seedfarmer_version: <minimum required seedfermer version>
```
- **project** (REQUIRED) - this is the name of the project that all deployments will reference
- **description** (OPTIONAL) - this is the description of the project
- **projectPolicyPath** (OPTIONAL) - this allows advanced users change the project policy that has the basic minimim permissions seedfarmer needs
- it consists of a path relative to the project root and MUST be a valid relative path
- to synth the existing project policy, run `seedfarmer projectpolicy synth`

- **seedfarmer_version** (OPTIONAL) - this specifies what is the minimum allowable version of `seed-farmer` the project supports
- if this value is set AND the runtime version of seedfarmer is greater, `seed-farmer` will exit immediately


(project_initalization)=
Expand Down
8 changes: 8 additions & 0 deletions seedfarmer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import yaml
from aws_codeseeder import LOGGER, codeseeder
from aws_codeseeder.codeseeder import CodeSeederConfig
from packaging.version import parse

import seedfarmer.errors
from seedfarmer.__metadata__ import __description__, __license__, __title__
Expand Down Expand Up @@ -90,6 +91,13 @@ def _load_config_data(self) -> None:
if self._project_spec.project_policy_path
else os.path.join(CLI_ROOT, DEFAULT_PROJECT_POLICY_PATH)
)
if self._project_spec.seedfarmer_version:
if parse(__version__) < parse(str(self._project_spec.seedfarmer_version)):
msg = (
f"The seedfarmer.yaml specified a minimum version: "
f"{self._project_spec.seedfarmer_version} but you are using {__version__}"
)
raise seedfarmer.errors.SeedFarmerException(msg)

@codeseeder.configure(self._project_spec.project.lower(), deploy_if_not_exists=True)
def configure(configuration: CodeSeederConfig) -> None:
Expand Down
3 changes: 2 additions & 1 deletion seedfarmer/models/_project_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from typing import Optional, Union

from seedfarmer.models._base import CamelModel

Expand All @@ -27,3 +27,4 @@ class ProjectSpec(CamelModel):
project: str
description: Optional[str] = None
project_policy_path: Optional[str] = None
seedfarmer_version: Optional[Union[int, str]] = None
Loading