Skip to content

Commit

Permalink
change to environment
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNino committed Jul 5, 2023
1 parent edb634c commit cbc3e5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion artifactory/commands/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

const (
// The actual field in the repository configuration is an array (plural) but in practice only one environment is allowed.
// This is why the question differs from the repository configuration.
environmentsKey = "environments"
)

type RepoCommand struct {
serverDetails *config.ServerDetails
templatePath string
Expand Down Expand Up @@ -88,7 +94,7 @@ var writersMap = map[string]utils.AnswerWriter{
ExcludePatterns: utils.WriteStringAnswer,
RepoLayoutRef: utils.WriteStringAnswer,
ProjectKey: utils.WriteStringAnswer,
Environments: utils.WriteStringArrayAnswer,
environmentsKey: utils.WriteStringArrayAnswer,
HandleReleases: utils.WriteBoolAnswer,
HandleSnapshots: utils.WriteBoolAnswer,
MaxUniqueSnapshots: utils.WriteIntAnswer,
Expand Down
13 changes: 7 additions & 6 deletions artifactory/commands/repository/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
ExcludePatterns = "excludesPattern"
RepoLayoutRef = "repoLayoutRef"
ProjectKey = "projectKey"
Environments = "environments"
Environment = "environment"

// Mutual local and remote repository configuration JSON keys
HandleReleases = "handleReleases"
Expand Down Expand Up @@ -223,7 +223,7 @@ var optionalSuggestsMap = map[string]prompt.Suggest{
ExcludePatterns: {Text: ExcludePatterns},
RepoLayoutRef: {Text: RepoLayoutRef},
ProjectKey: {Text: ProjectKey},
Environments: {Text: Environments},
Environment: {Text: Environment},
HandleReleases: {Text: HandleReleases},
HandleSnapshots: {Text: HandleSnapshots},
MaxUniqueSnapshots: {Text: MaxUniqueSnapshots},
Expand Down Expand Up @@ -295,7 +295,7 @@ var optionalSuggestsMap = map[string]prompt.Suggest{
}

var baseLocalRepoConfKeys = []string{
Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environments, BlackedOut, XrayIndex,
Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environment, BlackedOut, XrayIndex,
PropertySets, ArchiveBrowsingEnabled, OptionalIndexCompressionFormats, DownloadRedirect, BlockPushingSchema1,
}

Expand All @@ -320,7 +320,7 @@ var dockerLocalRepoConfKeys = []string{
}

var baseRemoteRepoConfKeys = []string{
Username, Password, Proxy, Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environments, HardFail, Offline,
Username, Password, Proxy, Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environment, HardFail, Offline,
BlackedOut, XrayIndex, StoreArtifactsLocally, SocketTimeoutMillis, LocalAddress, RetrievalCachePeriodSecs, FailedRetrievalCachePeriodSecs,
MissedRetrievalCachePeriodSecs, UnusedArtifactsCleanupEnabled, UnusedArtifactsCleanupPeriodHours, AssumedOfflinePeriodSecs,
ShareConfiguration, SynchronizeProperties, BlockMismatchingMimeTypes, PropertySets, AllowAnyHostAuth, EnableCookieManagement,
Expand Down Expand Up @@ -385,7 +385,7 @@ var vcsRemoteRepoConfKeys = []string{
}

var baseVirtualRepoConfKeys = []string{
Repositories, Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environments, ArtifactoryRequestsCanRetrieveRemoteArtifacts,
Repositories, Description, Notes, IncludePatterns, ExcludePatterns, RepoLayoutRef, ProjectKey, Environment, ArtifactoryRequestsCanRetrieveRemoteArtifacts,
DefaultDeploymentRepo,
}

Expand Down Expand Up @@ -797,9 +797,10 @@ var questionMap = map[string]utils.QuestionInfo{
Writer: utils.WriteStringAnswer,
Callback: projectKeyCallback,
},
Environments: {
Environment: {
PromptPrefix: "Insert the name of the environment to assign to >",
AllowVars: true,
MapKey: environmentsKey,
Writer: utils.WriteStringAnswer,
},
HandleReleases: BoolToStringQuestionInfo,
Expand Down
4 changes: 3 additions & 1 deletion artifactory/commands/utils/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ func OptionalKeyCallback(iq *InteractiveQuestionnaire, key string) (value string
if key != SaveAndExit {
valueQuestion := iq.QuestionsMap[key]
// Since we are using default question in most of the cases we set the map key here.
valueQuestion.MapKey = key
if valueQuestion.MapKey == "" {
valueQuestion.MapKey = key
}
editOptionalQuestionPromptPrefix(&valueQuestion, key)
value, err = iq.AskQuestion(valueQuestion)
}
Expand Down

0 comments on commit cbc3e5f

Please sign in to comment.