-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Detecting Golang services and creating plan file (#2)
- Loading branch information
1 parent
252b20f
commit 9e102dc
Showing
93 changed files
with
4,612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright IBM Corporation 2021 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package assets | ||
|
||
import "embed" | ||
|
||
//go:generate go run ../scripts/generator/persistpermissions.go built-in/ filepermissions.yaml | ||
|
||
// AssetsDir is the embedded built-in assets directory | ||
// | ||
//go:embed built-in/* | ||
var AssetsDir embed.FS | ||
|
||
// AssetFilePermissions is embedded file having permissions information for the assets | ||
// | ||
//go:embed filepermissions.yaml | ||
var AssetFilePermissions string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
move2kube: | ||
transformers: | ||
types: | ||
- ComposeGenerator | ||
- ComposeAnalyser | ||
- Knative | ||
- ContainerImagesPushScriptGenerator | ||
- DockerfileParser | ||
- DockerfileImageBuildScript | ||
- Kubernetes | ||
- ArgoCD | ||
- Tekton | ||
- Buildconfig | ||
- ClusterSelector | ||
- Parameterizer | ||
- ReadMeGenerator | ||
- DockerfileDetector | ||
transformerselector: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
move2kube: | ||
transformerselector: "move2kube.konveyor.io/task in (containerization,containerizationscript)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
move2kube: | ||
transformers: | ||
types: | ||
- Knative | ||
- ContainerImagesPushScriptGenerator | ||
- DockerfileParser | ||
- DockerfileImageBuildScript | ||
- Kubernetes | ||
- ArgoCD | ||
- Tekton | ||
- Buildconfig | ||
- ClusterSelector | ||
- Parameterizer | ||
- ReadMeGenerator | ||
- DockerfileDetector | ||
transformerselector: "" |
2 changes: 2 additions & 0 deletions
2
assets/built-in/presets/enable-containerized-transformers.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
move2kube: | ||
spawncontainers: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
move2kube: | ||
containerruntime: podman |
18 changes: 18 additions & 0 deletions
18
assets/built-in/transformers/cloudfoundry/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: CloudFoundry | ||
labels: | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "CloudFoundry" | ||
directoryDetect: | ||
levels: 1 | ||
consumes: | ||
Service: | ||
disabled: false | ||
produces: | ||
IR: | ||
disabled: false | ||
Service: | ||
disabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: CNBContainerizer | ||
labels: | ||
move2kube.konveyor.io/task: containerization | ||
move2kube.konveyor.io/built-in: true | ||
move2kube.konveyor.io/container-based: true | ||
spec: | ||
mode: "Container" | ||
class: "CNBContainerizer" | ||
directoryDetect: | ||
levels: -1 | ||
consumes: | ||
Service: | ||
disabled: false | ||
produces: | ||
CNBDetectedService: | ||
disabled: false | ||
config: | ||
container: | ||
image: "paketobuildpacks/builder:full" | ||
keepAliveCommand: ["tail", "-f", "/dev/null"] |
20 changes: 20 additions & 0 deletions
20
assets/built-in/transformers/compose/composeanalyser/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: ComposeAnalyser | ||
labels: | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "ComposeAnalyser" | ||
directoryDetect: | ||
levels: 1 | ||
consumes: | ||
Service: | ||
disabled: false | ||
produces: | ||
IR: | ||
disabled: false | ||
Dockerfile: | ||
disabled: false | ||
config: | ||
enableNetworkParsing: false |
13 changes: 13 additions & 0 deletions
13
assets/built-in/transformers/compose/composegenerator/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: ComposeGenerator | ||
labels: | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "ComposeGenerator" | ||
directoryDetect: | ||
levels: 0 | ||
consumes: | ||
IR: | ||
merge: true |
66 changes: 66 additions & 0 deletions
66
assets/built-in/transformers/containerimagespushscript/templates/pushimages.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
:: Copyright IBM Corporation 2021 | ||
:: | ||
:: Licensed under the Apache License, Version 2.0 (the "License"); | ||
:: you may not use this file except in compliance with the License. | ||
:: You may obtain a copy of the License at | ||
:: | ||
:: http://www.apache.org/licenses/LICENSE-2.0 | ||
:: | ||
:: Unless required by applicable law or agreed to in writing, software | ||
:: distributed under the License is distributed on an "AS IS" BASIS, | ||
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
:: See the License for the specific language governing permissions and | ||
:: limitations under the License. | ||
|
||
:: Invoke as pushimages.bat <registry_url> <registry_namespace> <container_runtime> | ||
:: Examples: | ||
:: 1) pushimages.bat | ||
:: 2) pushimages.bat quay.io your_quay_username | ||
:: 3) pushimages.bat index.docker.io your_registry_namespace podman | ||
|
||
@echo off | ||
IF "%3"=="" GOTO DEFAULT_CONTAINER_RUNTIME | ||
SET CONTAINER_RUNTIME=%3% | ||
GOTO REGISTRY | ||
|
||
:DEFAULT_CONTAINER_RUNTIME | ||
SET CONTAINER_RUNTIME=docker | ||
GOTO REGISTRY | ||
|
||
:REGISTRY | ||
IF "%2"=="" GOTO DEFAULT_REGISTRY | ||
IF "%1"=="" GOTO DEFAULT_REGISTRY | ||
SET REGISTRY_URL=%1 | ||
SET REGISTRY_NAMESPACE=%2 | ||
GOTO DOCKER_CONTAINER_RUNTIME | ||
|
||
:DEFAULT_REGISTRY | ||
SET REGISTRY_URL={{ .RegistryURL }} | ||
SET REGISTRY_NAMESPACE={{ .RegistryNamespace }} | ||
GOTO DOCKER_CONTAINER_RUNTIME | ||
|
||
:DOCKER_CONTAINER_RUNTIME | ||
IF NOT "%CONTAINER_RUNTIME%" == "docker" GOTO PODMAN_CONTAINER_RUNTIME | ||
GOTO MAIN | ||
|
||
:PODMAN_CONTAINER_RUNTIME | ||
IF NOT "%CONTAINER_RUNTIME%" == "podman" GOTO UNSUPPORTED_BUILD_SYSTEM | ||
GOTO MAIN | ||
|
||
:UNSUPPORTED_BUILD_SYSTEM | ||
echo 'Unsupported build system passed as an argument for pushing the images.' | ||
GOTO SKIP | ||
|
||
:MAIN | ||
:: Uncomment the below line if you want to enable login before pushing | ||
:: %CONTAINER_RUNTIME% login %REGISTRY_URL% | ||
{{- range $image := .Images }} | ||
|
||
echo "pushing image {{ $image }}" | ||
%CONTAINER_RUNTIME% tag {{ $image }} %REGISTRY_URL%/%REGISTRY_NAMESPACE%/{{ $image }} | ||
%CONTAINER_RUNTIME% push %REGISTRY_URL%/%REGISTRY_NAMESPACE%/{{ $image }} | ||
{{- end }} | ||
|
||
echo "done" | ||
|
||
:SKIP |
45 changes: 45 additions & 0 deletions
45
assets/built-in/transformers/containerimagespushscript/templates/pushimages.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
# Copyright IBM Corporation 2020 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Invoke as ./pushimages.sh <registry_url> <registry_namespace> <container_runtime> | ||
# Examples: | ||
# 1) ./pushimages.sh | ||
# 2) ./pushimages.sh quay.io your_quay_username | ||
# 3) ./pushimages.sh index.docker.io your_registry_namespace podman | ||
|
||
REGISTRY_URL={{ .RegistryURL }} | ||
REGISTRY_NAMESPACE={{ .RegistryNamespace }} | ||
CONTAINER_RUNTIME=docker | ||
if [ "$#" -gt 1 ]; then | ||
REGISTRY_URL=$1 | ||
REGISTRY_NAMESPACE=$2 | ||
fi | ||
if [ "$#" -eq 3 ]; then | ||
CONTAINER_RUNTIME=$3 | ||
fi | ||
if [ "${CONTAINER_RUNTIME}" != "docker" ] && [ "${CONTAINER_RUNTIME}" != "podman" ]; then | ||
echo 'Unsupported container runtime passed as an argument for pushing the images: '"${CONTAINER_RUNTIME}" | ||
exit 1 | ||
fi | ||
# Uncomment the below line if you want to enable login before pushing | ||
# ${CONTAINER_RUNTIME} login ${REGISTRY_URL} | ||
{{- range $image := .Images }} | ||
|
||
echo 'pushing image {{ $image }}' | ||
${CONTAINER_RUNTIME} tag {{ $image }} ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/{{ $image }} | ||
${CONTAINER_RUNTIME} push ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/{{ $image }} | ||
{{- end }} | ||
|
||
echo 'done' |
17 changes: 17 additions & 0 deletions
17
assets/built-in/transformers/containerimagespushscript/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: ContainerImagesPushScriptGenerator | ||
labels: | ||
move2kube.konveyor.io/task: containerizationscript | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "ContainerImagesPushScript" | ||
directoryDetect: | ||
levels: 0 | ||
consumes: | ||
NewImages: | ||
merge: true | ||
produces: | ||
ContainerImagesPushScript: | ||
disabled: false |
18 changes: 18 additions & 0 deletions
18
assets/built-in/transformers/dockerfile/dockerfiledetector/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: DockerfileDetector | ||
labels: | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "DockerfileDetector" | ||
directoryDetect: | ||
levels: 1 | ||
consumes: | ||
Service: | ||
disabled: false | ||
produces: | ||
Dockerfile: | ||
disabled: false | ||
DockerfileForService: | ||
disabled: false |
16 changes: 16 additions & 0 deletions
16
assets/built-in/transformers/dockerfile/dockerfileparser/transformer.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: move2kube.konveyor.io/v1alpha1 | ||
kind: Transformer | ||
metadata: | ||
name: DockerfileParser | ||
labels: | ||
move2kube.konveyor.io/built-in: true | ||
spec: | ||
class: "DockerfileParser" | ||
directoryDetect: | ||
levels: 0 | ||
consumes: | ||
DockerfileForService: | ||
merge: false | ||
produces: | ||
IR: | ||
disabled: false |
63 changes: 63 additions & 0 deletions
63
...transformers/dockerfile/dockerimagebuildscript/templates/buildandpushimages_multiarch.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
:: Copyright IBM Corporation 2021 | ||
:: | ||
:: Licensed under the Apache License, Version 2.0 (the "License"); | ||
:: you may not use this file except in compliance with the License. | ||
:: You may obtain a copy of the License at | ||
:: | ||
:: http://www.apache.org/licenses/LICENSE-2.0 | ||
:: | ||
:: Unless required by applicable law or agreed to in writing, software | ||
:: distributed under the License is distributed on an "AS IS" BASIS, | ||
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
:: See the License for the specific language governing permissions and | ||
:: limitations under the License. | ||
|
||
:: Invoke as buildandpush_multiarchimages.bat <registry_url> <registry_namespace> <comma_separated_platforms> | ||
:: Examples: | ||
:: 1) buildandpush_multiarchimages.bat | ||
:: 2) buildandpush_multiarchimages.bat index.docker.io your_registry_namespace | ||
:: 3) buildandpush_multiarchimages.bat quay.io your_quay_username linux/amd64,linux/arm64,linux/s390x | ||
|
||
@echo off | ||
for /F "delims=" %%i in ("%cd%") do set basename="%%~ni" | ||
|
||
if not %basename% == "scripts" ( | ||
echo "please run this script from the 'scripts' directory" | ||
exit 1 | ||
) | ||
|
||
REM go to the parent directory so that all the relative paths will be correct | ||
cd {{ .RelParentOfSourceDir }} | ||
|
||
IF "%3"=="" GOTO DEFAULT_PLATFORMS | ||
SET PLATFORMS=%3% | ||
GOTO REGISTRY | ||
|
||
:DEFAULT_PLATFORMS | ||
SET PLATFORMS=linux/amd64,linux/arm64,linux/s390x,linux/ppc64le | ||
GOTO REGISTRY | ||
|
||
:REGISTRY | ||
IF "%2"=="" GOTO DEFAULT_REGISTRY | ||
IF "%1"=="" GOTO DEFAULT_REGISTRY | ||
SET REGISTRY_URL=%1 | ||
SET REGISTRY_NAMESPACE=%2 | ||
GOTO MAIN | ||
|
||
:DEFAULT_REGISTRY | ||
SET REGISTRY_URL={{ .RegistryURL }} | ||
SET REGISTRY_NAMESPACE={{ .RegistryNamespace }} | ||
GOTO MAIN | ||
|
||
:MAIN | ||
:: Uncomment the below line if you want to enable login before pushing | ||
:: docker login %REGISTRY_URL% | ||
{{- range $dockerfile := .DockerfilesConfig }} | ||
|
||
echo "building and pushing image {{ $dockerfile.ImageName }}" | ||
pushd {{ $dockerfile.ContextWindows }} | ||
docker buildx build --platform ${PLATFORMS} -f {{ $dockerfile.DockerfileName }} --push --tag ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/{{ $dockerfile.ImageName }} . | ||
popd | ||
{{- end }} | ||
|
||
echo "done" |
Oops, something went wrong.