Skip to content

Commit

Permalink
review coments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-codefresh committed Oct 20, 2023
1 parent a968300 commit 8ac7d17
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 79 deletions.
9 changes: 6 additions & 3 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5029,13 +5029,16 @@
"type": "object",
"properties": {
"deps": {
"type": "string"
"type": "string",
"title": "Content of Cart.yaml/dependencies"
},
"lock": {
"type": "string"
"type": "string",
"title": "Content of Chart.lock"
},
"requirements": {
"type": "string"
"type": "string",
"title": "Content of requirements.yaml"
}
}
},
Expand Down
2 changes: 0 additions & 2 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alp

ts.AddCheckpoint("version_ms")
log.Debugf("Generating Manifest for source %s revision %s", source, revisions[i])

// versionConfig :=
manifestInfo, err := repoClient.GenerateManifest(context.Background(), &apiclient.ManifestRequest{
Repo: repo,
Repos: permittedHelmRepos,
Expand Down
106 changes: 55 additions & 51 deletions pkg/apiclient/events/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions pkg/version_config_manager/version_config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
log "github.com/sirupsen/logrus"
)

const (
CodefreshAPIProviderType = "CodereshAPI"
ConfigMapProviderType = "ConfigMap"
)

type VersionConfig struct {
ProductLabel string `json:"productLabel"`
JsonPath string `json:"jsonPath"`
Expand All @@ -23,7 +28,7 @@ type ConfigMapProvider struct {
ConfigMapPath string
}

func (CodereshAPI *CodereshAPIConfigProvider) GetConfig() (*VersionConfig, error) {
func (codereshAPI *CodereshAPIConfigProvider) GetConfig() (*VersionConfig, error) {
// Implement logic to fetch config from the CodereshAPI here.
// For this example, we'll just return a mock config.
return &VersionConfig{
Expand All @@ -50,9 +55,9 @@ type VersionConfigManager struct {
func NewVersionConfigManager(providerType string, source string) (*VersionConfigManager, error) {
var provider ConfigProvider
switch providerType {
case "CodereshAPI":
case CodefreshAPIProviderType:
provider = &CodereshAPIConfigProvider{CodereshAPIEndpoint: source}
case "ConfigMap":
case ConfigMapProviderType:
provider = &ConfigMapProvider{ConfigMapPath: source}
default:
return nil, errors.New("Invalid provider type")
Expand All @@ -67,7 +72,7 @@ func (v *VersionConfigManager) ObtainConfig() (*VersionConfig, error) {
func GetVersionConfig() *VersionConfig {
versionConfigManager, err := NewVersionConfigManager("ConfigMap", "some-product-cm")
if err != nil {
log.Printf("ERROR: Failed to create VersionConfigManager: %v", err)
log.Errorf("ERROR: Failed to create VersionConfigManager: %v", err)
return nil
}

Expand Down
19 changes: 12 additions & 7 deletions reposerver/apiclient/repository.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions reposerver/repository/app_version.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package repository

import (
"fmt"
"os"
"path/filepath"
"strings"

log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"k8s.io/client-go/util/jsonpath"
)
Expand Down Expand Up @@ -90,9 +90,6 @@ func convertToJSONCompatible(i interface{}) (interface{}, error) {
}

func getAppVersions(appPath string, resourceName string, jsonPathExpression string) (*Result, error) {
// TODO: remove mock
// appPath = "/home/andrii/projects/codefresh/test-chart"

// Defaults
if resourceName == "" {
resourceName = "Chart.yaml"
Expand All @@ -106,7 +103,7 @@ func getAppVersions(appPath string, resourceName string, jsonPathExpression stri
if err != nil {
return nil, err
}
fmt.Printf("appVersion value: %v\n", *appVersion)
log.Printf("appVersion value: %v\n", *appVersion)

result := &Result{
AppVersion: *appVersion,
Expand Down
5 changes: 5 additions & 0 deletions reposerver/repository/repository.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ message Manifest {
}

message Dependencies {
// Content of Chart.lock
string lock = 1;
// Content of Cart.yaml/dependencies
string deps = 2;
// Content of requirements.yaml
string requirements = 3;
}

message ApplicationVersions {
// Application version presented by single value
string appVersion = 1;
// Yaml content of dependencies
Dependencies dependencies = 2;
}

Expand All @@ -123,6 +127,7 @@ message ManifestResponse {
string commitMessage = 8;
string commitAuthor = 9;
k8s.io.apimachinery.pkg.apis.meta.v1.Time commitDate = 10;
// A version of the application and its dependencies
ApplicationVersions applicationVersions = 11;
}

Expand Down
Loading

0 comments on commit 8ac7d17

Please sign in to comment.