Skip to content

Commit

Permalink
Implement Kubernetes application configuration and deployment input s…
Browse files Browse the repository at this point in the history
…tructures (#5356)

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
  • Loading branch information
Warashi authored Nov 21, 2024
1 parent 669bbd2 commit 16edf80
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
25 changes: 25 additions & 0 deletions pkg/app/pipedv1/plugin/kubernetes/config/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,28 @@ type K8sResourceReference struct {
Kind string `json:"kind"`
Name string `json:"name"`
}

// KubernetesApplicationSpec represents an application configuration for Kubernetes application.
type KubernetesApplicationSpec struct {
// Input for Kubernetes deployment such as kubectl version, helm version, manifests filter...
Input KubernetesDeploymentInput `json:"input"`

// TODO: Define fields for KubernetesApplicationSpec.
}

func (s *KubernetesApplicationSpec) Validate() error {
// TODO: Validate KubernetesApplicationSpec fields.
return nil
}

// KubernetesDeploymentInput represents needed input for triggering a Kubernetes deployment.
type KubernetesDeploymentInput struct {
// List of manifest files in the application directory used to deploy.
// Empty means all manifest files in the directory will be used.
Manifests []string `json:"manifests,omitempty"`

// The namespace where manifests will be applied.
Namespace string `json:"namespace,omitempty"`

// TODO: Define fields for KubernetesDeploymentInput.
}
16 changes: 15 additions & 1 deletion pkg/app/pipedv1/plugin/kubernetes/deployment/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
"context"
"time"

kubeconfig "github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/config"
"github.com/pipe-cd/pipecd/pkg/app/pipedv1/plugin/kubernetes/provider"
config "github.com/pipe-cd/pipecd/pkg/configv1"
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
"github.com/pipe-cd/pipecd/pkg/regexpool"

Expand Down Expand Up @@ -69,8 +71,20 @@ func (a *DeploymentService) DetermineStrategy(context.Context, *deployment.Deter

// DetermineVersions implements deployment.DeploymentServiceServer.
func (a *DeploymentService) DetermineVersions(ctx context.Context, request *deployment.DetermineVersionsRequest) (*deployment.DetermineVersionsResponse, error) {
cfg, err := config.DecodeYAML[*kubeconfig.KubernetesApplicationSpec](request.GetInput().GetTargetDeploymentSource().GetApplicationConfig())
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

manifests, err := a.Loader.LoadManifests(ctx, provider.LoaderInput{
// TODO: fill the input
AppName: request.GetInput().GetDeployment().GetApplicationName(),
AppDir: request.GetInput().GetTargetDeploymentSource().GetApplicationDirectory(),
ConfigFilename: request.GetInput().GetTargetDeploymentSource().GetApplicationConfigFilename(),
Manifests: cfg.Spec.Input.Manifests,
Namespace: cfg.Spec.Input.Namespace,
TemplatingMethod: provider.TemplatingMethodNone, // TODO: Implement detection of templating method or add it to the config spec.

// TODO: Define other fields for LoaderInput
})

if err != nil {
Expand Down

0 comments on commit 16edf80

Please sign in to comment.