Hi,
Currently, GIT integration feature only supports one repo per node running
apictl. From below PR[1] it provides the support for working on multiple
repos simultaneously with apictl vcs commands.
The approach would be:
1. Adding a new command vcs init to initialize a git repository with APICTL.
apictl-git-cicd$ apictl vcs init
Successfully initialized GIT repository
This will add a new file - 'vcs.yaml` file inside the root folder of the
git repository.
apictl-git-cicd$ cat vcs.yaml *id: 9eff0a36-1f0f-417f-a3c7-8f4603532293*
2. 'vcs init' will only be done by the developer. It will not be used in
any CI/CD scripts.
3. The above ID will be used to uniquely identify each git repository from
.wso2apictl/vcs_config.yaml. So with this vcs_config.yaml will maintain the
state of the multiple repositories.
repos:
*9eff0a36-1f0f-417f-a3c7-8f4603532293*:
environments:
dev:
lastAttemptedRev: d77e5abc81257f92d9ea3145e5ce983b24995e2b
lastSuccessfulRev: d77e5abc81257f92d9ea3145e5ce983b24995e2b
failedProjects: {}
bb31a820-10fd-4f0a-a470-df06c2ebb219:
environments:
dev:
lastAttemptedRev: d77e5abc81257f92d9ea3145e5ce983b24995e2b
lastSuccessfulRev: d77e5abc81257f92d9ea3145e5ce983b24995e2b
failedProjects: {}
4. It is a must to have vcs.yaml in the repo root to do any other vcs
command. Otherwise, an error will be shown.
apictl-git-cicd$ apictl vcs status -e dev
apictl: The repository info: vcs.yaml is not found in the repository
root. If this is the first time you are using this repo, please
initialize it with 'vcs init'.
Exit status 1
5. vcs.yaml should be committed to the git repository so that it will be
used in the subsequent deployments (vcs deploy).
*The main reasons for using this approach are:*
1. There's no easy way to figure out a unique id for a git repository. Some
workarounds are there [2] but those will not work in a multi-branch
situation.
2. @Uvindra Dias Jayasinha <[email protected]> also suggested an alternative
approach - using <repoURL:branch> as the identifier. However, some issues
were identified in situations such as - Renaming the current working branch
that would create a new ID.
3. Giving an independent ID gives the full flexibility to use or not use
the current state in situations where new branches are created and existing
branches are renamed.
4. "vcs init" can be used in the future for adding initialization params
such as giving a starting commit id.
[1] https://github.com/wso2/product-apim-tooling/pull/421
[2]
https://stackoverflow.com/questions/34874343/how-can-i-uniquely-identify-a-git-repository
Thanks!
On Thu, Jul 16, 2020 at 3:55 PM Malintha Amarasinghe <[email protected]>
wrote:
> Hi Chamila,
>
> On Tue, Jul 14, 2020 at 12:28 PM Chamila Adhikarinayake <[email protected]>
> wrote:
>
>>
>>
>> Hi Malintha,
>>
>>> 3. The last successful commit will be stored in a special config file
>>> (vcs_config.yaml) that resides in <user_home>/.wso2apictl folder. This will
>>> have per-repo > per-environment last successful commit. Whenever there are
>>> new commits, the last successful commit will be used to identify the
>>> changes.
>>>
>>>
>> Regarding this approach, There are possibilities that we might not be
>> able to find changes based on the last stored commit because of some git
>> features. (Ex: rebasing, amending ,
>> https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History). Wouldn't
>> there be an issue when identifying the changes due to these things?
>>
>
> Thanks for raising this. Yes. If we rewrite history, that'll be an issue.
> However, I think, rewriting git history is rarely done in an organization.
> Even in our repositories (master branches), we hardly ever allow that.
> If someone needs to do it in an unavoidable situation, they will have to
> manually edit the stored commit to a correct one in the vcs_config file.
>
> Thanks!
>
>
>>
>> *Issues to be sorted:*
>>> 1. vcs_config.yaml is containing a state (last successful commit). In a
>>> typical CICD flow, there should be a way to preserve this file to use when
>>> the next build comes. In a single VM, it will not be an issue, but during
>>> other platforms like k8s, need to identify if there are any issues, etc.
>>>
>>> I am working on incorporating this into the APICTL 3.2.0 release.
>>>
>>> Your suggestions are most welcome.
>>>
>>> Thanks!
>>> Malintha
>>>
>>>
>>> --
>>> Malintha Amarasinghe
>>> *WSO2, Inc. - lean | enterprise | middleware*
>>> http://wso2.com/
>>>
>>> Mobile : +94 712383306
>>> _______________________________________________
>>> Architecture mailing list
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>
>>
>> --
>> Regards,
>> Chamila Adhikarinayake
>> Associate Technical Lead
>> WSO2, Inc.
>> Mobile - +94712346437
>> Email - [email protected]
>> Blog - http://helpfromadhi.blogspot.com/
>>
>
>
> --
> Malintha Amarasinghe
> *WSO2, Inc. - lean | enterprise | middleware*
> http://wso2.com/
>
> Mobile : +94 712383306
>
--
Malintha Amarasinghe
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/
Mobile : +94 712383306
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture