Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apptrust/commands/application/delete_app_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func GetDeleteAppCommand(appContext app.Context) components.Command {
Optional: false,
},
},
Flags: commands.GetCommandFlags(commands.AppDelete),
Action: cmd.prepareAndRunCommand,
}
}
10 changes: 3 additions & 7 deletions apptrust/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
accessToken = "access-token"
ProjectFlag = "project"

ApplicationKeyFlag = "application-key"
SpecFlag = "spec"
SpecVarsFlag = "spec-vars"
StageVarsFlag = "stage"
Expand Down Expand Up @@ -63,17 +62,16 @@ var flagsMap = map[string]components.Flag{
accessToken: components.NewStringFlag(accessToken, "JFrog access token.", func(f *components.StringFlag) { f.Mandatory = false }),
ProjectFlag: components.NewStringFlag(ProjectFlag, "Project key associated with the application. This flag is mandatory when the --spec flag is not provided.", func(f *components.StringFlag) { f.Mandatory = false }),

ApplicationKeyFlag: components.NewStringFlag(ApplicationKeyFlag, "Application key.", func(f *components.StringFlag) { f.Mandatory = false }),
SpecFlag: components.NewStringFlag(SpecFlag, "A path to the specification file.", func(f *components.StringFlag) { f.Mandatory = false }),
SpecVarsFlag: components.NewStringFlag(SpecVarsFlag, "List of semicolon-separated (;) variables in the form of \"key1=value1;key2=value2;...\" (wrapped by quotes) to be replaced in the File Spec. In the File Spec, the variables should be used as follows: ${key1}.", func(f *components.StringFlag) { f.Mandatory = false }),
StageVarsFlag: components.NewStringFlag(StageVarsFlag, "Promotion stage.", func(f *components.StringFlag) { f.Mandatory = true }),
ApplicationNameFlag: components.NewStringFlag(ApplicationNameFlag, "The display name of the application.", func(f *components.StringFlag) { f.Mandatory = false }),
DescriptionFlag: components.NewStringFlag(DescriptionFlag, "The description of the application.", func(f *components.StringFlag) { f.Mandatory = false }),
BusinessCriticalityFlag: components.NewStringFlag(BusinessCriticalityFlag, "The business criticality level. The following values are supported: "+coreutils.ListToText(model.BusinessCriticalityValues), func(f *components.StringFlag) { f.Mandatory = false }),
MaturityLevelFlag: components.NewStringFlag(MaturityLevelFlag, "The maturity level.", func(f *components.StringFlag) { f.Mandatory = false }),
MaturityLevelFlag: components.NewStringFlag(MaturityLevelFlag, "The maturity level. The following values are supported: "+coreutils.ListToText(model.MaturityLevelValues), func(f *components.StringFlag) { f.Mandatory = false }),
LabelsFlag: components.NewStringFlag(LabelsFlag, "List of semicolon-separated (;) labels in the form of \"key1=value1;key2=value2;...\" (wrapped by quotes).", func(f *components.StringFlag) { f.Mandatory = false }),
UserOwnersFlag: components.NewStringFlag(UserOwnersFlag, "Comma-separated list of user owners.", func(f *components.StringFlag) { f.Mandatory = false }),
GroupOwnersFlag: components.NewStringFlag(GroupOwnersFlag, "Comma-separated list of group owners.", func(f *components.StringFlag) { f.Mandatory = false }),
UserOwnersFlag: components.NewStringFlag(UserOwnersFlag, "semicolon-separated (;) list of user owners.", func(f *components.StringFlag) { f.Mandatory = false }),
GroupOwnersFlag: components.NewStringFlag(GroupOwnersFlag, "semicolon-separated (;) list of group owners.", func(f *components.StringFlag) { f.Mandatory = false }),
SyncFlag: components.NewBoolFlag(SyncFlag, "Whether to synchronize the operation.", components.WithBoolDefaultValueTrue()),
PromotionTypeFlag: components.NewStringFlag(PromotionTypeFlag, "The promotion type. The following values are supported: "+coreutils.ListToText(model.PromotionTypeValues), func(f *components.StringFlag) { f.Mandatory = false; f.DefaultValue = model.PromotionTypeCopy }),
DryRunFlag: components.NewBoolFlag(DryRunFlag, "Perform a simulation of the operation.", components.WithBoolDefaultValueFalse()),
Expand Down Expand Up @@ -151,14 +149,12 @@ var commandFlags = map[string][]string{
user,
accessToken,
serverId,
ApplicationKeyFlag,
},
PackageUnbind: {
url,
user,
accessToken,
serverId,
ApplicationKeyFlag,
},

Ping: {
Expand Down
2 changes: 1 addition & 1 deletion apptrust/commands/version/create_app_version_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func validateCreateAppVersionContext(ctx *components.Context) error {

if !hasSource {
return errorutils.CheckErrorf(
"At least one source flag is required to create an application version. Please provide one of the following: --%s, --%s, --%s, or --%s.",
"At least one source flag is required to create an application version. Please provide --%s or at least one of the following: --%s, --%s, --%s.",
commands.SpecFlag, commands.SourceTypeBuildsFlag, commands.SourceTypeReleaseBundlesFlag, commands.SourceTypeApplicationVersionsFlag)
}

Expand Down
4 changes: 2 additions & 2 deletions apptrust/commands/version/create_app_version_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
},
expectsPayload: nil,
expectsError: true,
errorContains: "At least one source flag is required to create an application version. Please provide one of the following: --spec, --source-type-builds, --source-type-release-bundles, or --source-type-application-versions.",
errorContains: "At least one source flag is required to create an application version. Please provide --spec or at least one of the following: --source-type-builds, --source-type-release-bundles, --source-type-application-versions.",
},
{
name: "empty flags",
Expand All @@ -166,7 +166,7 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
},
expectsPayload: nil,
expectsError: true,
errorContains: "At least one source flag is required to create an application version. Please provide one of the following: --spec, --source-type-builds, --source-type-release-bundles, or --source-type-application-versions.",
errorContains: "At least one source flag is required to create an application version. Please provide --spec or at least one of the following: --source-type-builds, --source-type-release-bundles, --source-type-application-versions.",
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"application_key": "should-be-ignored",
"packages": [
{"type": "npm", "name": "pkg-conflict", "version": "0.3.0", "repository": "repo-conflict"}
{
"type": "npm",
"name": "pkg-conflict",
"version": "0.3.0",
"repository_key": "repo-conflict"
}
]
}
7 changes: 6 additions & 1 deletion apptrust/commands/version/testfiles/invalid-spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"packages": [
{"type": "npm", "name": "pkg-invalid", "version": "0.1.0", "repository": "repo-invalid"}
{
"type": "npm",
"name": "pkg-invalid",
"version": "0.1.0",
"repository_key": "repo-invalid"
}
]
// missing closing brace and invalid JSON
7 changes: 6 additions & 1 deletion apptrust/commands/version/testfiles/minimal-spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"packages": [
{"type": "npm", "name": "pkg-min", "version": "0.1.0", "repository": "repo-min"}
{
"type": "npm",
"name": "pkg-min",
"version": "0.1.0",
"repository_key": "repo-min"
}
]
}
2 changes: 1 addition & 1 deletion apptrust/commands/version/testfiles/test-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "pkg1",
"version": "1.0.0",
"repository": "repo1",
"repository_key": "repo1",
"type": "npm"
}
],
Expand Down
7 changes: 6 additions & 1 deletion apptrust/commands/version/testfiles/unknown-fields-spec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"packages": [
{"type": "npm", "name": "pkg-unknown", "version": "0.2.0", "repository": "repo-unknown"}
{
"type": "npm",
"name": "pkg-unknown",
"version": "0.2.0",
"repository_key": "repo-unknown"
}
],
"unknown_field": "should be ignored"
}
7 changes: 6 additions & 1 deletion apptrust/commands/version/testfiles/with-vars-spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"packages": [
{"type": "npm", "name": "${PKG_NAME}", "version": "${PKG_VERSION}", "repository": "${PKG_REPO}"}
{
"type": "npm",
"name": "${PKG_NAME}",
"version": "${PKG_VERSION}",
"repository_key": "${PKG_REPO}"
}
]
}
2 changes: 1 addition & 1 deletion apptrust/model/create_app_version_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type CreateVersionPackage struct {
Type string `json:"type"`
Name string `json:"name"`
Version string `json:"version"`
Repository string `json:"repository"`
Repository string `json:"repository_key"`
}

type CreateVersionSources struct {
Expand Down
2 changes: 1 addition & 1 deletion apptrust/model/promote_app_version_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ type CommonPromoteAppVersion struct {

type PromoteAppVersionRequest struct {
CommonPromoteAppVersion
Stage string `json:"stage"`
Stage string `json:"target_stage"`
}
7 changes: 4 additions & 3 deletions apptrust/service/applications/application_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"

"github.com/jfrog/jfrog-cli-application/apptrust/model"
"github.com/jfrog/jfrog-cli-application/apptrust/service"
Expand Down Expand Up @@ -35,7 +36,7 @@ func (as *applicationService) CreateApplication(ctx service.Context, requestBody
response.StatusCode, responseBody)
}

fmt.Println(string(responseBody))
log.Output(string(responseBody))
return nil
}

Expand All @@ -51,7 +52,7 @@ func (as *applicationService) UpdateApplication(ctx service.Context, requestBody
response.StatusCode, responseBody)
}

fmt.Println(string(responseBody))
log.Output(string(responseBody))
return nil
}

Expand All @@ -67,6 +68,6 @@ func (as *applicationService) DeleteApplication(ctx service.Context, application
response.StatusCode, responseBody)
}

fmt.Println("Application deleted successfully")
log.Output("Application deleted successfully")
return nil
}
3 changes: 3 additions & 0 deletions apptrust/service/packages/package_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/jfrog/jfrog-cli-application/apptrust/model"
"github.com/jfrog/jfrog-cli-application/apptrust/service"
"github.com/jfrog/jfrog-client-go/utils/log"
)

type PackageService interface {
Expand All @@ -34,6 +35,7 @@ func (ps *packageService) BindPackage(ctx service.Context, applicationKey string
response.StatusCode, responseBody)
}

log.Output(string(responseBody))
return nil
}

Expand All @@ -49,5 +51,6 @@ func (ps *packageService) UnbindPackage(ctx service.Context, applicationKey, pkg
response.StatusCode, responseBody)
}

log.Output("Package unbound successfully")
return nil
}
3 changes: 2 additions & 1 deletion apptrust/service/systems/system_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/jfrog/jfrog-cli-application/apptrust/service"
"github.com/jfrog/jfrog-client-go/utils/log"
)

type SystemService interface {
Expand All @@ -28,6 +29,6 @@ func (ss *systemService) Ping(ctx service.Context) error {
return fmt.Errorf("failed pinging application service. Status code: %d", response.StatusCode)
}

fmt.Println(string(body))
log.Output(string(body))
return nil
}
5 changes: 5 additions & 0 deletions apptrust/service/versions/version_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"

"github.com/jfrog/jfrog-cli-application/apptrust/service"
"github.com/jfrog/jfrog-client-go/utils/log"

"github.com/jfrog/jfrog-cli-application/apptrust/model"
)
Expand Down Expand Up @@ -39,6 +40,7 @@ func (vs *versionService) CreateAppVersion(ctx service.Context, request *model.C
response.StatusCode, responseBody)
}

log.Output(string(responseBody))
return nil
}

Expand All @@ -54,6 +56,7 @@ func (vs *versionService) PromoteAppVersion(ctx service.Context, applicationKey,
response.StatusCode, responseBody)
}

log.Output(string(responseBody))
return nil
}

Expand All @@ -69,6 +72,7 @@ func (vs *versionService) ReleaseAppVersion(ctx service.Context, applicationKey,
response.StatusCode, responseBody)
}

log.Output(string(responseBody))
return nil
}

Expand All @@ -84,6 +88,7 @@ func (vs *versionService) RollbackAppVersion(ctx service.Context, applicationKey
response.StatusCode, responseBody)
}

log.Output("Application version deleted successfully")
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
// system.GetPingCommand(appContext),
// version.GetCreateAppVersionCommand(appContext),
// version.GetPromoteAppVersionCommand(appContext),
// version.GetRollbackAppVersionCommand(appContext),
// version.GetReleaseAppVersionCommand(appContext),
// version.GetDeleteAppVersionCommand(appContext),
// packagecmds.GetBindPackageCommand(appContext),
// packagecmds.GetUnbindPackageCommand(appContext),
Expand Down
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module github.com/jfrog/jfrog-cli-application

go 1.23.7

toolchain go1.23.9
go 1.24.6

require (
github.com/jfrog/jfrog-cli-core/v2 v2.58.7
github.com/jfrog/jfrog-client-go v1.53.1
github.com/jfrog/jfrog-cli-core/v2 v2.59.5
github.com/jfrog/jfrog-client-go v1.54.5
github.com/stretchr/testify v1.10.0
github.com/urfave/cli v1.22.16
go.uber.org/mock v0.5.2
Expand Down Expand Up @@ -43,7 +41,7 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jedib0t/go-pretty/v6 v6.6.5 // indirect
github.com/jfrog/archiver/v3 v3.6.1 // indirect
github.com/jfrog/build-info-go v1.10.12 // indirect
github.com/jfrog/build-info-go v1.10.16 // indirect
github.com/jfrog/gofrog v1.7.6 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
Expand Down
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk=
github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down Expand Up @@ -93,14 +91,14 @@ github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3N
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
github.com/jfrog/build-info-go v1.10.12 h1:KO/YUeKYtDrnpcmsXmwqr6akjzrwA0hSTUB+Op/HF88=
github.com/jfrog/build-info-go v1.10.12/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
github.com/jfrog/build-info-go v1.10.16 h1:M77OfTXl3Ew9AG9SIIYLAG5ccIIaf6xjIZ5nomc2XAw=
github.com/jfrog/build-info-go v1.10.16/go.mod h1:szdz9+WzB7+7PGnILLUgyY+OF5qD5geBT7UGNIxibyw=
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
github.com/jfrog/jfrog-cli-core/v2 v2.58.7 h1:njRlkJjNZ1cvG25S/6T4h+ouI+ZRABN6xZN87UIzB/M=
github.com/jfrog/jfrog-cli-core/v2 v2.58.7/go.mod h1:ZXcipUeTTEQ/phqHdbCh4wJ5Oo4QVDxzQBREQ0J9mDc=
github.com/jfrog/jfrog-client-go v1.53.1 h1:GDRLUDs6hhfGNjqbI+bjc3ApgBHnpVwURM+f26PVfyw=
github.com/jfrog/jfrog-client-go v1.53.1/go.mod h1:XxYs2QtlTm92yqJ5O4j4vzWI8d4sDtKQUT1miNHMgnw=
github.com/jfrog/jfrog-cli-core/v2 v2.59.5 h1:zPUOquY8gakWHJSdQifdcleFL0U23I0bdQdOYqxXAj4=
github.com/jfrog/jfrog-cli-core/v2 v2.59.5/go.mod h1:+zJfCkkFRWDbRTGpHsoaLZw5ze1xzRwffaLKuXjrZKc=
github.com/jfrog/jfrog-client-go v1.54.5 h1:WKd26zbJYPCgKTTFFflHnX/1QqtZt0IXh3czlikXsyY=
github.com/jfrog/jfrog-client-go v1.54.5/go.mod h1:+pSVE7Co+ytwhOhmz84/Lpe5fSeTaWJXsP1qt+WVfw0=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
Expand Down