viper | The Smart Virtual Machines Manager | Machine Learning library
kandi X-RAY | viper Summary
kandi X-RAY | viper Summary
The Smart Virtual Machines Manager
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of viper
viper Key Features
viper Examples and Code Snippets
Usage: viper [options]
Create, control and connect to VirtualBox VM instances.
Available commands:
Listing:
ls List created VMs
ps List running VMs
images List images
ip Show IP address for a run
$ viper create
# example
$ viper create ubuntu/bionic
$ viper create /path/to/provison.sh
# example
$ viper create ubuntu/bionic ~/init.sh
$ viper images
ubuntu/bionic (cached)
centos/8
$ viper ls
VM NAME IMAGE CPU MEM TAGS
vm_01 ubuntu/bionic 1 1024 MB spark kafka
vm_02 ubuntu/bionic 1 1024 MB
Community Discussions
Trending Discussions on viper
QUESTION
So I have a pretty basic configuration with Viper reading a .env file from my base directory. I fatal kill the process if there's no .env file. All goes well when running my app normally.
When I run my tests with go test -v ./..
, the test framework seems to step into each file's directory, and calls my config init() function each time, so the viper.AddConfigPath(".")
is pointing to the wrong location.
this is my directory structure:
...ANSWER
Answered 2021-Mar-30 at 01:59So apparently the viper.SetConfigFile()
call does not respect the viper.AddConfigPath()
call... I modified this to using viper.SetConfigName(".env")
and it would actually pick up the calls to AddConfigPath, so I could then add config paths for the current directory and parent.
QUESTION
I have a restful API utilizing mux and mongo-driver. Following a tutorial, I attempted to setup the server and mongo client like so in the main package:
...ANSWER
Answered 2021-Jun-05 at 21:42The standard way of doing this while avoiding globals would be to define a struct
that represents your server, and its methods would be the handlers. Then the methods share the struct's data, and you place things like your mongo client in there.
Something like this (in your admin
package):
QUESTION
I've just recently started working with Go, and I've run into some behavior working with Cobra and Viper that I'm not sure I understand.
This is a slightly modified version of the sample code you get by
running cobra init
. In main.go
I have:
ANSWER
Answered 2021-May-31 at 08:28I don't have any issue if I use cmd.PersistentFlags().Lookup("name")
.
QUESTION
I am trying to implement a simple iOS app using the VIPER pattern following this tutorial. The app is a simple table view which displays data from a json req
I have created the table view and can successfully show data from my object using the default cell.textLabel
. I am however trying to create a custom table view cell and so created the nib and class. I have connected all the outlets up correctly to the class from the nib and the code for this class is as follows:
ANSWER
Answered 2021-May-24 at 15:47I appreciate this might not be the correct answer for everyone, but this is what worked for me. I was struggling with trying to debug this and for the sake of time, I concluded that just creating everything programmatically would be easier. There are numerous tutorials for this, but I took the following structure: Stevia library used to set constraints for components and add subview
QUESTION
I've decided to try migrating my existing project architecture to VIPER. VIPER seems popular due to the way it separates modules. However, I have 2 similar view controllers that inherit from CustomVC. These 2 view controllers call for super methods to setup UI and run some business logic. If I leave the UI functionality in CustomVC, should I move the business logic to an analogous CustomPresenter superclass? Should I move common navigation behavior to an analogous CustomInteractor class? Okay, I do that, then what: do the 2 view controller modules inherit from the CustomPresenter and/or CustomInteractor classes? In the answers, please guide me toward what is acceptable in this situation, considering VIPER architecture goals. Thank you.
...ANSWER
Answered 2021-May-14 at 18:56- As described in https://TheSwiftDev.com/the-ultimate-viper-architecture-tutorial that teaches VIPER in its purest/original form (without some of the tangents that have appeared in recent years), VIPER is all about zones (or layers) of quarantined/divorced-apart functionality that speak to each other interzone via an app-domain data structs (many of which are the simpler E entities in the VIPER acronym) and the app-domain messages that each zone publish as their interzone API. In effect, each V I P R zone of VIPER presents a sort of façade to the other zones:
- while keeping UI/Apple-think/Android-think quarantined within V view zone, because such UI matters are not purely app-domain;
- while keeping sensor/datastore/networking/Apple-think/Android-think quarantined/divorced within I interactor zone, because such data-acquisition/data-exchange matters are not purely app-domain;
- while keeping navigation/Apple-think/Android-think/iOS-think/MacOS-think quarantined/divorced within R router zone, because such navigation matters are not purely app-domain (e.g., is the error presented by a pop-up modal dialog box or by a nonmetal dialog box or appending to the end of a scrolling log window-pane? as depending on which OS/platform) With all that in mind:
- The UI-centric CustomVC and its UI-centric subclasses go into V view zone in VIPER. A façade at the perimeter of V view zone translates interzone app-domain entity-based messages to intrazone UI concepts, constructs, and method invocations of Apple-think frameworks or Android-think frameworks.
- The business logic (which is obviously purely app-domain by definition) goes in the P presenter zone in VIPER. Whether there is a CustomPresenter superclass direct analogue in P presenter zone or whether P presenter zone models it differently due P presenter zone's own needs is a designer's choice, taking into account local taste. My point is that there is no strict rule to obey zealously there; not every way of organizing code in V view zone is the way to organizing code in P presenter zone.
- The navigation goes in the R router zone in VIPER. A façade at the perimeter of R router zone translates interzone app-domain entity-based messages to intrazone navigation concepts, constructs, and method invocations of Apple-think frameworks or Android-think frameworks. For example, the navigation might be different on iOS than on MacOS than on an Android port of the same app, because a pop-up modal dialog box versus a semipermanent nonmodal dialog box versus a window-pane might exist in your app's designed UI on certain platform(s) but not on other platform(s). Especially for navigation, ponder just a moment while working on, say, a currently iOS-only app, whether that might be done differently on, say, a desktop MacOS app or on an Android port of the app. If your current architecture of the app is anything like Massive View Controller, you might have navigation quite comingled with UI (which is one symptom of the massive of Massive View Controller antipattern); you will need then need to meticulously tease navigation apart from UI so that navigation & UI get quarantined/divorced separate from each other. Whether there is a CustomRouter superclass direct analogue in R router zone or whether R router zone models it differently due R router zone's own needs is a designer's choice, taking into account local taste. My point is that there is no strict rule to obey zealously there; not every way of organizing code in V view zone is the way to organizing code in R router zone.
- The sensor, datastore, and networking goes in the I interactor zone of VIPER. A façade at the perimeter of I interactor zone translates interzone app-domain entity-based messages to intrazone sensor/datastore/networking concepts, constructs, and method invocations of Apple-think frameworks or Android-think frameworks or 3rd-party libraries/frameworks. In this zone especially, ponder a little bit whether the quarantine/divorce is so clean & perfect that you can swap out non-app-domain infrastructure X for a different non-app-domain infrastructure Y, such as swap out a database instead of Apple Core Data that perhaps your app outgrew. Whether there is a CustomInteractor superclass direct analogue in I interactor zone or whether I interactor zone models it differently due I interactor zone's own needs is a designer's choice, taking into account local taste. My point is that there is no strict rule to obey zealously there; not every way of organizing code in V view zone is the way to organizing code in I interactor zone.
- The purely app-domain lingua franca interzone is partially simple entities in E entity zone, but more & more nowadays it is also reactive functional-programming-lite effect-event subscriptions & flows, such as RxSwift or Realm. RxSwift if the lingua-franca interzone programming language is Swift (or its Android analogues RxKotlin or RxJava or ZIO+CatsEffect if in Scala if the lingua-franca interzone programming language is one of those 3 languages) can be chosen by the designer as the official app-domain purity. Realm is messier because it does much of what RxSwift does, but when Realm is in interzone lingua franca, now Realm in the datastore interactor zone has not been kept quarantined within its proper datastore-interactor compartment, so now Realm cannot be swapped out as easily for some even better datastore technology in the future. The main moral of the story is: wisely overtly design & choose what comprises the pure app-domain lingua franca entities, messaging, philosophy, dependencies, etc interzone because that is the portion you need to live with unchanged as the app evolves to new OSes, new platforms, new infrastructure.
So no, once all the UI, business logic, and sensor/datastore/networking data-acquisition/exchange has been entirely separated from each other, the view controllers would no longer have anything directly to do with CustomPresenter or with CustomInteractor or CustomRouter, most especially no inheritance from them. All interactions among CustomUI & its subclasses versus CustomPresenter & its subclasses (if any) versus CustomInteractor & its subclasses (if any) versus CustomRouter & its subclasses (if any) would be via pure app-domain messaging (or effect-event subscription) interzone via app-domain lightweight entities—i.e., indirect interaction through V view zone's façade and/or I interactor zone's façade with P presenter zone.
QUESTION
I'm trying to learn how to use VIPER with android from this tutorial https://www.raywenderlich.com/5192-android-viper-tutorial but in the end of tutorial it said it's hard to implement the router layer which a core layer of the architecture .. is there anyway to implement viper and it's router layer across navigation component
...ANSWER
Answered 2021-May-05 at 03:10- Router is navigation; navigation is router. You should not think the way that you phrased the question, because “implement … router … across navigation component” will mislead your thinking. https://TheSwiftDev.com/the-ultimate-viper-architecture-tutorial is succinct and clear in establishing good thinking regarding VIPER, although even it could be even better if it drove the following point home even more intensely: 100% of the messaging & data-structures/entities & concepts interlayer between V I P R layers must be strictly app-domain concepts that have nothing to do with Apple-think or Android-think or Microsoft-think. All of the {Apple-frameworks-think, Android-think, Microsoft/UWP-think} must be quarantined within each the V I R layers and never appear at all in the P and E layers.
- It is best to learn navigation from VIPER and MVVM-C examples. The C of MVVM-C is almost exactly the same as the R of VIPER; both are responsible for navigation. There are multiple example/sample apps (as well as few open-source full-fledged apps) that use either VIPER or MVVM-C. Search for them via Bing or Google. You can learn the R of VIPER just as well from the C of MVVM-C if MVVM-C was done properly with strictly app-domain concepts/data-structures/messaging/entities flowing between VM & C without contamination between VM & C layers from {Android-think, Apple-think, Microsoft-think}. Even if messaging between VM & C layers is muddled with {Apple-think, Android-think, Microsoft-think} in some sample/example MVVM-C app, you can still learn from it by translating the operating-environment-pollution interlayer to strictly-app-domain information flows interlayer, but that is pretty much the how-to-convert-my-app-to-reactive/Rx technique by inserting {RxKotlin, RxSwift, RxScala, ZIO+CatsEffect} effect/outcome-centric reactive information flows interlayer instead of some {Android, Apple, Microsoft}-centric delegate/callback mechanism.
- Because VIPER and MVVM-C and Clean all need a pure app-domain interzone way of messaging that has {Apple-think, Android-think, Microsoft-think} quarantined within each layer/zone (e.g., keeping Apple-think/Android-think/Microsoft-think ways of representing UI strictly quarantined within view layer in VIPER; keeping Apple-think/Android-think/Microsoft-think ways of representing navigation strictly quarantined within router layer in VIPER), quite often design teams choose to use an event-driven functional-programming-esque reactive way of representing the strictly app-domain messaging that is flowing between each of the V I P R layers in VIPER (with E entities being the lingua franca of representing app-domain concepts between layers). As such, you can often use such reactive frameworks (e.g., RxSwift when in Apple world; ZIO or Cats Effect or RxScala when in the Scala school of thought within Android world; RxKotlin when in the Kotlin school of thought within Android world) as the primary search word for sample or example apps for that reactive framework, then cherry picking from the list of results the example or sample apps that are VIPER or MVVM-C, such as in https://AwesomeOpenSource.com/projects/rxswift where the description indicates which ones teach VIPER's or MVVM-C's R or C techniques that you will find quite instructive.
QUESTION
I would like to play with a specific Viper Module in my project. Technically now when I need to open a specific UIViewController I need to go through some screens enter some data and etc and then in a 20 seconds I am there in that specific screen.
So it takes a lot of time to navigate somewhere when I just need for example to test some small things (like UI adjustment, changing some strings how they fit screen and etc).
Instead I would like to run the specific screen when I run my project.
For sure mocking and injection will help a lot in this case as I need to insatiate my Viper Module with some initial data. This is just a technical detail here.
I would like to know how can organise my project to run specific modules instead of running entire project.
Hardcoded solution like using app delegate by adding extra code which overwriting initial point it's just a temp solution and you need to clean app delegate when you finish.
I may be wrong but I think there is should be a specific target solution which can run different modules whether it will initial point like HomeViewController or a specific module with mock injection.
...ANSWER
Answered 2021-Apr-29 at 21:48To set the ground-rules of this answer, https://TheSwiftDev.com/the-ultimate-viper-architecture-tutorial describes the most-normative original-school-of-thought variant of what VIPER is and what it is intended to accomplish as self-discipline. (Other derivative viewpoints have arisen in the past several years, but I'll use this original school of thought in this answer for all-the-wood-behind-1-arrow clarity & pedagogical reasons.)
I am going to politely reject OP's usage of “module” with respect to VIPER. Instead, VIPER is 5 zones {view for UI, interactor for datastore/networking/sensors, presenter for app-domain ‘business’ rules, entities for app-domain-centric [not datastore-centric, not network-centric, not sensor-centric] data structures, router for navigation} of quarantine & some degree of divorce. Someone might just say that zone & module are 100% synonyms/congruent, but I am going to tease them apart as separate interpretations. The 5 V I P E R zones are all about the divorce/quarantine from each other to stamp out Massive View Controller antipattern/code-smell software-architecture https://khanlou.com/2015/12/massive-view-controller and https://www.hackingwithswift.com/articles/159/how-to-refactor-massive-view-controllers, which is a mobile-app variant of the older-era Big Ball of Mud antipattern/code-smell software-architecture http://www.laputan.org/mud/mud.html#BigBallOfMud
Modules on the other hand can be interpreted as finer-grained than the 5 V I P E R zones. Let's do that here. Each zone of VIPER can be further subdivided into modules of like-topic portions of that zone, such as all the (sub)views comprising a scene/screen/containing-view or any other subcategorization of the app that one's heart desires. Module demarcation can be orthogonal (or oblivious) to the 5 V I P E R zones. Indeed, a designer might choose to have the same module demarcation within each of 2 or more V I P E R zones. Or just as validly, a designer might choose to have a quite-different module demarcation within view zone than within interactor zone than within presenter zone, because they each by happenstance focus on a different way of decomposing that isolated/divorced/quarantined zone in a way that is sensible only within that zone (and would make little sense over in some other 4 zones). Hence, from this answer's vantage, we won't mention modules anymore because it is a local taste within each zone, unrelated to the OP's intended goal.
Each zone in properly-accomplished VIPER architecture has been quarantined so that UI-specific topics never escaped outside of view zone (e.g., into most-temptingly presenter zone or router zone or [usually a lesser temptation unless heavily mimicking nonVIPER examples for sensor or networking data acquisition] interactor zone). Because of this quarantine, the OP's goal is effectively to have a quite-different router/navigation zone that drives the app in testing mode through its various scenes/screens/modal-dialogs in a way that might even be unnatural for the human-being-user variant of the app & its router navigation. But the entire purpose long-term for VIPER software architecture is to swap out a whole zone because it has such impeccable quarantine/divorce—literally like swapping out one spouse for another via marriage divorce. That is what OP is effectively seeking: the wholesale swapping out (primarily) the human-being-user variant of the router zone with a test-mock router zone that drives the app via script-like marching orders to march the UI in ways that take annoyingly too much effort to accomplish via human-being-user UI actions. The mocked/scripted substitute router zone is free to ‘short-circuit’ as it pleases to skip portions of the UI as long as any accumulated state that would have been naturally built up is backfilled as part of the mocking scriptedness. If router would not have had access to whichever methods/API are necessary to accomplish that backfilling of accumulated state when short-circuited navigating to a portion/screen/scene of the UI, then either a) that separation of concerns is eroded so that the mocked/scripted substitute router zone is less quarantined than its regular human-user variant or b) some other zone needs some degree of mocking to backfill that canned accumulated state to cooperate with the mocked/scripted substitute router zone.
But to accomplish this swap-out of the usual router zone with a mechanistic/test/mocked router zone for script-like navigation of the UI, the interactor zone especially must be mocked out too to drive canned datastore content, canned network content, and canned sensor content/acquisition in a script-like manner as well in ways that cooperate with the testing/mocked router variant. Indeed, the quarantine/divorce so sought after in the usual app-domain human-being-user variant of the app is the prize, but far less quarantine perhaps no divorce at all might be the laudable goal between the mocked/testing router zone and the mocked/testing interactor zone, which might conspire together quite intimately to accomplish their scripted/canned mocking functionality together as one mindset. So what is good divorce/quarantine separation of concerns for the human-being-user primary variant of the app would likely be disastrous separation in the OP's mocking/testing variant of the app, because in effect there is no such separation of concerns between the scripted/mocked router zone substituted in and the scripted/mocked interactor zone substituted in.
One would hope that the presenter's business-rules quasi-backend-esque processing doesn't need to be mocked out, as hopefully the enforcement of those app-domain business rules are not going to get in the way of mechanistic driving of the UI 1) with mocked/scripted navigation via the substituted router zone and 2) with mocked/scripted data from mocked/scripted sensors, mocked/scripted datastore, and/or mocked/scripted networking. If some app-domain needs to separate out pure UI testing in view zone from pure business-rules/quasi-backend testing in presenter zone, then a mocked-UI view zone would test/drive the real presenter zone and a mocked-business-rule presenter zone (with perhaps alternate-reality/fuzzed business rules) would test/enforce-more-strictly the real view zone.
Conversely, if the developers of an app failed to 100% quarantine, say, UI topics within view zone, then the ability to swap out the UI-contaminated nonview zones is eroded perhaps fatally to the point that nonview zone cannot be swapped out with a testing/mock substitute of that nonview zone. To accomplish this 100% strict quarantine interzone among the V I P E R zones requires overt self-discipline of assuring that 100% of the interzone messaging/method-invocation is expressed in purely app-domain concepts without contamination from Apple-think or its constructs, Android-think or its concepts, and so forth. Each V I P R zone (other than rather simple entities in E) usually needs a façade layer at the perimeter of each zone to interwork intrazone concepts with app-domain interzone concepts, such as quarantining all of Apple-think UI constructs or Android-think UI concepts within view zone so that only higher-order-thought app-domain concepts are exchanged interzone—likewise with a façade at the perimeter of interactor zone for interworking the quarantine of datastore-centric or sensor-centric or networking-centric constructs intrazone away from higher-order-thought app-domain concepts interzone.
Likewise, instead of fully automatic scripted navigation, another testing/mock substitute of the router navigation zone could fast-forward the human-being user to a particular portion/screen/scene of the UI for manual interaction for semiautomated testing. The fast forwarding could be to a relatively unfilled-out screen/scene. Or the fast forwarding could be to, say, an editing-something screen with canned elaborate entity to edit already loaded, which is especially useful if the canned elaborate entity is especially pernicious in exercising some use-case or just the right combination of situations for reproduction of a bug.
QUESTION
I am using GoLang and Viper as inferred from the questions title. My element.yml file which is in the same directory as the file trying to parse it is able to get Strings and Integers but for whatever reason cannot get a Slice of Strings with the method GetStringSlice(). Does anybody know what I'm doing wrong? I ran my yml in a validator which confirmed everything was fine. Code is as follows :
...ANSWER
Answered 2021-Apr-28 at 16:35I had no issues running this on my machine.
I suggest you try catching the error on read file and see if that helps.
You can also provide the file path if needed.
QUESTION
I have a dotenv file in the current format
...ANSWER
Answered 2021-Apr-26 at 18:46spf13/viper predominantly uses mapstructure package to convert between one native Go type to another i.e. when un-marshaling. You need to define an annotation that would cause any unused values to this map. There is an option to collect such reminder values. You need to modify the map to take an interface as
QUESTION
The sketch below is a command line application written using Cobra and Go. I'd like to throw an error if the value of flag1
doesn't match the regex ^\s+\/\s+
. How do I do that?
ANSWER
Answered 2021-Apr-22 at 18:14Let's say a user runs the command like this: cobra-sketch --flag1 "hello"
. "hello" will be stored in the var flag1 string
variable you have assigned to the flag, to check if the input matches any regexp, you can do:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install viper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page