Skip to content

Commit

Permalink
Correction after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Kuziemko committed Feb 15, 2022
1 parent f7d2711 commit 354571f
Show file tree
Hide file tree
Showing 25 changed files with 271 additions and 86 deletions.
1 change: 1 addition & 0 deletions cmd/argo-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following environment variables can be set:
|--------------------------|----------|-------------------------------------------------|--------------------------------------------------------|
| APP_ACTION | yes | | Defines action to perform |
| APP_LOCAL_HUB_ENDPOINT | no | http://capact-hub-local.capact-system/graphql | Defines local Hub Endpoint |
| APP_PUBLIC_HUB_ENDPOINT | no | http://capact-hub-public.capact-system/graphql | Defines public Hub Endpoint |
| APP_DOWNLOAD_CONFIG | no | | For download action defines Type Instances to download |
| APP_LOGGER_DEV_MODE | no | `false` | Enable additional log messages |

Expand Down
9 changes: 3 additions & 6 deletions cmd/argo-actions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,16 @@ func main() {
logger, err := logger.New(cfg.Logger)
exitOnError(err, "while creating zap logger")

localClient := local.NewDefaultClient(cfg.LocalHubEndpoint)
publicClient := public.NewDefaultClient(cfg.PublicHubEndpoint)

// TODO: Consider using connection `hubclient.New` and route requests through Gateway
client := hubclient.Client{
Local: localClient,
Public: publicClient,
Local: local.NewDefaultClient(cfg.LocalHubEndpoint),
Public: public.NewDefaultClient(cfg.PublicHubEndpoint),
}

switch cfg.Action {
case argoactions.DownloadAction:
log := logger.With(zap.String("Action", argoactions.DownloadAction))
action = argoactions.NewDownloadAction(log, localClient, cfg.DownloadConfig)
action = argoactions.NewDownloadAction(log, &client, cfg.DownloadConfig)

case argoactions.UploadAction:
log := logger.With(zap.String("Action", argoactions.UploadAction))
Expand Down
5 changes: 4 additions & 1 deletion cmd/k8s-engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type Config struct {

Logger logger.Config

LocalHubEndpoint string `envconfig:"default=http://capact-hub-local.capact-system/graphql"`
PublicHubEndpoint string `envconfig:"default=http://capact-hub-public.capact-system/graphql"`

GraphQLGateway struct {
Endpoint string `envconfig:"default=http://capact-gateway/graphql"`
Username string
Expand Down Expand Up @@ -107,7 +110,7 @@ func main() {
exitOnError(err, "while creating manager")

hubClient := getHubClient(&cfg)
typeInstanceHandler := argo.NewTypeInstanceHandler(cfg.HubActionsImage)
typeInstanceHandler := argo.NewTypeInstanceHandler(cfg.HubActionsImage, cfg.LocalHubEndpoint, cfg.PublicHubEndpoint)
interfaceIOValidator := actionvalidation.NewValidator(hubClient)
policyIOValidator := policyvalidation.NewValidator(hubClient)
wfValidator := renderer.NewWorkflowInputValidator(interfaceIOValidator, policyIOValidator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ spec:
value: "{{ .Values.global.gateway.auth.username }}"
- name: APP_GRAPHQLGATEWAY_PASSWORD
value: "{{ .Values.global.gateway.auth.password }}"
- name: APP_LOCAL_HUB_ENDPOINT
value: "http://capact-hub-local.{{.Release.Namespace}}.svc.cluster.local/graphql"
- name: APP_PUBLIC_HUB_ENDPOINT
value: "http://capact-hub-public.{{.Release.Namespace}}.svc.cluster.local/graphql"
- name: APP_BUILTIN_RUNNER_IMAGE
value: "{{ .Values.global.containerRegistry.path }}/{{ .Values.builtInRunner.image.name }}:{{ .Values.global.containerRegistry.overrideTag | default .Chart.AppVersion }}"
- name: APP_BUILTIN_RUNNER_TIMEOUT
Expand Down
6 changes: 3 additions & 3 deletions pkg/argo-actions/download_type_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"capact.io/capact/pkg/hub/client/local"
hubclient "capact.io/capact/pkg/hub/client"
"capact.io/capact/pkg/runner"
"github.com/pkg/errors"
"go.uber.org/zap"
Expand All @@ -25,11 +25,11 @@ type DownloadConfig struct {
type Download struct {
log *zap.Logger
cfg []DownloadConfig
client *local.Client
client *hubclient.Client
}

// NewDownloadAction returns a new Download instance.
func NewDownloadAction(log *zap.Logger, client *local.Client, cfg []DownloadConfig) Action {
func NewDownloadAction(log *zap.Logger, client *hubclient.Client, cfg []DownloadConfig) Action {
return &Download{
log: log,
cfg: cfg,
Expand Down
8 changes: 8 additions & 0 deletions pkg/sdk/apis/0.0.1/types/types.extend.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Package types holds manually added types.
package types

import (
"fmt"
)

// OCFPathPrefix defines path prefix that all OCF manifest must have.
const OCFPathPrefix = "cap."

Expand All @@ -20,6 +24,10 @@ type ManifestRef struct {
Revision string `json:"revision"` // Version of the manifest content in the SemVer format.
}

func (in *ManifestRef) String() string {
return fmt.Sprintf("%s:%s", in.Path, in.Revision)
}

// ManifestRefWithOptRevision specifies type by path and optional revision.
// +kubebuilder:object:generate=true
type ManifestRefWithOptRevision struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/renderer/argo/dedicated_renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func createFakeDedicatedRendererObject(t *testing.T) *dedicatedRenderer {
require.NoError(t, err)

genUUID := func() string { return "uuid" }
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7")
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7", "", "")
typeInstanceHandler.SetGenUUID(genUUID)

policyIOValidator := policyvalidation.NewValidator(fakeCli)
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/renderer/argo/renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestRenderHappyPath(t *testing.T) {

policy := policy.NewAllowAll()
genUUID := func() string { return "uuid" } // it has to be static because of parallel testing
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7")
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7", "http://capact-hub-local.capact-system/graphql ", "http://capact-hub-public.capact-system/graphql")
typeInstanceHandler.SetGenUUID(genUUID)

ownerID := "default/action"
Expand Down Expand Up @@ -294,7 +294,7 @@ func TestRenderHappyPathWithCustomPolicies(t *testing.T) {
tt := test
t.Run(tt.name, func(t *testing.T) {
genUUID := genUUIDFn(strconv.Itoa(tc))
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7")
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7", "http://capact-hub-local.capact-system/graphql ", "http://capact-hub-public.capact-system/graphql")
typeInstanceHandler.SetGenUUID(genUUID)

interfaceIOValidator := actionvalidation.NewValidator(fakeCli)
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestRendererMaxDepth(t *testing.T) {
require.NoError(t, err)

policy := policy.NewAllowAll()
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7")
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7", "http://capact-hub-local.capact-system/graphql ", "http://capact-hub-public.capact-system/graphql")
typeInstanceHandler.SetGenUUID(genUUIDFn(""))

interfaceIOValidator := actionvalidation.NewValidator(fakeCli)
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestRendererDenyAllPolicy(t *testing.T) {
require.NoError(t, err)

policy := policy.NewDenyAll()
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7")
typeInstanceHandler := NewTypeInstanceHandler("alpine:3.7", "http://capact-hub-local.capact-system/graphql ", "http://capact-hub-public.capact-system/graphql")
typeInstanceHandler.SetGenUUID(genUUIDFn(""))

interfaceIOValidator := actionvalidation.NewValidator(fakeCli)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{6fc7dd6b-d150-4af3-a1aa-a868962b7d68,/firstRole.yaml},{f2421415-b8a4-464b-be12-b617794411c5,/postgresql.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand All @@ -312,6 +316,10 @@ args:
value: /update/payload
- name: APP_UPDATE_CONFIG_TYPE_INSTANCES_DIR
value: /update/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{6fc7dd6b-d150-4af3-a1aa-a868962b7d68,/role.yaml},{f2421415-b8a4-464b-be12-b617794411c5,/postgresql.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand All @@ -293,6 +297,10 @@ args:
value: /update/payload
- name: APP_UPDATE_CONFIG_TYPE_INSTANCES_DIR
value: /update/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{c268d3f5-8834-434b-bea2-b677793611c5,/gcp-sa.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -295,6 +299,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{517cf827-233c-4bf1-8fc9-48534424dd58,/aws-credentials.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -1568,6 +1572,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{c268d3f5-8834-434b-bea2-b677793611c5,/gcp-sa.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -1269,6 +1273,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{c268d3f5-8834-434b-bea2-b677793611c5,/gcp-sa.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -1341,6 +1345,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{f2421415-b8a4-464b-be12-b617794411c5,/postgresql.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -1105,6 +1109,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{f2421415-b8a4-464b-be12-b617794411c5,/postgresql.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand All @@ -1124,6 +1132,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ args:
value: DownloadAction
- name: APP_DOWNLOAD_CONFIG
value: '{517cf827-233c-4bf1-8fc9-48534424dd58,/aws-credentials.yaml}'
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
name: ""
resources: {}
Expand Down Expand Up @@ -598,6 +602,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ args:
value: /upload/payload
- name: APP_UPLOAD_CONFIG_TYPE_INSTANCES_DIR
value: /upload/typeInstances
- name: APP_LOCAL_HUB_ENDPOINT
value: 'http://capact-hub-local.capact-system/graphql '
- name: APP_PUBLIC_HUB_ENDPOINT
value: http://capact-hub-public.capact-system/graphql
image: alpine:3.7
imagePullPolicy: IfNotPresent
name: ""
Expand Down
Loading

0 comments on commit 354571f

Please sign in to comment.