Skip to content

Commit

Permalink
Merge pull request #474 from dgraeber/feature/min-version-check
Browse files Browse the repository at this point in the history
adding ability to check the runtime of seedfarmer in in seedfarmer.yaml
  • Loading branch information
dgraeber authored Jan 8, 2024
2 parents a6e698b + 96b13e6 commit f8d5dd8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
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

0 comments on commit f8d5dd8

Please sign in to comment.